Schedule icon
FluxQuery icon
Switch icon
Log icon
SlackIncomingWebhook icon

Audit InfluxDB Series Cardinality and Detect Tag Explosion Surges

Audit InfluxDB series cardinality across telemetry buckets with Kestra. Detect tag explosion and high-cardinality bursts before TSDB memory exhaustion.

Categories
DataInfrastructure

Time-series databases like InfluxDB rely on inverted index structures (TSI) to store and query metrics efficiently. In production telemetry and IoT ingestion pipelines, high-entropy fields such as user IDs, request UUIDs, container IP addresses, or unparsed URLs are occasionally mistakenly indexed as tags rather than stored as field values. This creates millions of unique time series keys in minutes, a condition known as series cardinality explosion. Runaway cardinality causes exponential TSI index memory consumption, severe compaction delays, query timeouts, and unrecoverable out-of-memory (OOM) crashes across InfluxDB storage nodes.

This blueprint implements an automated Day 2 Operations sentinel that queries InfluxDB on a recurring schedule. It runs a Flux aggregation across target telemetry buckets to identify measurements with the highest active series volume, evaluates peak series counts against cardinality thresholds, and automatically dispatches Slack incident alerts with root-cause measurement telemetry to prevent TSDB cluster degradation.

How it works

  1. periodic_cardinality_audit (io.kestra.plugin.core.trigger.Schedule) triggers the audit pass every 4 hours (disabled by default for initial setup).
  2. probe_series_cardinality (io.kestra.plugin.influxdb.FluxQuery) connects to InfluxDB via its native Flux API, scanning the target bucket over the configured lookback window, grouping by measurement and field, and sorting descending to return the top 5 highest series measurements.
  3. evaluate_cardinality (io.kestra.plugin.core.flow.Switch) evaluates whether the peak measurement series count exceeds max_series_threshold.
  4. When within acceptable operational limits (HEALTHY), log_cardinality_healthy records the measurement name, series count, and healthy status.
  5. When a cardinality surge is detected (SURGE_DETECTED), alert_cardinality_surge dispatches an operational incident alert to Slack using io.kestra.plugin.slack.notifications.SlackIncomingWebhook, and log_remediation_guidance logs actionable isolation instructions.
  6. log_audit_completion writes a final audit recap for execution tracking and audit lineage.
  7. The flow-level errors block alerts Slack immediately if InfluxDB authentication or network connectivity fails.

What you get

  • Early warning of InfluxDB series cardinality explosion before memory exhaustion triggers node OOM kills.
  • Identification of exact offending measurements driving index bloat.
  • Automated Slack incident notifications with measurement names, series counts, and threshold context.
  • Configurable lookback windows and series capacity thresholds tailored to your cluster sizing.
  • Flow-level error alerting safeguarding audit pipeline reliability.

Who it's for

  • Site Reliability Engineers and Platform Teams managing self-hosted InfluxDB OSS or Enterprise clusters.
  • Observability and DevOps Engineers maintaining high-throughput Prometheus, Telegraf, or OpenTelemetry ingestion.
  • Data Platform Engineers operating time-series telemetry pipelines for IoT or application monitoring.

Why orchestrate this with Kestra

Monitoring InfluxDB cardinality using detached cron jobs or external scripts requires managing client libraries, credential rotation, error handling, and notification webhooks in brittle custom code. Kestra provides a declarative workflow engine with native InfluxDB Flux support, centralized secret management, conditional branching, execution history, and native Slack alerting without operating dedicated monitoring daemons.

Prerequisites

  • A running InfluxDB v2 instance (OSS v2.x or InfluxDB Cloud).
  • An InfluxDB API token with read permissions on the monitored bucket.
  • A Slack Incoming Webhook URL configured in Kestra secrets.

Local Docker Container Setup

To run InfluxDB locally for development and testing without host port conflicts:

docker run -d --name influxdb-dev -p 8086:8086 \
  -e DOCKER_INFLUXDB_INIT_MODE=setup \
  -e DOCKER_INFLUXDB_INIT_USERNAME=admin \
  -e DOCKER_INFLUXDB_INIT_PASSWORD=adminpassword123 \
  -e DOCKER_INFLUXDB_INIT_ORG=company-infra \
  -e DOCKER_INFLUXDB_INIT_BUCKET=telemetry \
  -e DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=my-super-secret-auth-token \
  influxdb:2.7-alpine

If Kestra is running inside a Docker network, connect the InfluxDB container to Kestra's network:

docker network ls
docker network connect YOUR_KESTRA_NETWORK influxdb-dev

Secrets

  • INFLUXDB_TOKEN: API token permitted to execute Flux queries in the target InfluxDB organization.
  • SLACK_WEBHOOK: Incoming Webhook URL for Slack alerting.

Note for Kestra Open-Source (OSS): Secrets are configured as base64-encoded environment variables formatted as SECRET_<NAME> (e.g. SECRET_INFLUXDB_TOKEN).

Inputs

Name Type Default Allowed Values Description
influxdb_host STRING "http://localhost:8086" Valid HTTP/S URL InfluxDB API endpoint
influxdb_org STRING "company-infra" String identifier InfluxDB organization name
target_bucket STRING "telemetry" Valid bucket name Bucket inspected for cardinality
lookback_window STRING "1h" Valid Flux duration (15m, 1h, 6h) Aggregation time window
max_series_threshold INT 50000 Positive integer Maximum allowable series per measurement
remediation_mode SELECT "ALERT_ONLY" "ALERT_ONLY", "LOG_REMEDIATION" Action mode on cardinality breach

Outputs

  • {{ outputs.probe_series_cardinality.rows }}: List of top measurement records containing _measurement, _field, and _value (series count).
  • {{ outputs.probe_series_cardinality.size }}: Total number of measurement summary rows returned by the Flux query.

Quick start

  1. Configure INFLUXDB_TOKEN and SLACK_WEBHOOK in your Kestra namespace secrets.
  2. Import this blueprint into your Kestra instance.
  3. Run a manual execution with inputs.target_bucket set to your telemetry bucket to verify connectivity and series aggregation.
  4. Enable the periodic_cardinality_audit schedule trigger to run automated recurring audits.

How to extend

  • Add automated tag isolation by triggering an downstream HTTP request to query InfluxDB schema keys (schema.tagKeys()) and identify the exact high-cardinality tag.
  • Integrate with PagerDuty or Opsgenie in the SURGE_DETECTED branch for critical production cluster alerts.
  • Chain an automated Telegraf or vector configuration reload subflow using io.kestra.plugin.core.flow.Subflow to filter out unbounded tag dimensions at the ingestion edge.

Pitfalls

  • Flux Query Timeout on Very Large Buckets: If a bucket contains billions of points across wide timeframes, scanning a large lookback window may cause query timeouts. Keep lookback_window focused (e.g., 15m to 1h) for high-frequency time series data.
  • InfluxDB v1 vs v2 Compatibility: This blueprint utilizes Flux queries designed for InfluxDB v2.x and InfluxDB Cloud. If querying InfluxDB v1.8 compatibility endpoints, use io.kestra.plugin.influxdb.InfluxQLQuery with SHOW SERIES CARDINALITY syntax instead.
  • Port Accessibility: When running InfluxDB and Kestra in separate Docker containers, ensure hostnames resolve via container networks rather than referencing localhost.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.