You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for query functions to custom_query_range #241
or does this support need to be added? I don't mind trying to add it if it needs it.
Whether get_metric_range_data should be updated to support this functionality, or users should use custom_query_range for such cases would be up for discussion imo /cc @4n4nd
or does this support need to be added? I don't mind trying to add it if it needs it.
Whether get_metric_range_data should be updated to support this functionality, or users should use custom_query_range for such cases would be up for discussion imo /cc @4n4nd
Yes, using custom_query_range was the workaround I used also. It isn't as confusing in hindsight, but it was initially, and it's interesting that I wasn't the only one with the issue. Thanks
Question: If I use metric_data = prom.get_metric_range_data(...) then I can use metric_object_list = MetricsList(metric_data) call. However, If I use metric_data = prom.custom_query_range(...) then the MetricsList() call fails with KeyError: '__name__'. I can fix this by running this loop before calling MetricsList().
for r in metric_data:
r['metric']["__name__"] = metric_name
Where metric_name is part of my query string.
Is this right? Or am I crossing the streams (so to speak).
Is this right? Or am I crossing the streams (so to speak).
This is the "right" way to do it since Prometheus doesn't return a metric name when you use functions. I wasn't sure if the library should add the query string as the name by default. wdyt @chauhankaranraj?
Is this right? Or am I crossing the streams (so to speak).
This is the "right" way to do it since Prometheus doesn't return a metric name when you use functions. I wasn't sure if the library should add the query string as the name by default. wdyt @chauhankaranraj?
I encountered same issue with query fuction when using custom_query_range(). Is it possible to add a parameter for custom_query_range() to specify the missing metric name ?
Is this right? Or am I crossing the streams (so to speak).
This is the "right" way to do it since Prometheus doesn't return a metric name when you use functions. I wasn't sure if the library should add the query string as the name by default. wdyt @chauhankaranraj?
Hm that's an interesting problem. Do we know if users tend to pass the return value of custom_query_range() to MetricsList()? If yes, and if that is one of the intended use cases of the MetricsList class, then I think we should make the query string as the name by default.
Activity
chauhankaranraj commentedon Jun 30, 2022
Hi @NoahZielke thanks for bringing this up! I believe you're right, I'm also unable to use query functions in
get_metric_range_datalike this:And yes, it's likely because of the way chunk size is implemented.
I was able to work around this problem by using
custom_query_rangeinstead like this:Does this work for your use case too?
Whether
get_metric_range_datashould be updated to support this functionality, or users should usecustom_query_rangefor such cases would be up for discussion imo /cc @4n4ndNoahZielke commentedon Jul 2, 2022
Yes, using
custom_query_rangewas the workaround I used also. It isn't as confusing in hindsight, but it was initially, and it's interesting that I wasn't the only one with the issue. Thanksmahtin commentedon Oct 30, 2022
Question: If I use
metric_data = prom.get_metric_range_data(...)then I can usemetric_object_list = MetricsList(metric_data)call. However, If I usemetric_data = prom.custom_query_range(...)then theMetricsList()call fails withKeyError: '__name__'. I can fix this by running this loop before callingMetricsList().Where
metric_nameis part of my query string.Is this right? Or am I crossing the streams (so to speak).
Thanks in advance
4n4nd commentedon Oct 31, 2022
This is the "right" way to do it since Prometheus doesn't return a metric name when you use functions. I wasn't sure if the library should add the query string as the name by default. wdyt @chauhankaranraj?
bdulive commentedon Dec 11, 2022
I encountered same issue with query fuction when using custom_query_range(). Is it possible to add a parameter for custom_query_range() to specify the missing metric name ?
chauhankaranraj commentedon Mar 31, 2023
Hm that's an interesting problem. Do we know if users tend to pass the return value of
custom_query_range()toMetricsList()? If yes, and if that is one of the intended use cases of theMetricsListclass, then I think we should make the query string as the name by default.