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

[Bug][Grafana/Dashboards] Missing PostgreSQL dashboards and panel desync for Cursor and AI metrics

Open Thundercloud12 opened this issue 2 months ago • 1 comments

Search before asking

  • [x] I had searched in the issues and found no similar issues.

What happened

DevLake officially supports both MySQL and PostgreSQL as lake databases. In PR #8870, dashboards were split into grafana/dashboards/mysql/ and grafana/dashboards/postgresql/, and Grafana provisioning selectively mounts or keeps the relevant database directory based on DATABASE_TYPE.

However, the recent Cursor integration (PR #9017) and Claude Code integration (PR #8808) introduced significant dashboard omissions and desyncs for PostgreSQL deployments:

  1. cursor-usage.json is completely missing from PostgreSQL: • cursor-usage.json was added in PR #9017 (1,354 lines of JSON). • No PostgreSQL equivalent was created in . • When running on PostgreSQL, entrypoint.sh:66 executes rm - rf /etc/grafana/dashboards/mysql, and docker-compose-dev- postgresql.yml mounts only ./grafana/dashboards/postgresql. As a result, Cursor users on PostgreSQL have no Cursor dashboard at all.
  2. Panels are out-of-sync in existing comparison dashboards: • ai-cost-efficiency.json: The MySQL version has 17 panels, while the PostgreSQL version has only 10 panels. All 7 Cursor panels (such as Cursor Spend Breakdown, Charged Amount, and spend reconciliation) are completely missing from PostgreSQL. • multi-ai-comparison.json: The MySQL version has 10 panels, while the PostgreSQL version has only 9 panels. The Cursor: Tab Completions panel and Cursor LOC/acceptance queries are missing from PostgreSQL.
  3. Claude Code dashboards stranded in root directory: • ClaudeCodeAdoption.json and ClaudeCodeAdoptionByUser.json sit directly in grafana/dashboards/ root hardcoded to "datasource": {"type": "mysql", "uid": "devlake-mysql-api"} and MySQL-specific functions (TIMESTAMPDIFF, DATE_SUB). • Because docker-compose-dev-mysql.yml and docker-compose- dev-postgresql.yml mount grafana/dashboards/mysql and grafana/dashboards/postgresql directly to /etc/grafana/dashboards:ro, files in the root folder are not mounted in local dev environments and fail with missing datasource errors in PostgreSQL containers.

What do you expect to happen

  1. Full PostgreSQL Parity for Cursor: • Generate cursor-usage.json with converted PostgreSQL SQL syntax (DATE_TRUNC, TO_CHAR, COALESCE, interval arithmetic) and UID cursor_usage-pg. • Ensure datasource references match Grafana 13 format: "datasource": {"type": "grafana-postgresql-datasource", "uid": "devlake-postgres-api"}

  2. Synchronize Comparison Dashboards: • Sync ai-cost-efficiency.json to include the 7 missing Cursor spend panels with PostgreSQL syntax. • Sync multi-ai-comparison.json with Cursor Tab Completions and LOC/acceptance queries.

  3. Move & Convert Claude Code Dashboards: • Move ClaudeCodeAdoption.json and ClaudeCodeAdoptionByUser. json into grafana/dashboards/mysql/. • Generate their PostgreSQL equivalents in grafana/dashboards/postgresql/.

How to reproduce

  1. Start DevLake using PostgreSQL: docker-compose -f docker-compose-dev-postgresql.yml up postgres grafana

  2. Log into Grafana (http://localhost:3002 or http://localhost:4000/grafana).

  3. Search for dashboards: • Notice that Cursor Usage is missing. • Open AI Cost-Efficiency: notice that Cursor spend panels are missing (only 10 panels instead of 17). • Open Multi-AI Tool Comparison: notice Cursor metrics are missing.

Anything else

• Root Cause: PR #9017 added the Cursor plugin and updated MySQL dashboards, but did not run convert-mysql-to-postgresql.py or generate PostgreSQL dashboards. CI currently does not test dashboard parity between MySQL and PostgreSQL. • Relevant files: • cursor-usage.json • ai-cost-efficiency.json vs ai-cost-efficiency.json • multi-ai-comparison.json vs multi-ai-comparison.json • convert-mysql-to-postgresql.py

Version

main (commit a18194b96b5b332a60a74b23d51bacbb4262234d)

Are you willing to submit PR?

  • [x] Yes I am willing to submit a PR!

Code of Conduct

Thundercloud12 avatar Sep 26 '26 16:09 Thundercloud12

Thanks for your contribution.

klesh avatar Sep 27 '26 02:09 klesh