Forum Discussion
MetricsQueryClient returning different results based on timespan
I'm using the Python MetricsQueryClient to list out how many tokens were used on certain days via the APIM policy "azure-openai-emit-token-metric". The problem is that when I call the query_resource() function with "timespan" set for the entire month of October, I get different results for token count usage for today's date than when I set the "timespan" to just the last 48 hours. For example, when setting the timespan to be from 10/20/2024 to 10/22/2024, I see 34 prompt tokens for today's date. But if I set the timespan to be 10/1/24 to 11/1/24, I see 0 prompt tokens for today's date.
Is this a known issue? It is documented somewhere?
1 Reply
This is a known quirk of Azure Monitor’s metrics ingestion and aggregation, not a coding error on your side. If you need reliable daily counts, stick to smaller timespan windows or add a delay before querying month‑wide ranges.
MetricsQueryClient returns empty results · Issue #30903 · Azure/azure-sdk-for-net