You can SQL your logs in Grafana

Most people don’t know that Grafana can join log queries using SQL.

In my team, we manage a system that runs asynchronous jobs, each writing two log lines - one at the start, one on completion. How do you track job progress without creating a database?

Turns out, Grafana can do it.

The Pattern: Write two Loki queries (to find the “start” and “end” lines), then use Grafana’s SQL Expressions to join them on job_id.

The Result: A full job state table! See start time, end time, duration, or status – all from logs, and no database required.

Diagram showing how two Loki queries (one for job start events, one for job finish events) are combined using a Grafana SQL expression with a LEFT JOIN on  job ID. The resulting dashboard table displays job runs with columns for action, job result, start time, and end time.
Combining two Loki queries with a SQL expression to create a job runs table

I shared this with someone, and they immediately went off to build their own dashboard. :)

Add Data Links (contextual links to relevant log queries) and you’ve got a custom job monitoring tool with zero infrastructure.

I really like this feature. Same pattern works for any async workload that produces logs: CI/CD runs, batch jobs, ETL processes, anything you like.