-
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 Azure Monitor support for multiple aggregation types #39204
Fix Azure Monitor support for multiple aggregation types #39204
Conversation
10dce20
to
ad70b05
Compare
Pinging @elastic/obs-ds-hosted-services (Team:obs-ds-hosted-services) |
}}, | ||
}}, | ||
Type: to.Ptr("Microsoft.Insights/metrics"), | ||
Unit: to.Ptr(armmonitor.MetricUnit("Count")), |
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.
Wondering if you first save the value of armmonitor.MetricUnit("Count") to a variable and reference here the variable will eliminate this lint error
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.
Oh, I think you're right.
@@ -43,7 +43,7 @@ func (client *MockService) GetMetricNamespaces(resourceId string) (armmonitor.Me | |||
|
|||
// GetMetricValues is a mock function for the azure service | |||
func (client *MockService) GetMetricValues(resourceId string, namespace string, timegrain string, timespan string, metricNames []string, aggregations string, filter string) ([]armmonitor.Metric, string, error) { | |||
args := client.Called(resourceId, namespace) | |||
args := client.Called(resourceId, namespace, timegrain, timespan, metricNames, aggregations, filter) |
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.
You can just add some description what each parameter is here used for
Maybe you can update the GetMetricValues description
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.
Yeah, good point. I'm updating the GetMetricValues description in the interface.
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 noticed there is an unused method in the interface. I'll update the docs for the other methods and remove the unused ones in a cleanup PR.
LGTM and the tests run successfully on myside |
The MetricRegistry wasn't using the aggregation type in the cache key, returning the wrong answer to the 'needs update?' question.
Restores support for multiple aggregation types for the same metric name. Adding tests for the known use cases, so we don't miss this feature again in future updates.
I was checking the wrong response values.
7f48328
to
7cc4f44
Compare
7cc4f44
to
2dadc87
Compare
* Add aggregation type to the MetricRegistry key The MetricRegistry wasn't using the aggregation type in the cache key, returning the wrong answer to the 'needs update?' question. * Handle multiple aggregation types Restores support for multiple aggregation types for the same metric name. Adding tests for the known use cases so we don't miss this feature again in future updates. (cherry picked from commit 81fc73e)
* Add aggregation type to the MetricRegistry key The MetricRegistry wasn't using the aggregation type in the cache key, returning the wrong answer to the 'needs update?' question. * Handle multiple aggregation types Restores support for multiple aggregation types for the same metric name. Adding tests for the known use cases so we don't miss this feature again in future updates. (cherry picked from commit 81fc73e)
…9280) * Add aggregation type to the MetricRegistry key The MetricRegistry wasn't using the aggregation type in the cache key, returning the wrong answer to the 'needs update?' question. * Handle multiple aggregation types Restores support for multiple aggregation types for the same metric name. Adding tests for the known use cases so we don't miss this feature again in future updates. (cherry picked from commit 81fc73e) Co-authored-by: Maurizio Branca <maurizio.branca@elastic.co>
…ation types (#39279) * Fix Azure Monitor support for multiple aggregation types (#39204) * Add aggregation type to the MetricRegistry key The MetricRegistry wasn't using the aggregation type in the cache key, returning the wrong answer to the 'needs update?' question. * Handle multiple aggregation types Restores support for multiple aggregation types for the same metric name. Adding tests for the known use cases so we don't miss this feature again in future updates. (cherry picked from commit 81fc73e) * Remove extra changelog entries --------- Co-authored-by: Maurizio Branca <maurizio.branca@elastic.co>
Proposed commit message
Fixes two bugs related to supporting multiple aggregation types.
MetricRegistry
in the cache key.KeyValuePoint
for each aggregation type(1) Use aggregation type in
MetricRegistry
in the cache keyThe
MetricRegistry.NeedsUpdate
checks if a metric definition needs an update. If there are multiple metrics config with no dimensions:All three metric configs end up having the same key, ending up skipping the metric collection for the second and third configs.
By adding the aggregation type in the cache key, we can correctly keep track of metric updates.
(2) Create one
KeyValuePoint
for each aggregation typeAdd support for multiple aggregation types in the
mapToKeyValuePoints()
function to restore support for configs like the following:I missed this feature in a previous change. Unfortunately, no existing modules or integrations use multiple aggregation types, and no tests exist.
We are adding more tests targeting to cover all existing use cases soon.
Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
How to test this PR locally
Related issues
Use cases
The PR must support multiple aggregation types in two different variants:
Here are two variants of the metric
ActiveConnections
with three aggregation types:Maximum
,Minimum
, andAvergate
:This variant should be preferred since in needs less API calls to fetch the same data:
Screenshots
Logs