Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to add statically defined Prometheus labels to queries #14

Open
yosefy opened this issue Jul 4, 2017 · 9 comments
Open

Support to add statically defined Prometheus labels to queries #14

yosefy opened this issue Jul 4, 2017 · 9 comments

Comments

@yosefy
Copy link

yosefy commented Jul 4, 2017

without injecting columns to query?
like

labels:
x: y
a: b

@haxorof
Copy link
Contributor

haxorof commented Jul 7, 2017

Hi @yosefy

Can you please give us a more complete example of what kind of feature you want to see in prometheus-sql.

Cheers!

@yosefy
Copy link
Author

yosefy commented Jul 8, 2017

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

@haxorof
Copy link
Contributor

haxorof commented Jul 8, 2017

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?

@yosefy
Copy link
Author

yosefy commented Jul 8, 2017

yes exactly.
thanks

@haxorof haxorof changed the title may be can add option to add labels in config Support to add statically defined Prometheus labels to queries Jul 8, 2017
@roidelapluie
Copy link
Contributor

FYI We do it like this:

SELECT "ford" as type, "green" as color, foobar FROM foobar

@roidelapluie
Copy link
Contributor

Depending on the DB you might need single quotes instead of double quotes

@roidelapluie
Copy link
Contributor

Would be great to have this fixed because even when fetching would fail we would have labels (metric_name{type="ford"} -1)

@roidelapluie
Copy link
Contributor

I am willing to work on this once #37 is merged.

@pschou
Copy link

pschou commented Nov 1, 2020

I've added documentation on how to do this in pull request #66

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants