Skip to content
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

Metrics: add new metrics for the upcoming Postgres v14 release. #399

Merged

Conversation

kmoppel-cognite
Copy link
Collaborator

Some new views are more niche, so don't add the to default configs though

Some new views are more nische, so don't add the to default configs though.
@kmoppel-cognite
Copy link
Collaborator Author

@carlosbrb @markwort Hey, please review:) Can't break anything for old setups though..

Copy link

@carlosbrb carlosbrb left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Contributor

@markwort markwort left a comment

Choose a reason for hiding this comment

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

Dear @kmoppel-cognite , thanks for your PR, I hope you're doing well.
I've added a few comments. Primarily, I'm unsure about the conversion from floating point numbers to integers, maybe you can enlighten us with your thought processes?
Do you forsee any issues with Grafana and floats? Or is this about some of the metrics storage DB options?

(extract(epoch from now()) * 1e9)::int8 as epoch_ns,
wal_records,
wal_fpi,
(wal_bytes / 1000)::int8 as wal_bytes_kb,
Copy link
Contributor

Choose a reason for hiding this comment

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

In wal_size the size is measured in bytes, I've seen several other cases (data dir sizze, table bloat e.g.) where bytes are used.
I think we should leave this unit as is (in bytes) and not convert it. It is cheap (and consistent with other usage) to do the conversion in e.g. Grafana when displaying the data.

If you're worried that this might soon exceed bigint sizes, then I would at least vote to make the divisor be 1024, not 1000.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hey Julian, thanks for the review! And I think you're right - was worrying too much here :) if there would be a real danger of overflow then the PG core team would have used some other unit, will change to bytes..

pgwatch2/metrics/db_stats/14/metric.sql Show resolved Hide resolved
pgwatch2/metrics/db_stats/14/metric.sql Show resolved Hide resolved
@@ -2,7 +2,7 @@ select
(extract(epoch from now()) * 1e9)::int8 as epoch_ns,
wal_records,
wal_fpi,
(wal_bytes / 1000)::int8 as wal_bytes_kb,
wal_bytes,
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the quick fix, but I think you forgot something that you mentioned in another comment...
For some reason, the wal_bytes are of data type numeric, so a cast to bigint or similar might indeed be necessary?

https://github.com/postgres/postgres/blob/1bc8e7b0991c1eae5fa6dc2d29bb2280efb52740/src/backend/utils/adt/pgstatfuncs.c#L1822-L1823

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah crap, missed that it was numeric, good that someone is paying attention :) ...so indeed core devs considered an overflow possibility..so thatswhy I probably did the division thing in the 1st place...I guess to be on the safe side let's divide by 1024 then? Maybe some data warehouse is writing a petabyte per day indeed - then they have "only" 25 years with byte units :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, the time counters in pg_stat_database would overflow after 29 years as well...
I guess the assumption is that users will run through at least one statistics reset before that anyway?

I don't feel confident making a decision here. I guess whoever constructs the dashboards to display this data should look up the units anyway, and then the name of the field wal_bytes_kb would indicate what kind of value they are getting anyway.
So if you think that converting to kilobytes is a good idea then I am fine with it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes I think kB units are just fine like that when they're explicit - the metric is not part of default configs / dashboards anyways and better be as future proof as possible - this metrics will stay valid for all future PG versions as well if no breaking catalog changes to pg_stat_wal

Copy link
Collaborator

@pashagolub pashagolub left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

@markwort markwort merged commit 4b9f630 into cybertec-postgresql:master Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants