Skip to content

fix(apisix): match service key to container_name for stable Swarm DNS#509

Merged
wax911 merged 1 commit into
devfrom
fix/prometheus-apisix-scrape-target
Jun 26, 2026
Merged

fix(apisix): match service key to container_name for stable Swarm DNS#509
wax911 merged 1 commit into
devfrom
fix/prometheus-apisix-scrape-target

Conversation

@wax911

@wax911 wax911 commented Jun 26, 2026

Copy link
Copy Markdown
Member

Closes #503.

Changes the APISIX gateway service key from apisix_gateway (underscore) to apisix-gateway (hyphen) to match the existing container_name. The generator strips container_name from Swarm stacks, so the service key becomes the DNS-resolvable name on the shared traefik-public overlay network.

This preserves DNS stability: apisix-gateway:9091 resolves as the Prometheus scrape target in both Swarm and non-Swarm modes, avoiding the need to change configuration files for each deployment mode.

Changes:

  • apisix/api-gateway/docker-compose.yml: service key apisix_gatewayapisix-gateway
  • apisix/api-gateway/swarm.fragment.yml: matching key change
  • stacks/infrastructure.yml: regenerated

@wax911 wax911 changed the title fix(observability): update cross-stack Prometheus scrape targets for Swarm DNS fix(apisix): match service key to container_name for stable Swarm DNS Jun 26, 2026

@wax911 wax911 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This does not fully satisfy #503 as written.

Changing the service key from apisix_gateway to apisix-gateway preserves the old short name in the source Compose file, but it does not prove that apisix-gateway:9091 is resolvable from the observability stack after Swarm deployment. Docker stack deploy creates stack-scoped service names, and Docker's own examples show service names such as vossibility_nsqd after deployment: https://docs.docker.com/reference/cli/docker/stack/deploy/

The safer fixes are one of:

  1. Keep the existing service key and change Prometheus to the actual fully-qualified Swarm service name, e.g. infrastructure_apisix_gateway:9091.
  2. Add an explicit network alias for apisix-gateway on the shared traefik-public network and document that alias as the stable cross-stack scrape name.

The #505 handoff/deepwork note also records the aligned direction for #503 as a fully-qualified cross-stack target, not service-key renaming. This PR should either update the Prometheus target directly or add a deliberate alias with runtime validation evidence.

@wax911 wax911 force-pushed the fix/prometheus-apisix-scrape-target branch from d70f328 to 2cbde26 Compare June 26, 2026 22:45
Update APISIX and Traefik scrape targets to use Swarm-qualified names:
- apisix-gateway:9091 → infrastructure_apisix_gateway:9091
- traefik:8080 → infrastructure_traefik:8080

Docker stack deploy creates stack-scoped services; cross-stack DNS
resolution on the shared traefik-public overlay network requires the
<stack>_<service> prefix.  All same-stack targets (loki, tempo, otel)
remain unchanged.

Ref: #503
@wax911 wax911 force-pushed the fix/prometheus-apisix-scrape-target branch from 2cbde26 to a5984d0 Compare June 26, 2026 22:49
@wax911 wax911 merged commit 22cee04 into dev Jun 26, 2026
5 checks passed
@wax911 wax911 deleted the fix/prometheus-apisix-scrape-target branch June 26, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(observability): validate APISIX Prometheus scrape target after Swarm service renaming

1 participant