Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

discovery.dockerswarm unable to refresh target groups for "services" role #2014

Open
tomdaley92 opened this issue Oct 31, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@tomdaley92
Copy link

tomdaley92 commented Oct 31, 2024

What's wrong?

The discovery.dockerswarm component fails to refresh targets for just the "service" role with minimal configuration. The same discovery.dockerswarm component (as shown in config file below) is able to export targets successfully for the roles tasks and nodes on the same host/docker-daemon.

I have several stack/services running on this single node docker swarm manager. The error from the logs makes me think there is some variable "default" is missing when calling the downstream prometheus swarm service discovery under the hood.

Steps to reproduce

  1. Initialize a single node docker swarm manager on Ubuntu 20.04 LTS
  2. Write configuration file to /home/automation/applications/alloy/dev/config/config.alloy
  3. Deploy Alloy container as a swarm service using this docker-compose.yaml file with the docker stack deploy command. Since alloy is a service we should be able to get a target for itself, although you may want to deploy other random stacks/services on the node to ensure other service targets are available.
# docker-compose.yaml
version: '3.8'
services:

  daemon:
    image: grafana/alloy:v1.4.3
    hostname: 'example.host'
    volumes:
      - '/etc/localtime:/etc/localtime'
      - '/etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt'
      - '/home/automation/applications/alloy/dev/data/:/var/lib/alloy/data'
      - '/home/automation/applications/alloy/dev/config/config.alloy:/etc/alloy/config.alloy'
      - /var/run/docker.sock:/var/run/docker.sock
      - /:/hostfs/:ro
      - /sys:/hostfs/sys:ro
      - /proc:/hostfs/proc:ro
      - /var/log:/hostfs/var/log:ro
      - /run/udev/data:/hostfs/run/udev/data:ro
    ports:
      - '12345:12345'
    command:
      - run
      - --storage.path=/var/lib/alloy/data
      - --server.http.listen-addr=0.0.0.0:12345
      - /etc/alloy/config.alloy
    deploy:
      mode: global
      restart_policy:
        condition: any
    networks:
      - hostnet

networks:
  hostnet:
    name: host
    external: yes

System information

Ubuntu 20.04.6 LTS, Docker Engine 25.0.4

Software version

grafana/alloy:v1.4.3

Configuration

// WORKING
discovery.dockerswarm "node" { 
  host             = "unix:///var/run/docker.sock"
  refresh_interval = "60s"
  role             = "nodes"
}

// NOT WORKING
discovery.dockerswarm "service" { 
  host             = "unix:///var/run/docker.sock"
  refresh_interval = "15s"
  role             = "services"
}

 // WORKING
discovery.dockerswarm "task" {
  host             = "unix:///var/run/docker.sock"
  refresh_interval = "15s"
  role             = "tasks"
}

Logs

ts=2024-10-31T20:34:40.886224195Z level=error msg="Unable to refresh target groups" component_path=/ component_id=discovery.dockerswarm.service err="error while parsing address : invalid CIDR address: "
@tomdaley92 tomdaley92 added the bug Something isn't working label Oct 31, 2024
@tomdaley92 tomdaley92 changed the title discovery.dockerswarm "service" role Unable to refresh target groups discovery.dockerswarm "service" role unable to refresh target groups Oct 31, 2024
@tomdaley92 tomdaley92 changed the title discovery.dockerswarm "service" role unable to refresh target groups discovery.dockerswarm unable to refresh target groups for "services" role Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant