Skip to content

feat: add the swarm scheduler exporter - #313

Merged
dargmuesli merged 4 commits into
mainfrom
feat/monitoring/swarm-scheduler-exporter
Oct 22, 2026
Merged

dargmuesli merged 4 commits into
mainfrom
feat/monitoring/swarm-scheduler-exporter

Conversation

@dargmuesli

@dargmuesli dargmuesli commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

The metrics monitoring currently observes node and container level metrics only. This adds the cluster level view: which managers are available, and whether each service runs its desired number of tasks.

It deploys swarm-scheduler-exporter as a single replica on a manager node, where the docker daemon serves the cluster-wide service, node and event data the exporter reads. The exporter does not mount the docker socket itself: a pinned docker-socket-proxy in front of it forwards only the API sections the exporter needs, read-only, and both services run with all capabilities dropped, the exporter additionally on a read-only root filesystem, on an internal network nothing else can reach. The exporter's image ships the health check the stack relies on to replace a stuck exporter task.

The metrics monitoring gains a scrape job for the exporter. The new signals include swarm_cluster_nodes_by_state for manager availability, swarm_service_at_desired and swarm_service_running_replicas compared against swarm_service_schedulable_replicas for per service task gaps, and swarm_exporter_health for the exporter itself. The proxy makes the API read-only for the exporter, not least-privilege: the enabled sections still allow reading service and task logs, which can hold secrets.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Swarm deployment ignores the configured security_opt settings, so the promised no-new-privileges restriction needs supported enforcement or a corrected hardening claim.

1 open issue
What changed in this PR

Adds cluster-level monitoring to complement the existing node and container metrics, exposing Swarm node availability and service task counts to Prometheus.

Changes:

  • Adds a production scheduler exporter and a manager-node Docker socket proxy.
  • Restricts proxy access through an internal network and a read-only API allowlist.
  • Adds the Prometheus scrape target and updates the generated service reference.
File Description
src/​production/​swarm-scheduler-exporter/​compose.yaml Defines the exporter deployment and health check.
src/​production/​docker-socket-proxy/​configurations/​allowlist.env Defines permitted Docker API sections and blocks writes.
src/​production/​docker-socket-proxy/​compose.yaml Defines the socket proxy and internal overlay network.
src/​development/​prometheus/​configurations/​prometheus.yaml Adds the exporter scrape target.
artifacts/​docs/​README.md Documents both production services and analytics profile membership.

Review effort: Balanced

Comment thread src/production/docker-socket-proxy/compose.yaml Outdated
docker stack deploy silently ignores security_opt, so the no-new-privileges restriction was never applied to either service
@dargmuesli
dargmuesli marked this pull request as ready for review October 22, 2026 18:27
dargstack 4.20.0 resolves dot-relative env_file entries against the declaring compose's dir, so the stack root prefix workaround comes out. The compatibility floor rises to 4.20.0, so a node running an older CLI refuses the stack until it updates.
@dargmuesli
dargmuesli merged commit bcac72a into main Oct 22, 2026
8 checks passed
@dargmuesli
dargmuesli deleted the feat/monitoring/swarm-scheduler-exporter branch October 22, 2026 19:14
maevsi-bot pushed a commit that referenced this pull request Oct 22, 2026
## [21.4.0](21.3.4...21.4.0) (2026-10-22)

### Features

* add the swarm scheduler exporter ([#313](#313)) ([bcac72a](bcac72a))
@maevsi-bot

Copy link
Copy Markdown

🎉 This PR is included in version 21.4.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants