Ok, you clarifying,
But,
How to make this querys in the same request?
*query = {__name__=~"a100_001_FT_DACA_PV|a101_401_0_PIC_PIDA_PV"}*
*and*
*query = avg_over_time(E002_C04_kW[1h])/1000 *
Em terça-feira, 9 de novembro de 2021 às 09:22:29 UTC-3, Brian Candler
escreveu:
> On Tuesday, 9 November 2021 at 11:33:00 UTC [email protected] wrote:
>
>> How to make an request with function in HTTP API ?
>>
>
> The HTTP API is documented here:
> https://prometheus.io/docs/prometheus/latest/querying/api/
> You're using it correctly, but your query is bad.
>
> This query, dont return this metric using function of avg_over_time,
>>
>
> First get your query working in the PromQL browser in the web interface,
> before sending it to the API.
>
> Your query doesn't do what you think it does, in fact it's a pretty
> meaningless query. Your query is:
>
>
> *{__name__=~"a100_001_FT_DACA_PV|a101_401_0_PIC_PIDA_PV|avg_over_time(E002_C04_kW)"}*
>
> What you are doing is matching the timeseries name (which is in an
> internal label __name__) against one regular expression. So what this
> query means is:
>
> *Return every timeseries whose name is either "a100_001_FT_DACA_PV" or
> "a101_401_0_PIC_PIDA_PV" or "avg_over_timeE002_C04_kW"*
>
> (The vertical bar in a regular expression gives alternatives. Parentheses
> also have special meanings in a regular expression, so a(b) matches "ab")
>
> And that's exactly what your result shows:
> - one timeseries with name "a100_001_FT_DACA_PV"
> - one timeseries with name "a101_401_0_PIC_PIDA_P"
> - no timeseries matching name "avg_over_timeE002_C04_kW"
>
> If you want to use average_over_time then you'll need to invest some time
> learning promQL. This is a function, and it applies to a range vector not
> an instance vector. For example,
>
> average_over_time(a100_001_FT_DACA_PV[2h])
>
> is a valid query: a100_001_FT_DACA_PV[2h] is a range vector, i.e. it
> returns all timeseries with that name, and all data covering a 2 hour
> period. average_over_time(...) gives you an instant vector which averages
> all the data points within that time range for each matching timeseries.
>
> Here are some resources to start learning about promQL:
>
> * https://prometheus.io/docs/prometheus/latest/querying/basics/
> * https://github.com/infinityworks/prometheus-example-queries
> * https://timber.io/blog/promql-for-humans/
> * https://www.weave.works/blog/promql-queries-for-the-rest-of-us/
> *
> https://www.slideshare.net/weaveworks/promql-deep-dive-the-prometheus-query-language
> * https://medium.com/@valyala/promql-tutorial-for-beginners-9ab455142085
> * https://www.robustperception.io/common-query-patterns-in-promql
> * https://www.robustperception.io/booleans-logic-and-math
> *
> https://www.robustperception.io/composing-range-vector-functions-in-promql
> * https://www.robustperception.io/rate-then-sum-never-sum-then-rate
> *
> https://www.robustperception.io/using-group_left-to-calculate-label-proportions
> * https://www.robustperception.io/extracting-raw-samples-from-prometheus
> * https://www.robustperception.io/prometheus-query-results-as-csv/
> * https://www.robustperception.io/existential-issues-with-metrics
> * https://www.robustperception.io/left-joins-in-promql
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/0dc9765c-89b0-4197-b5a8-7ac2a3b8f621n%40googlegroups.com.