Hi Team,
I’m trying to monitor event logs from an application in Grafana. The application outputs json which is dumped into a eventLogs.json file on the HDD via a script - here’s an example with 3x objects:
{
"object": "list",
"data": [
{
"object": "event",
"type": 1100,
"itemId": "aba8329b-16fb-407d-abda-af51009b3d01",
"collectionId": null,
"groupId": null,
"policyId": null,
"memberId": null,
"actingUserId": "dffc7182-1203-4af0-b1d0-af51009a9a0c",
"installationId": null,
"date": "2022-11-18T09:25:12.3433333Z",
"device": 10,
"ipAddress": "2.198.xxx.xxx"
},
{
"object": "event",
"type": 1108,
"itemId": "0deba616-9f81-488f-81c1-af4a01040347",
"collectionId": null,
"groupId": null,
"policyId": null,
"memberId": null,
"actingUserId": "dffc7182-1203-4af0-b1d0-af51009a9a0c",
"installationId": null,
"date": "2022-11-18T09:24:57.071Z",
"device": 10,
"ipAddress": "2.198.xxx.xxx"
},
{
"object": "event",
"type": 1107,
"itemId": "f812baad-6e31-4fac-8c8a-af4a0103a7f4",
"collectionId": null,
"groupId": null,
"policyId": null,
"memberId": null,
"actingUserId": "83cd55a9-95bf-4eb5-a221-af4900c54bf7",
"installationId": null,
"date": "2022-11-11T15:45:36.167Z",
"device": 10,
"ipAddress": "2.198.xxx.xxx"
}
],
"continuationToken": "5249723801789057904"
}
I’m scraping this using promtail - here’s my promtail scrape config:
- job_name: xxx-eventLogs_json
pipeline_stages:
- json:
expressions:
event: event
eventType: eventType
itemId: itemId
collectionId: collectionId
groupId: groupId
policyId: policyId
memberId: memberId
actingUserId: actingUserId
installationId: installationId
date: date
device: device
ipAddress: ipAddress
- labels:
event:
eventType:
itemId:
collectionId:
groupId:
policyId:
memberId:
actingUserId:
installationId:
date:
device:
ipAddress:
job: xxxlogs-eventLogs_json
- timestamp:
format: RFC3339Nano
source: date
static_configs:
- targets:
- localhost
labels:
job: bwlogs-eventLogs_json
__path__: /var/xxxlogs/eventLogs/*.json
host: xxx-grafana
These lines are appearing correctly labelled inside of grafana, but are appearing as individual log lines, instead of as a single log line with multiple labels:
In addition - my ‘date’ pipeline stage doesn’t seem to have taken - date is just a label on the data.
I also made an attempt at exporting to .csv, but using the json labels seems ‘neater’
I would very much appreciate any help in getting these json objects read as single log lines.