Reputation: 3862
So we are using Loki/Grafana to collect logs from our Kubernetes cluster, and the tool is great for that. But now that I have cleaned up the logs, I would also like to visualize them!
Selecting only JSON lines
# My query
{namespace="default",pod=~"kkds-dockerscanner-test.+"} |= "SchemaVersion" | json
I select only two columns that I want to display in a table
{namespace="default",pod=~"kkds-dockerscanner-test.+"} |= "SchemaVersion" | json | line_format "{{.ArtifactName}} {{.Metadata_OS_Family}}"
Now I want to show the results in a table, but Grafana doesn't quite show the table I want. I want to show the output of my query in a table, and not just my output as a string in a column. Do you have any suggestions how to make this work, or can you point to a tutorial?
Upvotes: 10
Views: 22916
Reputation: 3862
As suggested by @Witt, it is possible to transform the JSON by applying a transformation.
If I choose the Transform pane and extract fields, I now get the JSON keys as columns in the Table view.
Under your datasource, you can also add the columns using Derived Fields and Regex. This, however, is a bit more cumbersome.
Upvotes: 9