Grafana + Loki: How to Join and Filter Log Streams by Matching SHAs?

  • What are you trying to achieve?
    Hello, I am trying to calculate lead time for changes. The graph should show the difference in the pull_request merged_at time and the deployment updated_at. The linking value is the sha.

  • How are you trying to achieve it?
    With two LogQL queries to a Loki db that store Github Events.

{team_name="$team", action=~"closed", merged_at!=""} | json
{team_name="$team", deployment_state="success"} | json

These are the objects after Extracting the Labels and Filtering fields by name.

I am seeking advice on what transformations or edits to my query would allow me to filter out all sha’s that aren’t in both deployment_sha and pull_request sha so I can “link” the two objects together and calculate this metric.

Thanks in advance for the help :grinning: