I have a JSON file and I would like to visualize in Bar Chart format the content of the column called “severity”. I would like to shown number of “major” and number of 'info". How do I do that? I can read the json file into grafana and display it in tabular form as shown below but don’t know how to extract the information from severity column. I have tried reading the file using Gitlab-Infinity-Prod and also Json data sources and tried to format the data but still can’t display the bar chart. Appreciate any help.
Can you share your JSON file here? If it contains sensitive info, you can put dummy data in there.
Hi, please see attached json file. Thanks.
lint_run_report2.json (2.8 KB)
Using an abbreviated dataset,
{
"major": $count($filter($, function($v) { $v.severity = "major" })),
"info": $count($filter($, function($v) { $v.severity = "info" }))
}
gives this:
{
"major": 5,
"info": 7
}
https://try.jsonata.org/tCAjMETqp
and here is a dashboard on Play that maybe @yosiasz or someone else can help put the above into UQL.
Thanks but I need a clarification because I’m new to Grafana. How did you come up with the new dataset? Do I need to write a script like you are showing to extract the information from the original json file? If so do I do it inside Grafana or outside of it? I was under the impression that I can create a transformation inside Grafana to parse the column and extract the counts of major and info and display them.
There are usually 6 different ways to accomplish the same thing, and your idea of using the Backend Parser with multiple Grafana transformations may indeed work fine.
I went the jsonata route because I find it easier (at least sometimes) to sort/parse/exclude/etc. the data using jsonata expressions.
Thanks
Just add double quotes on everything after jsonata and use single quotes on the inner values
| jsonata " 'food':$count"