Giter VIP home page Giter VIP logo

Comments (17)

MJGTwo avatar MJGTwo commented on July 17, 2024 10

@rljoia I was getting the same errors as @ioagel but I'll explain the config:

started with the error ERROR 502 /metrics] context canceled

  1. verify the address is 172.18.0.1
  2. make sure your firewall allows connections to the port 9323 from the virtual network (ufw allow from 172.18.0.0/16 to any port 9323 works for me)

This resulted in the error dial tcp 172.18.0.1:9323: getsockopt: connection refused.

My fix for this was to verify the json file located /etc/docker/daemon.json to be:

{
  "metrics-addr" : "0.0.0.0:9323",
  "experimental" : true
}

because I had set the address to be 127.0.0.1 per the instructions on Docker's website, but that was incorrect.

Also, because these are in global mode, make sure you do this .json file on every node of your cluster so it properly reads out the data.

from swarmprom.

ioagel avatar ioagel commented on July 17, 2024 1

Ubuntu 18.04.1 LTS - docker server version: 18.09.1

  • filtering docker through ufw

i opened port 9323 in firewall for docker_gwbridge net with command:

# ufw allow from 172.18.0.0/16 to any port 9323

Problem with dockerd-exporter fixed!

from swarmprom.

belfo avatar belfo commented on July 17, 2024

if you have firewalld enabled you need to open the port:

firewall-cmd --permanent --add-port=9323/tcp

from swarmprom.

binakot avatar binakot commented on July 17, 2024

if you have firewalld enabled you need to open the port:

firewall-cmd --permanent --add-port=9323/tcp

Nope, I haven't. Also other exportes work in the same network.
Btw I fixed it. I just change the dockerd-exporter service definition in https://github.com/stefanprodan/swarmprom/blob/master/docker-compose.yml#L24 to

  dockerd-exporter:
    image: stefanprodan/dockerd-exporter
    networks:
      - net    
    deploy:
      mode: global
      resources:
        limits:
          memory: 128M
        reservations:
          memory: 64M

If you can check it on your side, I will close the issue ;)

from swarmprom.

belfo avatar belfo commented on July 17, 2024

on my side it work with the caddy image, but the firweall was blocking access (as in the end docker expose this metrics already)
the caddy is just used for having an automated task detection and just fw to the docker daemon.
the dockerd-exported seems not so different it just do a socat.

from swarmprom.

binakot avatar binakot commented on July 17, 2024

I see. Okay, issue can be closed.

from swarmprom.

pascal08 avatar pascal08 commented on July 17, 2024

Same issue here.

Using stefanprodan/dockerd-exporter does not solve the issue in my case. I also find it hard to believe it has something to do with a firewall since the metrics endpoint is dead from the dockerd-exporter container itself. This call would not pass any firewall, would it?

selection_026

Log from the dockerd-exporter container:

2019/02/06 20:18:53 socat[43] N exit(1)


2019/02/06 20:18:53 socat[1] N childdied(): handling signal 17


2019/02/06 20:18:58 socat[1] N accepting connection from AF=2 10.0.4.185:45430 on AF=2 10.0.4.210:9323


2019/02/06 20:18:58 socat[1] N forked off child process 52


2019/02/06 20:18:58 socat[1] N listening on AF=2 0.0.0.0:9323


2019/02/06 20:18:58 socat[52] N opening connection to AF=2 172.18.0.1:9323


2019/02/06 20:19:07 socat[44] E connect(5, AF=2 172.18.0.1:9323, 16): Operation timed out


2019/02/06 20:19:07 socat[44] N exit(1)


2019/02/06 20:19:07 socat[1] N childdied(): handling signal 17


2019/02/06 20:19:13 socat[1] N accepting connection from AF=2 10.0.4.185:45448 on AF=2 10.0.4.210:9323


2019/02/06 20:19:13 socat[1] N forked off child process 53


