Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Companion PR for removing Prometheus metrics prefix #3623

Merged
merged 14 commits into from
Dec 10, 2021
Merged

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Aug 11, 2021

Companion for paritytech/substrate#9543

I've removed the set_prometheus_registry function altogether, as Substrate automatically customizes the registry with the chain id.

cc @HCastano I've tweaked the metric_name function.
I don't really understand the reason for this function (it was introduced in 9781c79 😬 ), so let me know if this is correct.

@tomaka tomaka added the A4-companion A PR that needs a companion PR to merge in parallel for one of its downstream dependencies. label Aug 11, 2021
@tomaka tomaka requested a review from HCastano August 11, 2021 16:47
@tomaka tomaka added B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels Aug 11, 2021
@tomaka
Copy link
Contributor Author

tomaka commented Aug 11, 2021

Sorry I've been missing a bunch of metrics because the code style isn't the same as Substrate. Will do another thorough pass.

Copy link
Contributor

@HCastano HCastano left a comment

Choose a reason for hiding this comment

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

If you're curious about the origin of metric_name, this is the relevant PR: paritytech/parity-bridges-common#878

} else {
name.into()
format!("polkadot_{}", name)
Copy link
Contributor

Choose a reason for hiding this comment

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

This piece of code isn't Polkadot specific (and in fact, isn't technically used by the Polkadot repo), so there's no need for this change

@@ -270,7 +270,8 @@ fn create_metrics_registry(prefix: Option<String>) -> Registry {
match prefix {
Some(prefix) => {
assert!(!prefix.is_empty(), "Metrics prefix can not be empty");
Registry::new_custom(Some(prefix), None).expect("only fails if prefix is empty; prefix is not empty; qed")
Registry::new_custom(None, Some(iter::once((String::from("chain"), prefix)).collect()))
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not too familar with Prometheus, so why is it better to use a label instead of a prefix here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With a prefix you can't easily use the same Grafana dashboard across multiple prefixes.
See paritytech/substrate#9543

@@ -121,9 +121,9 @@ impl From<Option<MetricsAddress>> for MetricsParams {
/// Returns metric name optionally prefixed with given prefix.
pub fn metric_name(prefix: Option<&str>, name: &str) -> String {
if let Some(prefix) = prefix {
format!("{}_{}", prefix, name)
format!("polkadot_{}_{}", prefix, name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment here (I forgot to highlight the block)

Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

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

Besides the bridges stuff that should be reverted, it looks good.

@bkchr
Copy link
Member

bkchr commented Nov 25, 2021

@tomaka this also needs to be updated.

bob: reports parachain_candidate_dispute_concluded{validity="valid"} is at least 1 within 90 seconds
charlie: reports parachain_candidate_dispute_concluded{validity="valid"} is at least 1 within 90 seconds
charlie: reports parachain_candidate_dispute_concluded{validity="valid"} is at least 1 within 90 seconds
alice: reports polkadot_parachain_candidate_disputes_total is at least 1 within 250 seconds
Copy link
Member

Choose a reason for hiding this comment

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

this doesn't need to be updated I believe cc @pepoviola

Copy link
Member

Choose a reason for hiding this comment

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

It needs. It failed before.

Copy link
Member

Choose a reason for hiding this comment

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

Let's wait what the test is saying.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @ordian, no. The prefix isn't expected.
Thx!

Copy link
Member

Choose a reason for hiding this comment

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

@pepoviola it seems there are some hard coded metrics. See the tests below. Can you fix this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Test are failing, let me review how the metrics are reported with this changes.
Thx!

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @bkchr, I check why the test are failing and with this changes metrics are reported like:

substrate_sub_libp2p_peers_count{chain="/cfg/wococo-local.json"} 5

The issue is the suffix {chain="/cfg/wococo-local.json"} is this needed? Currently the metrics are reported without that.

polkadot_sub_libp2p_peers_count 3

Zombiente will try to get the metric without looking the prefix (polkadot/substrate) but don't have the logic to add the chain suffix.

Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

The issue is the suffix {chain="/cfg/wococo-local.json"}

This is a bug and should be only chain=wococo. I'm working on a fix. However, this chain arg stays.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oks, this will need some changes in zombienet to match the metrics. I will work on that asap and update the runner image in CI to review.
Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @bkchr, I already added support for the suffix in zombienet and now test are ok.
Thanks!

@bkchr bkchr added this to the v0.9.14 milestone Dec 9, 2021
@tomaka tomaka requested a review from a team as a code owner December 10, 2021 10:30
@bkchr bkchr merged commit b658044 into master Dec 10, 2021
@bkchr bkchr deleted the tka-prometheus-prefix branch December 10, 2021 14:24
@pepyakin pepyakin added B1-releasenotes and removed B0-silent Changes should not be mentioned in any release notes labels Dec 10, 2021
@pepyakin
Copy link
Contributor

I think this PR was mislabeled: I think this is a change that worth to put into polkadot changelogs.

@pepyakin pepyakin added B0-silent Changes should not be mentioned in any release notes and removed B1-releasenotes labels Dec 10, 2021
@pepyakin
Copy link
Contributor

nevermind, actually it doesn't change the metric names.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A4-companion A PR that needs a companion PR to merge in parallel for one of its downstream dependencies. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants