Skip to content

n8n Module API Explanation

The n8n module monitors the status and execution state of automated workflow definitions.


API Execution Logic

The module locates the service matching the identifier n8n. It loads the N8N_API_KEY environment variable and passes it via the X-N8N-API-KEY header.

Request Execution

A GET request is dispatched to /api/v1/workflows. A 5-second timeout is enforced.

Data Parsing and De-duplication

Upon a successful response, the JSON payload is parsed. If the n8n API returns workflows containing archives, the module performs filtering and de-duplication:

  1. Archive Filter: Workflows flagged as archived (isArchived: true) are filtered out.
  2. De-duplication: To prevent inaccurate counts on instances running overlapping execution stages, the workflows are de-duplicated by name using a Map key lookup, prioritizing the active workflow state.
  3. Metric Calculation:
  4. Primary Metric: The count of unique, non-archived workflows.
  5. Secondary Metric: The number of workflows currently active (enabled).

Caching Strategy

The workflow telemetry is cached for 60 seconds (TTL) with a stale window of 300 seconds.