OpenDataAlex
OpenDataAlex

Reputation: 1475

Summing a parsed field in Grafana Loki

I am trying to sum the count of rows (row_count) being inserted/updated according to my process logs, which look similar to the following line:

{"function": "Data Processing Insert", "module": "Data Processor", "environment": "DEV", "level": "INFO", "message": "Number of rows inserted", "time": "2022-04-29T09:07:02.735Z", "epoch_time": 1651223222.735133, "row_count": "8089"}

I'm able to build the filter to get those lines but haven't been able to perform calculations on row_count. How would I go about doing that?

Upvotes: 3

Views: 5646

Answers (1)

OpenDataAlex
OpenDataAlex

Reputation: 1475

The grafana community channel came thru. To do what I'm looking for I had to use unwrap:

sum_over_time({__aws_cloudwatch_log_group="/aws/batch/job"} | json | message=~".+inserted" | unwrap row_count [1h])

Upvotes: 5

Related Questions