Bar Gauge : How to show Series name from a query's row value (MySQL)?

I’ve got this query :

SELECT hostmacro.value as macro, count(hostmacro.value) as compte FROM zabbix.hostmacro group by hostmacro.value;

I want to use the first column’s row values of the query (macro) as the series’s names for my Bar Gauge and use the 2nd column values (compte) as the value for each series. Right now, i’m not getting the expected result :

If i switch to a table view, i can see the 2 columns like this :
image

Anyone knows how to do this or if it’s possible with the new panel?

Thanks!

type $__cell_0 in the Field title template

3 Likes

Ah yes, it works now. I was a bit confused with the tooltip, as i tought i had to enter $__cell_{0}

image

Thanks!

Hello! I cannot see that field in my query builder, could you please be so kind to post the full working query so I can edit my own? Thank you!

Same problem here. I am not using the query builder. “Field title template” - where??

Hello,
What must I add to my query to show series? Is it…

SELECT * , $__series.name{Bar1}, FROM table WHERE No=10

or

SELECT * , $__field.name{Bar1}, FROM table WHERE No=10

or what? Thkns…

Hi, here an exemple of query:

SELECT distinct(hostname) as hostname,count() as total FROM DB.Table
group by hostname order by count(
) desc

In the ‘Display’ tab on ‘Title’ field put : $__cell_0

It will make you bar title as the first field of your SQL query and the lenght of the bar will be the count(*)

Hi, i am trying to change the series name in a query very similar to this, but i cannot.
My query is like this:

SELECT sum(weight) FROM gitlab_issues where $timeFilter group by project

It works fine, but on the series title in the bar gauge it displays “gitlab_issues.sum {project: HR}”, when I would like it to show only the tag values, in this case “HR”, or at least removing the “gitlab_issues.sum” part.

Thanks.

Have you tried SELECT sum(weight) as HR FROM… ?

Antony.

Hi Torkel,

The other options as of _series_name and _field_name don’t appear to work. Am I missing something?

Thanks

Could you share other configuration settings? I run very similar query with two columns returned, but for some reason gauge indicator shows each colum/row combination as separate gauge.

I have set “Title” field to $__cell_0

If I display same query as table, it shows 5 rows as expected:

Thanks!



this is my query
select
sum(if(dik.ID = ‘1’ , dik.value, 0)) as ‘_a1’,
sum(if(dik.ID = ‘2’ , dik.value, 0)) as ‘_a2’,
sum(if(dik.ID = ‘3’ , dik.value, 0)) as ‘_a3’,
sum(if(dik.ID = ‘4’ , dik.value, 0)) as ‘_a4’,
sum(if(dik.ID = ‘5’ , dik.value, 0)) as ‘_a5’,
sum(if(dik.ID = ‘6’ , dik.value, 0)) as ‘_a6’,
sum(if(dik.ID = ‘7’ , dik.value, 0)) as ‘_a7’

from
(SELECT
__timeGroup(Start,'5m',0) as "time", sum(VehicleActivities) as value, ID FROM request_info WHERE __timeFilter(Start)
GROUP BY ID
ORDER BY Start) as dik

I get same to all bars in bar gauge.
Somebody can help

Using this macros could help us on the group by month?