Skip to content

[*] Fix global-db-overview query logic, fixes #1152#1239

Open
Mazen050 wants to merge 4 commits intocybertec-postgresql:masterfrom
Mazen050:bugfix/global-db-overview-queryLogic
Open

[*] Fix global-db-overview query logic, fixes #1152#1239
Mazen050 wants to merge 4 commits intocybertec-postgresql:masterfrom
Mazen050:bugfix/global-db-overview-queryLogic

Conversation

@Mazen050
Copy link
Contributor

This PR partially fixes #1152

Fixing query logic in the global-db-overview dashboard.

@Mazen050 Mazen050 marked this pull request as draft February 24, 2026 23:01
@Mazen050 Mazen050 changed the title [*] fix connections overview sql query [*] Fix global-db-overview query logic, fixes #1152 Feb 24, 2026
@pashagolub pashagolub self-assigned this Mar 2, 2026
@pashagolub pashagolub added wontfix This will not be worked on dashboards Grafana dashboards related labels Mar 2, 2026
@pashagolub
Copy link
Collaborator

closed by #1262

@pashagolub pashagolub closed this Mar 2, 2026
@Mazen050
Copy link
Contributor Author

Mazen050 commented Mar 2, 2026

@pashagolub this PR has nothing to do with my PR. My PR fixes another bug

@0xgouda 0xgouda reopened this Mar 2, 2026
@pashagolub
Copy link
Collaborator

@Mazen050 sorry about that!

@Mazen050
Copy link
Contributor Author

Mazen050 commented Mar 4, 2026

Before:

image

After:

image

@Mazen050 Mazen050 force-pushed the bugfix/global-db-overview-queryLogic branch from 8c7ddf5 to 4882abe Compare March 6, 2026 00:12
@Mazen050 Mazen050 marked this pull request as ready for review March 6, 2026 00:12
@0xgouda
Copy link
Collaborator

0xgouda commented Mar 6, 2026

Please describe how you fixed the queries.

@Mazen050
Copy link
Contributor Author

Mazen050 commented Mar 6, 2026

Hello @0xgouda , Based on your fix I fixed the queries my self first then sent to gemini 3 for review.

Here basically we get the most recent sample before the dashboards selected time range so that lag() has something to subtract from for the first row in the range. preventing the NULL we used to get because the inner query's WHERE time >= $__timeFrom() excludes any prior row for it to look back at.

A new addition to your CTE is DISTINCT ON (dbname) which is necessary here because in this dashboard the queries run on multiple dbs so DISTINCT ON (dbname) makes us select the most recent rows(before range) per db.

Please if anything else needs more clarification let me know.

@Mazen050 Mazen050 force-pushed the bugfix/global-db-overview-queryLogic branch from 4882abe to dc70999 Compare March 6, 2026 12:35
@Mazen050
Copy link
Contributor Author

Mazen050 commented Mar 6, 2026

I rebased and now go tests are failing.

@Mazen050 Mazen050 force-pushed the bugfix/global-db-overview-queryLogic branch from dc70999 to 054b8f8 Compare March 6, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dashboards Grafana dashboards related wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem in query logic of some panels

3 participants