Skip to content

feat: add queries for additional metrics #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 14, 2021
Merged

Conversation

darora
Copy link
Contributor

@darora darora commented Jul 14, 2021

No description provided.

@@ -35,6 +173,17 @@ auth_users:
usage: "GAUGE"
description: "Number of users in the project db"

replication:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll select the series of interest with e.g. replication_realtime_lag{slot_name="realtime"}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@darora Gotcha, would it be preferable to make that part of the query?

i.e. SELECT slot_name, pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn) as replication_lag FROM pg_replication_slots WHERE slot_name = 'realtime';

Also, pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn) outputs lag in bytes. Would it be preferable to use pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)) since its output is more reader friendly (e.g. 92 kB)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can divide it if desired, though it needs to be scalar so we wouldn't want to use pg_size_pretty. Generally, the norm in this space is to keep the native units (e.g. bytes), and then allow the frontends to convert them as appropriate.

Happy to select for realtime in the query, was leaving it this way in case we wanted info on other replications (now or in the future).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarified by renaming metric to replication_realtime_lag_bytes (also more idiomatic)

Copy link
Member

@w3b6x9 w3b6x9 Jul 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

norm in this space is to keep the native units (e.g. bytes), and then allow the frontends to convert them as appropriate

thanks, good to know!

@darora darora force-pushed the da/additional-metrics branch from 551841e to b0314b2 Compare July 14, 2021 03:09
@darora darora merged commit 161bfa8 into develop Jul 14, 2021
@darora darora deleted the da/additional-metrics branch July 14, 2021 23:30
darora added a commit that referenced this pull request Jul 15, 2021
* feat: add queries for additional metrics

* chore: filter for realtime replication lag

* chore: add realtime replication slot active status

Co-authored-by: Wen Bo Xie <wenbo.xie3@gmail.com>
dragarcia added a commit that referenced this pull request Jul 15, 2021
feat: add queries for additional metrics (#59)
damonrand pushed a commit to cepro/postgres that referenced this pull request Jun 15, 2025
* feat: add queries for additional metrics

* chore: filter for realtime replication lag

* chore: add realtime replication slot active status

Co-authored-by: Wen Bo Xie <wenbo.xie3@gmail.com>
damonrand pushed a commit to cepro/postgres that referenced this pull request Jun 15, 2025
* feat: add queries for additional metrics

* chore: filter for realtime replication lag

* chore: add realtime replication slot active status

Co-authored-by: Wen Bo Xie <wenbo.xie3@gmail.com>
damonrand pushed a commit to cepro/postgres that referenced this pull request Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants