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

fix(core): Respect prefix for all Prometheus metrics #10130

Merged
merged 7 commits into from
Jul 22, 2024

Conversation

ivov
Copy link
Contributor

@ivov ivov commented Jul 22, 2024

Prometheus metrics from express-prom-bundle and prom-client were not respecting N8N_METRICS_PREFIX

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Jul 22, 2024
}

disableAllLabels() {
for (const label of Object.keys(this.includes.labels) as MetricLabel[]) {
Copy link
Member

Choose a reason for hiding this comment

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

could we not use a for-in loop here instead of a for-of on Object.keys?

metrics: {
default: config.getEnv('endpoints.metrics.includeDefaultMetrics'),
api: config.getEnv('endpoints.metrics.includeApiEndpoints'),
Copy link
Member

Choose a reason for hiding this comment

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

is this a breaking change 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do you mean? This is an internal implementation detail, the schema path and the env remain the same.

Copy link
Member

Choose a reason for hiding this comment

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

does this not change the metric name that gets scraped by prometheus?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh that's what you mean. Since we advertise this as experimental I take it this is okay to change, but I can add a mention just in case.

});
}

private addPrefixToMetrics(metrics: string) {
Copy link
Member

Choose a reason for hiding this comment

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

could we make this public and add unit tests just for this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is covered by integration tests containing the n8n_test_ prefix.

Copy link

cypress bot commented Jul 22, 2024

3 flaky tests on run #6064 ↗︎

0 400 0 0 Flakiness 3

Details:

🌳 🖥️ browsers:node18.12.0-chrome107 🤖 ivov 🗃️ e2e/*
Project: n8n Commit: c7368c00ce
Status: Passed Duration: 05:40 💡
Started: Jul 22, 2024 9:36 AM Ended: Jul 22, 2024 9:42 AM
Flakiness  5-ndv.cy.ts • 2 flaky tests

View Output Video

Test Artifacts
NDV > should not retrieve remote options when required params throw errors Screenshots Video
NDV > Stop listening for trigger event from NDV Screenshots Video
Flakiness  10-undo-redo.cy.ts • 1 flaky test

View Output Video

Test Artifacts
Undo/Redo > should undo/redo adding nodes Test Replay Screenshots Video

Review all test suite changes for PR #10130 ↗︎

Copy link
Contributor

✅ All Cypress E2E specs passed

@ivov ivov merged commit b1816db into master Jul 22, 2024
27 checks passed
@ivov ivov deleted the respect-prefix-for-all-prometheus-metrics branch July 22, 2024 10:01
@github-actions github-actions bot mentioned this pull request Jul 24, 2024
@janober
Copy link
Member

janober commented Jul 24, 2024

Got released with n8n@1.52.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants