prometheus-adapter icon indicating copy to clipboard operation
prometheus-adapter copied to clipboard

Is there a way to define default for a metric by default if not present

Open varunvijayagopal opened this issue 1 year ago • 4 comments

We use istio_requests_total for scaling . However this metric comes into picture only when we try to hit endpoint of service . /stats/proemetheus endpoint doesn't give this metric by default . Since we use this hpa , it comes as UNKNOWN till that service is accessed . I tried to add vector(0) so that if not present it gives a counter of 0 and this works fine on prometheus but still prometheus adapter complains with 404

Below is the query which we ar esuing

seriesQuery: istio_requests_total{destination_service_name!="",reporter="destination", destination_workload_namespace!=""} resources: overrides: destination_service_name: { resource: "service" } destination_workload_namespace: { resource: "namespace" } name: matches: "^(.*)_total" as: "${1}_per_second" metricsQuery: 'sum(rate(<<.Series>>{reporter="destination", <<.LabelMatchers>>}[1m]) or vector(0)) by (<<.GroupBy>>)'

varunvijayagopal avatar May 19 '23 08:05 varunvijayagopal

/kind support /triage accepted /assign

dgrisonnet avatar Jun 29 '23 16:06 dgrisonnet

I'm interested in this, have you found a workaround?

huguesgr avatar Dec 04 '23 18:12 huguesgr

I don't think this was ever fixed

dgrisonnet avatar Dec 06 '23 09:12 dgrisonnet

I found something that works in my use-case:

metricsQuery: <<.Series>>{<<.LabelMatchers>>} or clamp_max(absent(<<.Series>>{<<.LabelMatchers>>}),0)

huguesgr avatar Dec 06 '23 20:12 huguesgr