RobustPerception / azure_metrics_exporter

Azure metrics exporter for Prometheus
Apache License 2.0
133 stars 70 forks source link

Expose remaining rate limit #38

Open carlpett opened 5 years ago

carlpett commented 5 years ago

The header x-ms-ratelimit-remaining-subscription-reads contains the remaining allowed read request quota, and would be use very useful. See https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-request-limits.

I'm happy to implement this, but would like some feedback on this approach:

Sounds reasonable?

There is a write quota header too, but it is only returned on writes, so to collect it we'd need to make some form of write and the service principal would need to be allowed to do so. I'd consider this out of scope initially. Main concern for us at least is reads.

brian-brazil commented 5 years ago

Another option would be storing the most recent value inside AzureClient.

This sounds useful.

carlpett commented 5 years ago

Yes, that is an even better idea! When going at this, should we additionally start respecting the Retry-After if we get a HTTP 429? And/or even proactively failing scrapes if the rate limit is getting close to depleted? That might be hard to do well, though, and would probably require a lot of flags for user tweakability.

brian-brazil commented 5 years ago

Let's get the data in first.

lukasmrtvy commented 5 years ago

@carlpett any progress on this? Or is it passé for You?

carlpett commented 5 years ago

@lukasmrtvy Sorry, I left the client where we used Azure before it could be finished. Hopefully someone with an Azure account could pick up the PR.