Postgresql – Create histograms in Grafana with alphabetical values as x-axis

dashboardgrafanahistogramkibanapostgresql

I need to create a dashboard to be used in a control room, where a bunch of operators will need to monitor the number of tasks assigned to other employees (among other aspects).

Source data will be coming from a RDBMs (PostgreSQL, in this case). We have people with assigned and numbered tasks that also have a status, and the DB data is like this (purely fictional: but it resembles the real one)

Example of data

Having to create and mantain a dashboard i was thinking to use tools like Grafana, Kibana or similars, to plot something like this

enter image description here

The problem is that Grafana, for example, doesn't let me use alphabetical values for the x-axis. It only allow numeric values, while i've names to plot (Mark, Luke, Brian).

Is there a best practice than i can follow? Am i trying to use the wrong tools?

Best Answer

Actually solution is easier then you think although it also took me some time to figure it out. I will place here an example for some unspecified shop data grouped over countries - you just need to change it for your task. Example was tested on Grafana 5.0.3

  1. PostgreSQL query for metrics
SELECT
  $__time( partition_date ),
  country as metric,
  sum(value) as value
FROM
  aggregations.my_data_for_dashboard
WHERE
  shop = 'myshopname' AND 
  $__timeFilter(partition_date )
group by 1, 2

Grafana will show usual metrics: enter image description here

  1. In "Axes" tab look at "X-Axis" section, item "Mode" - switch "Time" to "Series" and Grafana will show bar chart for countries.

enter image description here

Related Topic