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

use 'moonbeam' prefix when emitting prometheus metrics #1329

Merged
merged 7 commits into from
Mar 3, 2022

Conversation

nbaztec
Copy link
Contributor

@nbaztec nbaztec commented Mar 1, 2022

What does it do?

Configures the prometheus registry to use moonbeam prefix when emitting metrics. The metrics would continue to use the chain id as a value for the label chain.

Based on similar polkadot feature here.

What important points reviewers should know?

Existing (grafana) dashboards will break since the metrics are renamed (eg: moonbeam_substrate_block_height).

Existing metrics do not use a prefix and hence are emitted as is. This change will prepend moonbeam_ to all metric names that are emitted by the client: substrate_block_height -> moonbeam_substrate_block_height.

All consumers of the metrics (e.g. Grafana) need to use the prefixed metric names going forward.

Is there something left for follow-up PRs?

(Manual) Integration test must be performed to ascertain that the runtime's prometheus registry override does not inadvertently override prefix for metrics emitted outside the runtime.
Confirmed locally with prometheus.

What alternative implementations were considered?

Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?

What value does it bring to the blockchain users?

Clients can easily distinguish the emitted metrics by the moonbeam application. Distinct chains can be filtered on the chain label.

@librelois librelois added B5-clientnoteworthy Changes should be mentioned in any downstream projects' release notes D3-trivial PR contains trivial changes in a runtime directory that do not require an audit labels Mar 1, 2022
@librelois
Copy link
Collaborator

librelois commented Mar 1, 2022

thank @nbaztec, this is an excellent first contribution :)

This is a breaking change for ops, so we'll have to remember to warn them when we release the client v0.22!

cc @purestakeoskar @Mitchell-Grimes, so that you already have it in your head.

@nbaztec nbaztec marked this pull request as ready for review March 1, 2022 15:58
@nbaztec
Copy link
Contributor Author

nbaztec commented Mar 1, 2022

There's another existing issue for Export chain name in prometheus metrics, this can easily be done as part of this PR by adding the chain_spec.id() as a global const label (all metrics would contain it).

I'm just not sure if the following is the desired behavior for that issue:

moonbeam_my_counter{chain="moonriver", value=1.0}
moonbeam_my_counter{chain="moonbeam", value=2.0}

Any thoughts?

@librelois
Copy link
Collaborator

@artkaseman, what do you think?

@Mitchell-Grimes
Copy link

There's another existing issue for Export chain name in prometheus metrics, this can easily be done as part of this PR by adding the chain_spec.id() as a global const label (all metrics would contain it).

I'm just not sure if the following is the desired behavior for that issue:

moonbeam_my_counter{chain="moonriver", value=1.0}
moonbeam_my_counter{chain="moonbeam", value=2.0}

Any thoughts?

This would be how Polkadot now separates its metrics, we do some magic in our backend so we will be able to handle incoming changes for our dashboards not to break. But really looking forward to any new additional metrics, especially Moonbeam specific ones 🙂

node/service/src/lib.rs Outdated Show resolved Hide resolved
@artkaseman
Copy link

The original use case for the chain id is actually no longer valid. It would be a nice to have but would this greatly increase cardinality if it's included in every metric? @PSjoe

@PSjoe
Copy link

PSjoe commented Mar 1, 2022

The original use case for the chain id is actually no longer valid. It would be a nice to have but would this greatly increase cardinality if it's included in every metric? @PSjoe

I'm afraid I don't follow exactly what's going on here. If we're talking about adding a new label like chain="moonriver" to all the metrics, we all ready to this with our Prometheus rules, so there would be no change in cardinality. Others might appreciate it though.

@nbaztec
Copy link
Contributor Author

nbaztec commented Mar 2, 2022

I agree with @PSjoe, the cardinality is already present and shouldn't impact too much if a collector is only scraping a few distinct chains.

node/service/src/lib.rs Outdated Show resolved Hide resolved
@librelois
Copy link
Collaborator

@nbaztec When the Pr is approved and the CI is green you can merge directly, unless there is a code freeze when a release is coming.

@nbaztec nbaztec merged commit 7e89857 into master Mar 3, 2022
@nbaztec nbaztec deleted the nish-prometheus-prefix branch March 3, 2022 16:56
@HailD HailD mentioned this pull request Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B5-clientnoteworthy Changes should be mentioned in any downstream projects' release notes D3-trivial PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants