Hi.
I am trying to create a bar gauge dashboard with data coming from a PostGreSQL DB.
The goal is to show how long takes some operation with a tool.
I am able to show the total time as below:
But my goal would be to have something which also shows each steps (request, queue, start, …) in the same bar.
Something which would look like this:
(this is based on a screenshot I did, and just added the info about what I am trying to achieve, based on the following example:
Grafana)
Currently, I just have a very simple query:
SELECT id, sum(duration) as duration /*, eventtype*/ FROM monitoring WHERE $__timeFilter(timestamp)
GROUP BY id;
Where eventtype are the different steps (queue, dequeue, …)
Version of Grafana is: 9.2.5
Thanks!
You are summing your duration to get a total, you would need to select the individual steps, and then you can stack those using the bar chart, similar to the below.
SELECT id, request/, queue/, start/, eventtype/ FROM monitoring WHERE $__timeFilter(timestamp)
GROUP BY id;
I have tried to create a query to get the info I need, and looks like that the table I get is correct, but I still am still not able to visualize the data as I expect…
Here is the new query:
SELECT
id,
MAX(CASE WHEN eventtype = 'request' THEN duration ELSE NULL END) AS request,
MAX(CASE WHEN eventtype = 'enqueue' THEN duration ELSE NULL END) AS enqueue,
MAX(CASE WHEN eventtype = 'dequeue' THEN duration ELSE NULL END) AS dequeue,
MAX(CASE WHEN eventtype = 'start' THEN duration ELSE NULL END) AS start,
MAX(CASE WHEN eventtype = 'success' THEN duration ELSE NULL END) AS success
FROM monitoring
GROUP BY id;
Here is an example of the output table:
id |
request |
enqueue |
dequeue |
start |
success |
398add16-8247-494c-af6e-d391a4656855 |
0 |
9486 |
919470 |
919516 |
3120592 |
But I am still not able to get the data as I expected… I tried to change the options of the dashboard, but it is still not working. Or maybe the format of my data is wrong?
The data are already numeric. Anyway I have tested your suggestion, but it still does not work
That is the result I got when I run my query.
I suppose I may have missed an option somewhere…
you cannot stack on a bar gauge, you can only stack on a bar chart…
Oh crap, I missed that info… it works now!
Thanks
1 Like