elastic/beats

docker autodiscover hints & networks

Open

#8498 aperta il 29 set 2018

Vedi su GitHub
 (9 commenti) (3 reazioni) (1 assegnatario)Go (3451 fork)batch import
Team:Cloudnative-MonitoringTeam:Integrationscontainersenhancementgood first issue

Metriche repository

Star
 (9173 star)
Metriche merge PR
 (Merge medio 5g 14h) (353 PR mergiate in 30 g)

Descrizione

Hi,

I'm configuring my servers monitoring with metricbeat, and I have an issue: I'm using docker autodiscover hints to find containers to monitor, eg:


  traefik:
    image: traefik:1.6.6
    # some config unrelated to this issue skipped
    deploy:
      mode: global
    labels:
      co.elastic.metrics/module: traefik
      co.elastic.metrics/metricsets: health
      co.elastic.metrics/hosts: '$${data.host}:8080'
      co.elastic.metrics/period: 10s
    networks:
      - web
      - default
      - metrics

networks:
  default:
  web:
    name: web
    driver: overlay
    attachable: true
  metrics:
    name: metrics
    external: true

here metrics is the network metricbeat is attached to, the traefik containers has multiple IPs for the multiple networks it's attached to, so ${data.host} get one of the IP (first? random?) but it's not the correct one. that means metricbeat is not able to query the traefik API, and I have this message instead of the metrics in the metricbeat index:

"failed to sample health: error making http request: Get http://10.0.24.31:8080/health: dial tcp 10.0.24.31:8080: connect: network is unreachable"

10.0.24 is the IP of traefik but for another container

traefik itself deals with this problem when using autodiscover by adding a label to specify wich network to use (in the exemple I have above, I use the "web" network to let traefik communicate with other containers so I add the label traefik.docker.network: web)

I think a similar label should be added to metricbeat, here I would like to add co.elastic.metrics/network: metrics

an alternative would be to add all IPs inside the autodiscover event data, so that I could use this label instead for the hosts: co.elastic.metrics/hosts: '${data.networks.metrics.ip}:8080'

Guida contributor