Schedule icon
Request icon
Return icon
Switch icon
Log icon
SlackIncomingWebhook icon
OutputValues icon

NetBird Mesh Peer Connectivity and Security Sentinel

Audit NetBird WireGuard peer connectivity, detect expired login sessions and pending approvals, classify mesh health, and alert Slack via Kestra.

Categories
Infrastructure

Continuously audits NetBird zero-trust WireGuard overlay networks by querying the Management REST API, validating peer connectivity states, identifying expired login sessions or unapproved devices, classifying mesh health, and dispatching incident alerts to Slack.

How it works

  1. probe_netbird_users queries /api/users using an API access token to verify NetBird Management service vitality and credential validity.
  2. probe_netbird_peers retrieves the complete inventory of registered peers across the mesh network, extracting internal IPs, online connection statuses, login expiration flags, and approval requirements.
  3. probe_netbird_routes queries /api/routes to verify defined subnet routers and network routing health.
  4. classify_network_status evaluates peer attributes using a Pebble conditional expression:
    • Flags peers whose login sessions have expired (login_expired: true) and categorizes state as LOGIN_EXPIRED_CRITICAL.
    • Flags newly enrolled devices waiting for administrator review (approval_required: true) as APPROVAL_PENDING.
    • Flags disconnected peers (connected: false) exceeding max_tolerated_disconnected_peers as PEERS_DISCONNECTED_WARNING.
    • Confirms all enrolled peers are active and authorized to categorize state as HEALTHY.
    • Detects unreachable management endpoints or API errors as API_UNREACHABLE or PROBE_FAILED.
  5. route_by_network_status switches workflow execution based on the classification:
    • HEALTHY: Logs total peers, active network routes, and confirmed connectivity.
    • LOGIN_EXPIRED_CRITICAL: Dispatches an urgent escalation alert to Slack naming machines with severed WireGuard tunnels due to expired credentials.
    • PEERS_DISCONNECTED_WARNING: Posts a warning to Slack naming offline hostnames and assigned internal IPs.
    • APPROVAL_PENDING: Alerts administrators that new edge peers require connection authorization.
    • API_UNREACHABLE: Alerts on-call operations that the NetBird management control plane is down.
  6. log_audit_summary produces structured outputs recording peer counts, connected/disconnected ratios, and security flags for compliance reporting.
  7. errors catches unexpected task exceptions and posts a diagnostic notice to Slack.

What you get

  • Automated, continuous surveillance of zero-trust WireGuard network overlays without third-party monitoring agents.
  • Instant alerting when peer login sessions expire, preventing silent tunnel collapse between backend microservices, database clusters, and remote workers.
  • Automated detection of unapproved devices attempting to join the private mesh network.
  • Contextual Slack alerts containing exact machine hostnames, internal NetBird IPs, and diagnostic status.
  • Centralized audit tracking of network mesh health, device capacity, and route distribution.

Who it's for

  • Network Engineers and Security Administrators operating NetBird zero-trust overlay networks for internal corporate infrastructure.
  • Platform and Site Reliability Engineers managing WireGuard connectivity across multi-cloud and edge Kubernetes nodes.
  • DevSecOps teams enforcing compliance, peer approval gates, and device identity policies.

Why orchestrate this with Kestra

NetBird secures mission-critical interconnectivity between distributed microservices, databases, and remote environments. When a peer's authentication session expires or an edge subnet router goes offline, internal communication fails without traditional network monitoring picking it up immediately. Kestra delivers declarative, auditable orchestration with centralized secret management, robust HTTP probing, dynamic multi-state classification, and rapid multi-channel alerting.

Prerequisites

  • A running NetBird Management server instance with HTTP access from the Kestra worker.
  • A NetBird Personal Access Token (PAT) generated under User Profile > Access Tokens.
  • An incoming Slack webhook URL for alert delivery.

Secrets

  • NETBIRD_API_KEY: Personal Access Token or Service User token used for Token authentication against /api/ endpoints.
  • SLACK_WEBHOOK: Incoming Slack webhook URL used by alert_disconnected_peers_slack, alert_expired_logins_slack, alert_approval_pending_slack, alert_probe_failed_slack, alert_unreachable_slack, and the errors handler.

Quick start

  1. Generate an API token in the NetBird web console under User Profile > Access Tokens.
  2. Configure NETBIRD_API_KEY and SLACK_WEBHOOK as secrets within your Kestra namespace.
  3. Start a local NetBird test stack using Docker Compose:
    git clone https://github.com/netbirdio/netbird && cd netbird/infrastructure_files
    docker compose up -d
    
  4. Execute this flow manually in Kestra setting netbird_host: "localhost" or "netbird-management".
  5. The workflow inspects registered peers, validates active connections, classifies HEALTHY, and records audit outputs.
  6. Enable the every_4_hours trigger to automate continuous background monitoring.

How to extend

  • Add an automated remediation branch that calls PUT /api/peers/{id} to automatically approve known staging peers matching an authorized hostname pattern.
  • Integrate with PagerDuty or Opsgenie for LOGIN_EXPIRED_CRITICAL states affecting production database primary nodes.
  • Route separate alerts to Slack channels partitioned by peer user IDs or group tags (e.g. prod-servers vs developer-laptops).
  • Query /api/setup-keys to audit pre-shared key expiration and alert before automated CI enrollment keys expire.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.