incubator-devlake icon indicating copy to clipboard operation
incubator-devlake copied to clipboard

fix(dashboards): fix Grafana variable interpolation for string team/user IDs in MySQL dashboards

Open bujjibabukatta opened this issue 5 months ago • 1 comments

Summary

Fixes #8829

MySQL Grafana dashboards break when teams.id or users.id are non-numeric strings (the schema allows varchar(255)). Grafana injects $variable raw into SQL IN() clauses, so string values arrive unquoted and the query fails.

Root Cause

The affected SQL patterns looked like:

-- before
where team_id in (${team1})
where t.name in (${team})
where ua.user_id in (${users})

Grafana's ${variable:singlequote} formatter wraps each value in single quotes, making the query safe for string IDs. The PostgreSQL variants of these dashboards already used this formatter; only the MySQL variants were affected.

Changes

grafana/dashboards/mysql/work-logs.json

  • Variable definition query: ${team:singlequote} for user dropdown
  • All 12 panel rawSql blocks: ${users} → ${users:singlequote}

grafana/dashboards/mysql/dora-by-team.json

  • All occurrences of ${team} → ${team:singlequote} across all panels (Deployment Frequency, Lead Time, Change Failure Rate, Recovery Time — both stat cards and monthly bar charts)

grafana/dashboards/mysql/engineering-throughput-and-cycle-time-team-view.json

  • All occurrences of ${team1} / ${team2} → ${team1:singlequote} / ${team2:singlequote} across all panels

Testing

Verified by inspecting all rawSql blocks in each affected file. No changes to PostgreSQL dashboards (grafana/dashboards/postgresql/) as they already use :singlequote throughout.

bujjibabukatta avatar Jun 14 '26 11:06 bujjibabukatta

Hi @Startrekzky please review and merge pull request.

bujjibabukatta avatar Jun 19 '26 12:06 bujjibabukatta