Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Fix too many requests error. Add JSON logs. #11

Merged
merged 8 commits into from
Jan 24, 2022

Conversation

sfairat15
Copy link
Contributor

@sfairat15 sfairat15 commented Jan 21, 2022

Fixing issues #10 and #9.

Main change

According Microsoft documentation application may create only 30 API calls per minute.
After that threshold application will get Too Many Requests response from API.

Error code 429 - Call count has exceeded rate limits

To enable a consistent experience for all Cost Management subscribers, Cost Management APIs are rate limited. When you reach the limit, you receive the HTTP status code 429: Too many requests. The current throughput limits for our APIs are as follows:

30 calls per minute - It's done per scope, per user, or application.

200 calls per minute - It's done per tenant, per user, or application.

To avoid such errors, this exporter has background job to get data from API.
Received cost data placed in memory cache. Prometheus scriber calls on /metrics get data from cache and get quick response.

In case of Too Many Requests errors, background job waits 1 minute before next calls.

Also

  • Add logging in JSON format (use Serilog)
  • Use Dodo.HttpClientResiliencePolicies policy library for API calls

@sfairat15 sfairat15 changed the title Sre fix too many requests 3057414 Fix too many requests. Add JSON logs. Jan 21, 2022
@sfairat15 sfairat15 changed the title Fix too many requests. Add JSON logs. Fix too many requests error. Add JSON logs. Jan 21, 2022
@sfairat15 sfairat15 merged commit 341c020 into master Jan 24, 2022
@sfairat15 sfairat15 deleted the sre-fix-too-many-requests-3057414 branch January 24, 2022 06:51
@sfairat15 sfairat15 restored the sre-fix-too-many-requests-3057414 branch August 7, 2023 06:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants