Skip to content

About

Wazuh Exporter

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Wazuh Prometheus Exporter

A small, opinionated exporter that turns Wazuh data into a low-noise Prometheus and Alertmanager operational view.

It is intentionally not a second Wazuh dashboard. It answers four questions:

  1. Can the exporter collect current data from Wazuh?
  2. Are agents connected and current?
  3. How many high or critical alerts exist in the rolling window?
  4. Which agent and category combinations meet the configured finding policy?

Detailed evidence remains in Wazuh. The exporter does not expose full logs, alert descriptions, addresses, usernames, paths, commands, hashes, CVEs, or individual alert IDs as Prometheus labels.

Architecture

Wazuh agents -> Wazuh manager -> Wazuh indexer
                     |                 |
                     +---- exporter ---+
                              |
                    Prometheus / Alertmanager
                              |
                         Slack / Rootly

The exporter collects in background goroutines and stores one pre-rendered Prometheus payload in memory. A Prometheus scrape never waits on Wazuh.

Build

Go 1.23 or newer is required.

make test
make race
make vet
make build VERSION=0.1.0 REVISION=$(git rev-parse --short HEAD)

The project uses only the Go standard library.

Run

./bin/wazuh-exporter --config.file=./config.example.json --check.config
./bin/wazuh-exporter --config.file=./config.example.json

Endpoints:

GET /metrics
GET /healthz
GET /readyz

/healthz confirms that the HTTP process is running. /readyz returns success only after every enabled data source has completed a successful collection.

Collection model

The Manager API supplies agent state and inventory. The Indexer supplies alert summary and finding data.

Indexer collection searches only:

  • alerts at or above security.thresholds.high_min_level; and
  • rule IDs listed in security.configured_finding_rule_ids.

Alerts are aggregated by agent and rule with a paged composite aggregation. One absolute RFC3339 UTC cutoff is calculated at the start of each collection and reused for every page. Complete alert documents are never downloaded.

security.max_rule_buckets is a hard safety limit. The exporter reports:

wazuh_alert_processing_complete 1

when every matching bucket was processed, or 0 when the limit was reached.

Alerts and findings

An alert is a high or critical event reported by Wazuh.

A finding is an agent and category combination that met the exporter policy. One finding can summarize several alerts and several Wazuh rules. Prometheus and Alertmanager therefore receive a durable condition instead of one notification per Wazuh event.

Built-in categories:

malware
credential_access
privilege_escalation
persistence
lateral_movement
command_and_control
data_exfiltration
security_control_change
file_integrity_change
rootkit
unclassified

A finding has one deterministic matched_by value:

configured_rule
critical_severity
high_severity
multiple_rules
repeated_alerts
multiple_agents

Meanings:

  • configured_rule: a contributing rule ID is explicitly configured to create a finding.
  • critical_severity: a contributing alert reached the critical threshold.
  • high_severity: a high-severity alert belongs to an immediate high-priority category such as malware, rootkit, command-and-control, exfiltration, or a security-control change.
  • multiple_rules: enough distinct high-severity rules contributed.
  • repeated_alerts: enough high-severity alerts repeated during the window.
  • multiple_agents: the same category affected enough agents.

The finding remains exposed while contributing alerts remain in the configured rolling window. With a 15m window and 60s collection interval, it normally disappears roughly 15 to 16 minutes after the last contributing alert.

Default metrics

Every metric includes an environment label.

Exporter build and collection

wazuh_exporter_build_info{environment,version,revision,go_version}
wazuh_collection_success{environment,source}
wazuh_collection_last_success_timestamp_seconds{environment,source}
wazuh_collection_duration_seconds{environment,source}
wazuh_collection_failures_total{environment,source}

source is manager_api or indexer.

Agent coverage

wazuh_agents{environment,status}
wazuh_agent_connected{environment,agent_id,agent_name}
wazuh_agent_last_seen_timestamp_seconds{environment,agent_id,agent_name}
wazuh_agent_outdated{environment,agent_id,agent_name}

Alert summary

wazuh_alert_window_seconds{environment}
wazuh_alert_processing_complete{environment}
wazuh_alerts{environment,severity}
wazuh_agents_with_alerts{environment,severity}
wazuh_alerts_unclassified{environment}

Findings

Finding series are sparse and exist only while the policy is matched.

wazuh_agent_finding{environment,agent_id,agent_name,category,severity,matched_by}
wazuh_agent_finding_alerts{environment,agent_id,agent_name,category}
wazuh_agent_finding_rules{environment,agent_id,agent_name,category}

Optional inventory

Disabled by default:

wazuh_agent_info{environment,agent_id,agent_name,manager,operating_system,version}
wazuh_agent_group{environment,agent_id,agent_name,group}

Aggregate counts by manager, operating system, or group should be calculated in Prometheus rather than emitted as duplicate exporter metrics.

Optional MITRE summary

Disabled by default:

wazuh_mitre_alerts{environment,tactic}

Configuration

The configuration is strict JSON. Unknown fields fail startup.

{
  "collectors": {
    "agent_health": true,
    "inventory": false,
    "security_summary": true,
    "findings": true,
    "mitre_summary": false
  },
  "security": {
    "window": "15m",
    "composite_page_size": 500,
    "max_rule_buckets": 5000,
    "ignored_rule_ids": [],
    "configured_finding_rule_ids": [],
    "thresholds": {
      "critical_min_level": 15,
      "high_min_level": 13,
      "minimum_distinct_rules": 2,
      "minimum_repeated_alerts": 3,
      "minimum_affected_agents": 3
    }
  }
}

Use password files where possible. TLS verification is enabled by default. An empty ca_file uses the operating-system trust store.

Cardinality policy

The default schema contains 17 metric families. Enabling inventory and MITRE raises the maximum to 20.

The exporter does not emit duplicate summary families that Prometheus can derive from per-agent metrics. It also does not use rule IDs, arbitrary rule groups, MITRE techniques, event contents, or other unbounded values as labels.

Alerting

Examples under deploy/prometheus/ gate agent and finding alerts on recent successful collection. This prevents cached data from being interpreted as current when the Manager API or Indexer is unavailable.

The primary operator condition is:

wazuh_agent_finding == 1

The labels identify the environment, agent, category, severity, and why the finding matched. The operator then opens Wazuh to validate the underlying alerts.

Required permissions

Use dedicated read-only identities in production. The Manager API identity needs read access to agent data. The Indexer identity needs search/read access only to the configured wazuh-alerts-* pattern.

About

Wazuh Exporter

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages