-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix event mapping implementation for statsd module #36925
Conversation
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
Hi @ritalwar, |
Issue details: Root Cause: Here are the specifics: The data periodically sent by Airflow is not limited to a single DAG; it can encompass information from all currently running DAGs. This collective data is gathered into a group and subsequently processed to generate an event. The issue was traced back to a for loop used to iterate through all the key-value pairs within this group to create a single event. Because the data originates from multiple DAGs, creating a single event resulted in the data from one DAG overwriting the data from another. This led to the chaotic mixing of metrics, causing the problem at hand. Solution: We've updated the implementation to match the approach used in the statsd exporter. Now, each key-value pair and its associated attributes are treated as individual events. As a result, each key-value pair is processed to create distinct events, with only the related fields present in each event. This modification effectively resolves the issue and offers greater flexibility when using controls and filters to generate visualizations for related data. |
For this configuration:
Document generated before the change, with all data combined into a single event: And after change, document featuring only one related field and its attributes within a single event: |
Testing DetailsTest Setup
Test Case Scenarios
|
Just left a minor comment, all other changes look good to me. |
The change looks good to me. However, as discussed, i would recommend to have it tested with Graphite for additional test coverage, if time permits. @aliabbas-elastic , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Yes, we can check if statsd.mappings work well with Graphite metrics and if it's logical to have separate events in there too. |
Sure @agithomas I am looking into it. |
Brought up Graphite with default metrics in it Defined mappings for the same in Refer one Corresponding mapping for the metric in
Sample Event for the same:-
cc:- @agithomas @ritalwar |
for idx, tagGroup := range groups { | ||
|
||
mapstrTags := mapstr.M{} | ||
// If there are no groups, return an empty slice. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny nit: the comment does not match the code - we aren't returning an empty slice here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
} | ||
events = append(events, &mb.Event{ | ||
MetricSetFields: ms, | ||
RootFields: mapstr.M{"labels": mapstrTags}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to worry about increasing storage cost by duplicating the tags across many more metric documents?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tags aren't always there. We're not adding them ourselves; they are optional. In fact, I couldn't find them in the case of Airflow, so there is no extra overhead involved. More about StatsD tags in general, as they are supported by every StatsD implementation, such as Datadog and Atlassian. Same we are supporting this here.
<-done | ||
|
||
assert.Len(t, events, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this test fail without the new changes in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed running the test before making this change, but I've run it now and made the necessary updates(the tags needed to be identical for both the events to test this change). Thanks!
f46ecaa
to
b2cb507
Compare
* Fix eventmapping implementation for statsd module. (cherry picked from commit adcd4b0)
* Fix eventmapping implementation for statsd module.
Proposed commit message
The root cause of the problem is the implementation of the event mapping method.
The data periodically sent by Airflow is not limited to a single DAG; it can encompass information from all currently running DAGs. This collective data is gathered into a group and subsequently processed to generate an event. The issue was traced back to a for loop used to iterate through all the key-value pairs within this group to create a single event. Because the data originates from multiple DAGs, creating a single event resulted in the data from one DAG overwriting the data from another. This led to the chaotic mixing of metrics, causing the problem.
The new implementation matches the approach used in the statsd_exporter. Now, each key-value pair and its associated attributes are treated as individual events. As a result, each key-value pair is processed to create distinct events, with only the related fields present in each event. This modification effectively resolves the issue and offers greater flexibility when using controls and filters to generate visualizations for associated data.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Related issues
Screenshots