Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upUsing a query that returns "no data points found" in an expression #2389
Comments
This comment has been minimized.
This comment has been minimized.
|
It's recommended not to expose data in this way, partially for this reason. Separate metrics for total and failure will work as expected. |
brian-brazil
added
the
kind/question
label
Feb 1, 2017
This comment has been minimized.
This comment has been minimized.
|
Good to know, thanks for the quick response! |
rich-youngkin
closed this
Feb 2, 2017
This comment has been minimized.
This comment has been minimized.
|
Finally getting back to this. I made the changes per the recommendation (as I understood it) and defined separate success and fail metrics. A simple request for the count (e.g., rio_dashorigin_memsql_request_fail_duration_millis_count) returns no datapoints). So I still can't use that metric in calculations ( e.g., success / (success + fail) ) as those calculations will return no datapoints. So it seems like I'm back to square one. Here's the full expression:
Perhaps I misunderstood, but it looks like any defined metrics that hasn't yet recorded any values can be used in a larger expression. I.e., there's no way to coerce no datapoints to 0 (zero)? |
rich-youngkin
reopened this
Mar 2, 2017
This comment has been minimized.
This comment has been minimized.
|
The idea is that if done as @brian-brazil mentioned, there would always be a fail and success metric, because they are not distinguished by a label, but always are exposed. Are you not exposing the fail metric when there hasn't been a failure yet? Or do you have some other label on it, so that the metric still only gets exposed when you record the first failued request it? |
This comment has been minimized.
This comment has been minimized.
|
I'm not sure what you mean by exposing a metric. I am always registering the metric as defined (in the Go client library) by To your second question regarding whether I have some other label on it, the answer is yes I do. So perhaps the behavior I'm running into applies to any metric with a label, whereas a metric without any labels would behave as @brian-brazil indicated? |
This comment has been minimized.
This comment has been minimized.
|
@rich-youngkin Yes, the general problem is non-existent series. When you add dimensionality (via labels to a metric), you either have to pre-initialize all the possible label combinations, which is not always possible, or live with missing metrics (then your PromQL computations become more cumbersome). This is one argument for not overusing labels, but often it cannot be avoided. One thing you could do though to ensure at least the existence of failure series for the same series which have had successes, you could just reference the failure metric in the same code path without actually incrementing it, like so:
That way, the counter for that label value will get created and initialized to 0. |
This comment has been minimized.
This comment has been minimized.
|
@juliusv Thanks for clarifying that. This makes a bit more sense with your explanation. Is what you did above ( |
This comment has been minimized.
This comment has been minimized.
|
@rich-youngkin Yeah, what I originally meant with "exposing" a metric is whether it appears in your /metrics endpoint at all (for a given set of labels). The thing with a metric vector (a metric which has dimensions) is that only the series for it actually get exposed on /metrics which have been explicitly initialized. This is in contrast to a metric without any dimensions, which always gets exposed as exactly one present series and is initialized to 0. |
This comment has been minimized.
This comment has been minimized.
|
Nice, thanks again for clarifying. |
rich-youngkin
closed this
Mar 3, 2017
This comment has been minimized.
This comment has been minimized.
|
Hmmm, upon further reflection, I'm wondering if this will throw the metrics off. For example, I'm using the metric to record durations for quantile reporting. Will this approach record 0 durations on every success?
If so it seems like this will skew the results of the query (e.g., quantiles). Is that correct? If so I'll need to figure out a way to pre-initialize the metric which may be difficult since the label values may not be known a priori. |
rich-youngkin
reopened this
Mar 3, 2017
This comment has been minimized.
This comment has been minimized.
|
No, only calling |
This comment has been minimized.
This comment has been minimized.
|
perfect, thanks again. |
grobie
closed this
Mar 5, 2017
This was referenced Jun 21, 2017
This comment has been minimized.
This comment has been minimized.
lock
bot
commented
Mar 23, 2019
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
rich-youngkin commentedFeb 1, 2017
I've created an expression that is intended to display percent-success for a given metric.
This works fine when there are data points for all queries in the expression. However when one of the expressions returns no data points found the result of the entire expression is no data points found. In my case there haven't been any failures so
rio_dashorigin_serve_manifest_duration_millis_count{Success="Failed"}returns no data points found. Is there a way to write the query so that a default value can be used if there are no data points - e.g., 0.Thanks,
Rich