How to create bar chart grouped by hour with Loki as data source?

Hi,

We have logs in Loki. We would like to create bar chart with the occurrence of some specified keyword found grouped by hour.

For example:
X-Axis defining hour interval: 7AM-8AM, 8AM-9AM, 9AM-10AM, 10AM-11AM…
Y-Axis defining count: Occurrence of specified keyword

For example 7AM-8AM has count = 9, 8AM-9AM has count = 10…

How can we achieve this in Grafana Dashboard with Loki as Data Source?

A sample bar chart per hour:

First you need to parse the Loki data so that you have all the required labels and values.
Then you can use the “Extract fields” transformation with labels as the source. (Replace all fields)
Now you have a normal table that you can work with.

Jo