prometheus-sql
prometheus-sql copied to clipboard
Support to add statically defined Prometheus labels to queries
without injecting columns to query? like
labels: x: y a: b
Hi @yosefy
Can you please give us a more complete example of what kind of feature you want to see in prometheus-sql.
Cheers!
say we have a query that will give us amount of cars of type ford and they all green but query doesn"t have color column and type is called "__Type" (and i want "type" but i don"t want to touch the query as i have 50 of them in different shapes) so i dont want to use the column name (may be i do and may be i don"t) so i want to just manually add labels:
labels: type: ford color: green
just another yaml part for adding more labels to result then columns it has i hope i explained better :)
thanks
If I understood you correctly here then the end result in the metric endpoint would have to additional labels "type" and "color" which does not actually come from the SQL query itself, just added on afterwards.
@yosefy: Is this correctly understood?
yes exactly. thanks
FYI We do it like this:
SELECT "ford" as type, "green" as color, foobar FROM foobar
Depending on the DB you might need single quotes instead of double quotes
Would be great to have this fixed because even when fetching would fail we would have labels (metric_name{type="ford"} -1)
I am willing to work on this once #37 is merged.
I've added documentation on how to do this in pull request #66