Skip to content

Conversation

craftaholic
Copy link

Summary

This PR adds Prometheus metrics integration for n8n Insights data, allowing workflow analytics to be exposed to external monitoring systems like Datadog and Grafana.

Key Features:

  • 5 new Prometheus metrics for insights data (avg runtime, failures, failure rate, time saved, total
    executions)
  • Event-driven architecture that emits metrics when insights are calculated
  • Configurable via N8N_METRICS_INCLUDE_INSIGHTS_METRICS environment variable
  • Comprehensive documentation with integration examples

How to Test:

  1. Set environment variables:
  • N8N_METRICS=true
  • N8N_METRICS_INCLUDE_INSIGHTS_METRICS=true
  1. Navigate to insights dashboard to trigger calculations
  2. Check /metrics endpoint for new insights metrics

Related Linear tickets, Github issues, and Community forum posts

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@CLAassistant
Copy link

CLAassistant commented Oct 12, 2025

CLA assistant check
All committers have signed the CLA.

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 7 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="packages/cli/src/metrics/prometheus-metrics.service.ts">

<violation number="1" location="packages/cli/src/metrics/prometheus-metrics.service.ts:345">
The insights metrics listener subscribes to MessageEventBus, but insights events are emitted via EventService. As a result, these gauges won’t update. Subscribe to the same event system used by the emitter (or relay the EventService event to the bus) before processing insights-metrics-calculated.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

});

// Set up event listener for insights metrics events
this.eventBus.on('metrics.eventBus.event', (event) => {
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 12, 2025

Choose a reason for hiding this comment

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

The insights metrics listener subscribes to MessageEventBus, but insights events are emitted via EventService. As a result, these gauges won’t update. Subscribe to the same event system used by the emitter (or relay the EventService event to the bus) before processing insights-metrics-calculated.

Prompt for AI agents
Address the following comment on packages/cli/src/metrics/prometheus-metrics.service.ts at line 345:

<comment>The insights metrics listener subscribes to MessageEventBus, but insights events are emitted via EventService. As a result, these gauges won’t update. Subscribe to the same event system used by the emitter (or relay the EventService event to the bus) before processing insights-metrics-calculated.</comment>

<file context>
@@ -297,6 +299,75 @@ export class PrometheusMetricsService {
+		});
+		
+		// Set up event listener for insights metrics events
+		this.eventBus.on(&#39;metrics.eventBus.event&#39;, (event) =&gt; {
+			if (event.eventName === &#39;insights-metrics-calculated&#39;) {
+				const { metricType, period, value, projectId } = event.payload;
</file context>
Fix with Cubic

@n8n-assistant n8n-assistant bot added community Authored by a community member core Enhancement outside /nodes-base and /editor-ui in linear Issue or PR has been created in Linear for internal review labels Oct 12, 2025
@n8n-assistant
Copy link

n8n-assistant bot commented Oct 12, 2025

Hey @craftaholic,

Thank you for your contribution. We appreciate the time and effort you’ve taken to submit this pull request.

Before we can proceed, please ensure the following:
• Tests are included for any new functionality, logic changes or bug fixes.
• The PR aligns with our contribution guidelines.

Regarding new nodes:
We no longer accept new nodes directly into the core codebase. Instead, we encourage contributors to follow our Community Node Submission Guide to publish nodes independently.

If your node integrates with an AI service that you own or represent, please email [email protected] and we will be happy to discuss the best approach.

About review timelines:
This PR has been added to our internal tracker as "GHC-4983". While we plan to review it, we are currently unable to provide an exact timeframe. Our goal is to begin reviews within a month, but this may change depending on team priorities. We will reach out when the review begins.

Thank you again for contributing to n8n.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Authored by a community member core Enhancement outside /nodes-base and /editor-ui in linear Issue or PR has been created in Linear for internal review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants