I am trying to create a dashboard (in Grafana 7.3.5 with a Loki data source) that counts the occurrence of a specific log message pattern per day. I have got a table of all the relevant Timestamps (seen below) but can not figure out how to reduce the time from a YYYY-MM-dd hh-mm-ss format to a YYYY-MM-dd format.
So far I have a query which selects the pattern: {namespace="relevantNamespace"} |= "pattern"
and have “grouped by” the Time which counts the occurrences (as all timestamps are unique it is always 1).
Does anyone know how I can group the messages which are from the same day?
I have found some similar questions on the internet but none seems to work with the newer Grafana version.
is it possible to downgrade then ? grafana is also good in older versions.
Hello and thank you for the answer. I am running Grafana in the cloud based on an existing chart. So downgrading is not an option.
hello can you switch from cloud base to standalone ?
Not really as the purpose of the Grafana is to visualize resources in a Kubernetes cluster. These resources are collected by Prometheus and Loki and send on to Grafana.
I have the same question. How can I group by day instead of each individual timestamp?
Did you end up finding out ? Looking at doing the same thing right now.
What is your datasource
After a bit more attempts and using a timeseries visualization instead of a table, it eventually worked.
This is my query, if that’s of any interest for anyone.
sum by (customer) (count_over_time({product=“product_name”, customer=“customer_name”} |~ "msg":"/platform/api/.*"
[1d]))
But I wasn’t able to get the same result in a table (with one row per day).
Oh and my datasource is Loki.
try to group the data, but before you need to convert the field type (transformation).
after it you can group by the date with the format yyyy-mm-dd
Thanks. I think I tried the data transformation but it still showed the full time stamp. I’ll give that another try, maybe I messed up or something.
When you use the convert field type
Field date as Time you will see a input format, and here you can only show the yyyy-mm-dd .
After that you can group by the timestamp