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

Add some metrics to the postgres check #1373

Merged
merged 1 commit into from
Mar 18, 2015
Merged

Add some metrics to the postgres check #1373

merged 1 commit into from
Mar 18, 2015

Conversation

DorianZaccaria
Copy link
Contributor

Improve postgresql.replication_delay, add postgresql.replication_delay_bytes and postgresql.total_tables.

@remh
Copy link
Contributor

remh commented Feb 13, 2015

Thanks, looks like the pg tests are failing. Can you fix accordingly please ?

@remh
Copy link
Contributor

remh commented Feb 25, 2015

@DorianZaccaria can you rebase your branch as i can't merge it for now.
Thanks!

@DorianZaccaria
Copy link
Contributor Author

@remh Any updates for this one?

if self._is_9_1_or_above(key,db):
# Only available for >= 9.2 due to
# pg_xlog_location_diff
if self._is_9_2_or_above(key,db):
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you will break replication metrics for PG 9.1 users.

You should append the replication_delay_bytes metrics where PG >= 9.2 and keep replication_delay in case of 9.1

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'll split this one.

@DorianZaccaria DorianZaccaria force-pushed the dorian/postgres branch 2 times, most recently from e4912eb to ea85e41 Compare March 6, 2015 15:42
self.assertTrue(len([m for m in metrics if m[0] == u'postgresql.percent_usage_connections']) >= 1, pprint(metrics))
self.assertTrue(len([m for m in metrics if m[0] == u'postgresql.total_tables']) >= 1, pprint(metrics))
self.assertTrue(len([m for m in metrics if m[0] == u'postgresql.db.count']) == 1, pprint(metrics))
self.assertTrue(len([m for m in metrics if m[0] == u'postgresql.total_tables']) == 1, pprint(metrics))
Copy link
Member

Choose a reason for hiding this comment

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

Looks like you are asserting twice this total_tables metric.

@LeoCavaille
Copy link
Member

@DorianZaccaria looks good except the few nitpicks

if self._is_9_1_or_above(key, db) and metrics is None:
self.replication_metrics[key] = dict(self.REPLICATION_METRICS_9_1)
if self._is_9_2_or_above(key, db):
self.replication_metrics.update(self.REPLICATION_METRICS_9_2)
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't it be:

 self.replication_metrics[key].update(self.REPLICATION_METRICS_9_2)

?

Also this seems a bit weird, as you're then overriding a constant (self.REPLICATION_METRICS), which in result will be applied to all instances. So your code won't work in the (weird) case where you have multiples instances of postgres running different versions.

I think _get_replication_metrics should just return the replication metrics (as the name of the method seems to indicate)

@remh
Copy link
Contributor

remh commented Mar 16, 2015

@DorianZaccaria i made one last comment but it should be good after this one!

Thanks a lot !

* Add postgresql.replication_delay_bytes metric
* Add postgresql.total_tables metric
* Update postgresql.replication_delay because it wasn't accurate
* Update the test suite
@remh
Copy link
Contributor

remh commented Mar 18, 2015

Looks great! Waiting for the tests to finish and will merge.

Thanks a lot @DorianZaccaria !

@remh
Copy link
Contributor

remh commented Mar 18, 2015

🇫🇷 🍰 👍 💥

remh added a commit that referenced this pull request Mar 18, 2015
Add some metrics to the postgres check
@remh remh merged commit 031dc40 into master Mar 18, 2015
@DorianZaccaria DorianZaccaria deleted the dorian/postgres branch March 18, 2015 21:38
@DorianZaccaria
Copy link
Contributor Author

Yay!

@miketheman
Copy link
Contributor

~

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.

4 participants