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

Mechanism Search based on new label created through label_join function #5097

Open
xenthik opened this Issue Jan 15, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@xenthik
Copy link

xenthik commented Jan 15, 2019

Proposal

As you already know using label_join() and label_replace() function can be used to add new label dynamically. But there is way by to do matching/search on top of this newly added label. So this new label is useless if it can't be used as other label.

What did you do?

for example, A new label "full_name" is created by using existing two labels first_name and last_name in the following query.

label_join(sum(app:healthcheck:gauge{application="collectHealthies"} != bool 200) by (first_name, last_name), "full_name", " ", "first_name", "last_name")

let's say the output is:

{first_name="Jack",full_name="Jack daniels",last_name="daniels"} 10
{first_name="Glen",full_name="Glen fiddich",last_name="fiddich"} 0
{first_name="Royal",full_name="Royal stag",last_name="stag"} 3

There is no mechanism to search based on new label i.e. full_name.

label_join(sum(app:healthcheck:gauge{application="collectHealthies", full_name="Glen fiddich"} != bool 200) by (first_name, last_name), "full_name", " ", "first_name", "last_name")

returns nothing.

What did you expect to see?

{first_name="Glen",full_name="Glen fiddich",last_name="fiddich"} 0

Use case. here full_name is use less kind of label, for instance: In Grafana this new variable can be used to create template variable, and this template variable can be used with repeat panel functionality to populate single stat graph. but this is possible if this new label can be use to match the template variable

  • Prometheus version:
    Version 2.2.1
@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jan 15, 2019

You can do that on the first_name and last_name independently.

@xenthik

This comment has been minimized.

Copy link
Author

xenthik commented Jan 16, 2019

You can do that on the first_name and last_name independently.

No, When first_name and last_name independently used independently, it's giving Cartesian product.

let me explain:

I am trying plot a single stat graph using repeat functionality based on "full name" name as template variable. So in this case there should be 3 panel will be created. 1. Jack daniels 2. Glen fiddich and 3. Royal stag.

but if first_name and last_name used independently as template variable and supply these into panel query like:

sum(app:healthcheck:gauge{application="collectHealthies",first_name=~"$first_name",last_name=~"$las_name"}

it will give Multiple Series Error" because

for first_name template variable it creates combination with each value of last_name.
i.e. first_name="Jack", output becomes

  1. Jack daniels=10 2. Jack fiddich=null 3. Jack stag=null

for first_name ="Glen " the output becomes

  1. Glen daniels=null 5. Glen fiddich=0 6. Glen stag=null

and for first_name ="Royal" the output becomes

  1. Royaldaniels=null 8. Royal fiddich=null 9. Royal stag=3

I hope I have clarified, Why I want to match on combine label created through label_join.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jan 16, 2019

This sounds more like a Grafana usage question than a PromQL feature request. Keep in mind that template variables in Grafana don't have to be a single label value.

@xenthik

This comment has been minimized.

Copy link
Author

xenthik commented Jan 16, 2019

I don't feel so, The above criteria is just any example.

it as basic expected functionality, In other RDBMS databases , if you project data by creating custom col, or by using inline query or group by operator there is provision either by where clause or having clause to filter the output.

What is benefit of having label_join, if you can't use or manipulate it's outcome.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jan 16, 2019

You usually don't manipulate labels, you treat them as opaque strings that are used for matching. The canonical use case for label_join is when a hostname and port number are in separate labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.