Public | Automated Build

Last pushed: 8 days ago
Short Description
Node exporter image that allows to expose the host hostname as a metric
Full Description

basi/node-exporter

It is a simple node-exporter image that adds the capability of obtain the host hostname and expose it as a value in the container.

How to run it

To launch it as a global service in a swarm cluster:

docker \
  service create --mode global \
  --name node-exporter \
  --mount type=bind,source=/proc,target=/host/proc \
  --mount type=bind,source=/sys,target=/host/sys \
  --mount type=bind,source=/,target=/rootfs \
  --mount type=bind,source=/etc/hostname,target=/etc/host_hostname \
  -e HOST_HOSTNAME=/etc/host_hostname \
  basi/node-exporter:latest \
  -collector.procfs /host/proc \
  -collector.sysfs /host/sys \
  -collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)" \
  --collector.textfile.directory /etc/node-exporter/ \
  --collectors.enabled="conntrack,diskstats,entropy,filefd,filesystem,loadavg,mdadm,meminfo,netdev,netstat,stat,textfile,time,vmstat,ipvs"

The important add over the official image is the bind mount of the host /etc/hosts file in a specific location in the service.
This mount is used by the container to obtain the hostname of the host where the service is running.

It can be useful to use this value in a swarm cluster when obtaining data in Prometheus, while it does not support
swarm mode natively.

Docker Pull Command
Owner
basi
Source Repository

Comments (2)
basi
3 months ago

Hi @titansmc,

You could take a look to this stack file where you can see how to do it:

https://github.com/bvis/docker-prometheus-swarm/blob/master/docker-compose.yml

After it you can import this dashboard I created some time ago that allows you to use the node hostname: https://grafana.com/dashboards/609

More info in the previous repo README.md file.

titansmc
3 months ago

Hi,
I would like to know how I can run your image to get the hostname instead of the ip, I've just replaced the oficial image by yours but nothing happened.... Here is my yaml:

Should I tell prometheus something?

Thanks.

  node-exporter:
    container_name: node-exporter
    image: basi/node-exporter
    volumes: 
      - /proc:/host/proc
      - /sys:/host/sys
      - /:/rootfs
      - /etc/hostname:/etc/host_hostname
    command:
      - '-collector.procfs=/host/proc'
      - '-collector.sysfs=/host/sysfs'
      - '-collector.filesystem.ignored-mount-points="^/(sys|proc|dev|host|etc)($$|/)"'
      - '-collector.textfile.directory=/etc/node-exporter/'
      - 'collectors.enabled="conntrack,diskstats,entropy,filefd,filesystem,loadavg,mdadm,meminfo,netdev,netstat,stat,textfile,time,vmstat,ipvs"'
      - 'collector.filesystem.ignored-mount-points="^/(sys|proc|dev|host|etc)($$|/)"'
    networks:
      - apps
    environment:
      HOST_HOSTNAME: /etc/host_hostname
    deploy:
      mode: global
      resources:
        limits:
          cpus: '0.10'
          memory: 32M
        reservations:
          cpus: '0.10'
          memory: 16M