I am using Promtail to ship data to Loki, which I then visualize in Grafana. I have a JSON file that is recreated every minute with a format like:
{
"Date": "2023-10-23T11:43:57.0096488+02:00",
"Standort": {
"GeraeteNr": "01",
"PLZ": "48653",
"Ort": "Coesfeld",
"Strasse": "Boschstraße 14"
},
"Errors": [
{
"Key1": "value1"
},
{
"Key2": "value2"
}
]
}
My scrape config looks like this:
scrape_configs:
- job_name: mrs_error_list
static_configs:
- targets:
- localhost
labels:
job: mrs_error_list
system: mrs2-14
__path__: /var/lib/mrs/data/log/mrs-state.json
pipeline_stages:
- multiline:
firstline: '^\{'
max_wait_time: 3s
I want to create a simple Grafana dashboard table displaying the error messages on the left side and the corresponding system on the right side. The challenge is accessing the specific entries of the Errors array and filtering based on them. The keys and values within the Errors array don't have a distinct pattern to filter upon, except that we know the errors are in the Errors array.
I tried the following query in Grafana:
{job="test_6", system="mrs2-14"} | json | line_format `{{.log}}`
However, with this, each array entry becomes a label, making it impossible to distinguish if the original labels come from the Errors array or not
Expected Outcome: I want a solution or method to directly access and filter entries of the Errors array and display them in Grafana alongside the system label.