-
Notifications
You must be signed in to change notification settings - Fork 2.8k
receiver/azuremonitor - Added maximumResourcesPerBatch config #40752
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
base: main
Are you sure you want to change the base?
receiver/azuremonitor - Added maximumResourcesPerBatch config #40752
Conversation
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'm curious, would you be a user of that config field?
Because I mentioned in the issue the possibility to configure that by resource type. If this is something that could be interesting for you maybe you could implement it instead of a global field WDYT?
Also @andrewegel @ahurtaud I would like your opinion on that, since you are in the origins of that idea. #40078 (comment)
@@ -28,6 +28,7 @@ var ( | |||
errMissingClientSecret = errors.New(`"ClientSecret" is not specified in config`) | |||
errMissingFedTokenFile = errors.New(`"FederatedTokenFile" is not specified in config`) | |||
errInvalidCloud = errors.New(`"Cloud" is invalid`) | |||
errInvalidMaxResPerBatch = errors.New(`"MaximumResourcesPerBatch" is invalid`) |
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.
errInvalidMaxResPerBatch = errors.New(`"MaximumResourcesPerBatch" is invalid`) | |
errInvalidMaxResPerBatch = errors.New(`"MaximumResourcesPerBatch" is invalid. It should be between 1 and 50`) |
I think it is fine, even more that we dont have much configuration per "resource type". something like: receivers:
azuremonitor/default:
use_batch_api: true
maximum_resources_per_batch: 50
services:
- Microsoft.Compute/virtualMachines
- blahblah
azuremonitor/throttled:
use_batch_api: true
maximum_resources_per_batch: 10
services:
- Microsoft.Network/loadBalancers |
@@ -329,5 +333,9 @@ func (c Config) Validate() (err error) { | |||
err = multierr.Append(err, errInvalidCloud) | |||
} | |||
|
|||
if c.UseBatchAPI && c.MaximumResourcesPerBatch != 0 && (c.MaximumResourcesPerBatch > defaultMaximumResourcesPerBatch || c.MaximumResourcesPerBatch < 0) { |
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.
if c.UseBatchAPI && c.MaximumResourcesPerBatch != 0 && (c.MaximumResourcesPerBatch > defaultMaximumResourcesPerBatch || c.MaximumResourcesPerBatch < 0) { | |
if c.UseBatchAPI && c.MaximumResourcesPerBatch != 0 && (c.MaximumResourcesPerBatch > defaultMaximumResourcesPerBatch || c.MaximumResourcesPerBatch < 1) { |
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.
also I am not sure we want to reference defaultMaximumResourcesPerBatch
for the maximum test here. it works as long as we dont change the default. As its clearly stated in microsoft documentation, should we hardcode 50
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.
You mean enforce it here? and don't have the condition in the code later? I think it can be better yes
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 meant:
if c.UseBatchAPI && c.MaximumResourcesPerBatch != 0 && (c.MaximumResourcesPerBatch > defaultMaximumResourcesPerBatch || c.MaximumResourcesPerBatch < 0) { | |
if c.UseBatchAPI && c.MaximumResourcesPerBatch != 0 && (c.MaximumResourcesPerBatch > 50 || c.MaximumResourcesPerBatch < 1) { |
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'd prefer to have it named, otherwise it's magic number
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 yes I see it know, the default is actually to not set the field. Maybe that would make change my mind on the fact that we'd even error on that. Let's maybe let azure decide and so this will display error only if azure consider it as an 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.
@celian-garcia Do you want me to remove the config validation check altogether or just change it to hardcoded values?
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.
Sorry @suvaidkhan for that change of mind 🙏🏻 , but yes, please remove the config validation altogether. That will simplify the code and let Azure fail if needed.
Could you also just add that link in the README.md for reference? https://learn.microsoft.com/en-us/azure/azure-monitor/metrics/migrate-to-batch-api?tabs=individual-response . This is where the 50 is mentioned.
That's not written in a straightforward way in the REST API spec 😞 https://learn.microsoft.com/en-us/rest/api/monitor/metrics-batch/batch?view=rest-monitor-2023-10-01&tabs=HTTP
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.
@celian-garcia Sure that's not a problem! It does make more sense to have no validation now that I think more about it.
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.
@celian-garcia changes done, ready for review!
Having config by resource type is actually something that we do now, with split dimensions receivers:
azuremonitor:
dimensions:
enabled: true
overrides:
"Microsoft.Network/azureFirewalls":
# Real example of an Azure limitation here:
# Dimensions exposed are Reason, Status, Protocol,
# but when selecting Protocol in the filters, it returns nothing.
# Note here that the metric display name is ``Network rules hit count`` but it's programmatic value is ``NetworkRuleHit``
# Ref: https://learn.microsoft.com/en-us/azure/azure-monitor/reference/supported-metrics/microsoft-network-azurefirewalls-metrics
"NetworkRuleHit": [Reason, Status] With metrics aggregations specifications receivers:
azuremonitor:
resource_groups:
- ${resource_groups}
services:
- Microsoft.EventHub/namespaces
- Microsoft.AAD/DomainServices # scraper will fetch all metrics from this namespace since there are no limits under the "metrics" option
metrics:
"microsoft.eventhub/namespaces": # scraper will fetch only the metrics listed below:
IncomingMessages: [total] # metric IncomingMessages with aggregation "Total"
NamespaceCpuUsage: [*] # metric NamespaceCpuUsage with all known aggregations So to align in that direction, for consistency for users, it might be better to have it here as well. I don't know if it's shocking or not and in which measure this feature will be used. We are not so that's why I was asking to people that would use it ^^. But yeah, knowing that there is an easy solution and that the feature will probably used in limited conditions, let's not overthink and do it like you said @ahurtaud |
I've updated #40078 (comment) ; TL;DR: I don't think a
|
…ion-MaximumResourcesPerBatch' into receiver/azuremonitor-configuration-MaximumResourcesPerBatch
Thanks @andrewegel ! I answered directly in the issue. This is not incompatible IMHO. |
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.
Pretty neat! Looks completely good to me. I can't trigger the approval for workflow but I approve the code.
Correct not incompatible with this change, but I did go with a different route |
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 ready to merge. Thank you !
Description
Added a new config
maximum_resources_per_batch
with a default and max value of 50Link to tracking issue
Fixes #40112
Testing
Added UTs for config validation tests
Documentation
Added details about the config in
receiver/azuremonitorreceiver/README.md