0

I am trying to curl a query from my client that has data, but it seems the query i am sending doesn't seem to be correct. I want to get the number of commits that two projects have over a span of a year, but when I am adding the two I am getting a 422 error

error when executing query

Here's the query:

curl 'https://my_client/api/v1/query_range' -d 'query=sum(commits{development="no",id="123"}[4w])+sum(commits{development="no", project_id="456"}[4w])' -d 'start=-1y' -d 'step=4w' | json_pp

To do a sanity check, I had checked each project seperatly to see if I pull any data and I do, so my question is how would I add these two queries. Thanks

  • I think your separate queries e.g. `sum(commits{development="no",id="123"}[4w])` will not work because `sum` does not support the range vector returned by `commits{development="no",id="123"}[4w]`. You likely want to `sum_over_time` to total these range vectors. – DazWilkin Feb 09 '23 at 19:10
  • PromQL math operators e.g. `+` add metrics with matching (!) labels and it's unclear whether your metrics' labels match with `id="123"` and `project_id="456"`, presumably (otherwise why query like this) they don't. You could use PromQL `ignoring` keyword to drop labels that don't match between these two measurements. Or you could `sum without(...) (sum_over_time(...))` to aggregate matching sets of labels. Or you could use `group_left` or `group_right`. Without more information, it's not possible to say which. – DazWilkin Feb 09 '23 at 19:17
  • I had to use ascii encoding to add them up so I had to use %2B instead of "+" – Max Bojorquez Feb 09 '23 at 22:14

0 Answers0