MetricsQueryClient giving different results with different timespans

Ben 0 Reputation points
2024-10-21T18:19:43.98+00:00

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? 

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
{count} votes

1 answer

Sort by: Most helpful
  1. RevelinoB 3,685 Reputation points
    2024-10-21T18:47:40.9133333+00:00

    Hi Ben,

    This is likely due to a delay in Azure’s metric aggregation for recent data. When querying for a smaller, more recent window, the data is near real-time. But when you query for a longer period, such as an entire month, today's data may not have fully propagated or been processed yet, so it doesn’t appear in the results. To work around this, it’s a good idea to split the queries: use a smaller time range to get recent data and a larger range for older data. That way, you can ensure you're capturing today's usage accurately.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.