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
Extend Metrics Transform to be able to add a label to an existing metric #441
Conversation
cc @JingboWangGoogle as a fyi |
Codecov Report
@@ Coverage Diff @@
## master #441 +/- ##
==========================================
+ Coverage 84.71% 84.74% +0.02%
==========================================
Files 174 174
Lines 9389 9404 +15
==========================================
+ Hits 7954 7969 +15
Misses 1113 1113
Partials 322 322
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
It seems like this operation is simply adding a label into the labelKeys list in the selected metric's descriptor. So how about the label values in the timeseries, do all timeseries just have an empty value for that label? I might be missing something, but some clarification on this would be great.
@@ -80,7 +83,8 @@ type Operation struct { | |||
// AggregatedValues is a list of label values to aggregate away. | |||
AggregatedValues []string `mapstructure:"aggregated_values"` | |||
|
|||
// NewValue indicates what is the value called when the AggregatedValues are aggregated into one. | |||
// NewValue indicates what is the value called when the AggregatedValues | |||
// are aggregated into one or a new label is added to an existing metric. | |||
NewValue string `mapstructure:"new_value"` |
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.
The NewValue
field here used to mean the new label value for the label values being aggregated together, but it seems like in this action add_label
, this field means the description for the new label. Please correct me if I am wrong, but this seems like a pretty big difference for this one field in two different actions. Maybe consider having a new field called newDescription
or something?
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.
Side note: we probably need to break this struct up for different operation types at some point.
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.
This is just an error in setting the label values at the metric descriptor and not at the time series. Since the intent of hte pr is to update the label values they have the same goal (either in add a new label or when it gets aggregated). To make it cleared, i'll update the comment to say
// NewValue is used to set a new label value either when the operation is `AggregatedValues` or `AddLabel`.
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.
I have a similar question to Jingbo. Each data point in the metric will have a set of labels - presumably you would you want to add the label with the same value to each data point?
} | ||
if op.Action == AddLabel && op.NewValue == "" { | ||
return fmt.Errorf("missing required field %q while %q is %v in the %vth operation", NewValueFieldName, ActionFieldName, AddLabel, i) | ||
} |
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.
^ Duplicated
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.
Not quite duplicated but I can condense it to say that both NewLabel/NewValue are required. It would make the error message less precise as it won't say what is missing.
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.
My bad 🤦♂️
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.
No worries :)
@@ -80,7 +83,8 @@ type Operation struct { | |||
// AggregatedValues is a list of label values to aggregate away. | |||
AggregatedValues []string `mapstructure:"aggregated_values"` | |||
|
|||
// NewValue indicates what is the value called when the AggregatedValues are aggregated into one. | |||
// NewValue indicates what is the value called when the AggregatedValues | |||
// are aggregated into one or a new label is added to an existing metric. | |||
NewValue string `mapstructure:"new_value"` |
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.
Side note: we probably need to break this struct up for different operation types at some point.
That is good point. It should be for the time series labels. That reminds me the latest spec for metrics doesn't have labels on MetricDescriptors. The ascii art here is outdated but the message definition for Descriptor is up to date.. I'll also post this to the open pr for the metrics transform processor. I'll update the pr to reflect updating the timeseries labels and not the metric descriptors. Thank you for the catch |
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
operations: | ||
- action: add_label | ||
new_label: mylabel | ||
new_value: myvalue |
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.
Would be good to add this to config_test.go
as well
… append (#441) Co-authored-by: Rahul Patel <rghetia@yahoo.com>
Description: The current metrics transformation processor is extended to support adding a label to an existing metric.
The configuration is.
Link to tracking Issue: N/A
Testing: Added tests to cover configuration requirements and the logic around adding a label.
Documentation: Readme has been updated.