2019/02/06 20:19:13 socat[1] N listening on AF=2 0.0.0.0:9323


2019/02/06 20:19:13 socat[53] N opening connection to AF=2 172.18.0.1:9323


2019/02/06 20:19:24 socat[45] E connect(5, AF=2 172.18.0.1:9323, 16): Operation timed out


2019/02/06 20:19:24 socat[45] N exit(1)

from swarmprom.

binakot avatar binakot commented on July 17, 2024

@pascal08 Yeah, this is some kind of magic.
It worked last time on my dev host, but doesn't work in prod :)

I think the problem is in networks, because I can get metrics on localhost from host system, but got error when try to get from prometheus container.

from swarmprom.

pascal08 avatar pascal08 commented on July 17, 2024

@ioagel At first I thought it had nothing to do with the firewall, but when I opened up the port from the Docker bridge network IP that error [ERROR 502 /metrics] context canceled changed into dial tcp 172.18.0.1:9323: getsockopt: connection refused. I got it to work when I also changed the metrics IP address to one reachable from my Prometheus container. Glad it works now. :)

from swarmprom.

binakot avatar binakot commented on July 17, 2024

Interesting... Will try smth like this next week too.

from swarmprom.

rljoia avatar rljoia commented on July 17, 2024

@ioagel At first I thought it had nothing to do with the firewall, but when I opened up the port from the Docker bridge network IP that error [ERROR 502 /metrics] context canceled changed into dial tcp 172.18.0.1:9323: getsockopt: connection refused. I got it to work when I also changed the metrics IP address to one reachable from my Prometheus container. Glad it works now. :)

@ioagel, how did you change the metrics IP address to one reachable from your Prometheus container? I don't have problems with firewall, because it's inactive. I'm using Linux Ubuntu. I'm getting the same Error 502.

from swarmprom.

tamvcspk avatar tamvcspk commented on July 17, 2024

I simply change:
environment: - DOCKER_GWBRIDGE_IP=172.18.0.1
into
environment: - DOCKER_GWBRIDGE_IP='172.18.0.1'
It listened to http://:9323 so I guess the environment variable is wrong
Sorry for my english

from swarmprom.

rdehouss avatar rdehouss commented on July 17, 2024

@rljoia I was getting the same errors as @ioagel but I'll explain the config:

started with the error ERROR 502 /metrics] context canceled

1. verify the address is 172.18.0.1

2. make sure your firewall allows connections to the port 9323 from the virtual network (`ufw allow from 172.18.0.0/16 to any port 9323` works for me)

This resulted in the error dial tcp 172.18.0.1:9323: getsockopt: connection refused.

My fix for this was to verify the json file located /etc/docker/daemon.json to be:

{
  "metrics-addr" : "0.0.0.0:9323",
  "experimental" : true
}

because I had set the address to be 127.0.0.1 per the instructions on Docker's website, but that was incorrect.

Also, because these are in global mode, make sure you do this .json file on every node of your cluster so it properly reads out the data.

This solution worked for me as well, thanks a lot!

from swarmprom.

mishop avatar mishop commented on July 17, 2024

Get docker ip addres
ip addr show docker0
Enter docker ip in prometherus.yml configuratin
static_configs: - targets: ['172.17.0.1:9323']
docker

from swarmprom.

binakot avatar binakot commented on July 17, 2024

Get docker ip addres
ip addr show docker0
Enter docker ip in prometherus.yml configuratin
static_configs: - targets: ['172.17.0.1:9323']
docker

Try to do it when you have 3 dedicated servers in a swarm, but not single localhost machine. Does it still work?

from swarmprom.

Secursus avatar Secursus commented on July 17, 2024

Same problem... Docker Swarm & Traefik.

Capture d’écran 2021-04-09 aΜ€ 16 54 58

configuration problem ?

from swarmprom.

binakot avatar binakot commented on July 17, 2024

After all I just removed dockerd-exporter from my setup πŸ˜†

from swarmprom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.