Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upMechanism Search based on new label created through label_join function #5097
Comments
This comment has been minimized.
This comment has been minimized.
|
You can do that on the first_name and last_name independently. |
This comment has been minimized.
This comment has been minimized.
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:
it will give Multiple Series Error" because for first_name template variable it creates combination with each value of last_name.
for first_name ="Glen " the output becomes
and for first_name ="Royal" the output becomes
I hope I have clarified, Why I want to match on combine label created through label_join. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
xenthik commentedJan 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
Version 2.2.1