Categorygithub.com/davidborzek/docker-exporter
modulepackage
0.3.0
Repository: https://github.com/davidborzek/docker-exporter.git
Documentation: pkg.go.dev

# README

docker exporter

Go Report Card

Simple and lightweight Prometheus exporter for docker container metrics.

Prerequisites

Installation

Using Docker

The exporter is available as a Docker image. You can run it using the following example:

$ docker run \
  -u root \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -p 8080:8080 \
  ghcr.io/davidborzek/docker-exporter:latest

Note: To run Docker Exporter, you'll need to mount the Docker socket from your host system. This operation necessitates root privileges or the user running the command to be a member of the Docker group. It's important to note that mounting the Docker socket grants the container unrestricted access to Docker. For a more secure approach, consider utilizing the Docker Socket Proxy, which is further explained below for additional information.

Running with docker-socket-proxy

$ docker run \
  -e "DOCKER_HOST=tcp://localhost:2375" \
  -p 8080:8080 \
  ghcr.io/davidborzek/docker-exporter:latest

Note: the docker-socket-proxy needs to have container access enabled. (CONTAINERS=1)

Prometheus config

Once you have configured the exporter, update your prometheus.yml scrape config:

scrape_configs:
  - job_name: "docker_exporter"
    static_configs:
      - targets: ["localhost:8080"]

Config

FlagDescriptionDefault ValueEnvironment Variable
--portThe port of docker exporter server.8080DOCKER_EXPORTER_PORT
--hostThe host of docker exporter server.DOCKER_EXPORTER_HOST
--auth-tokenOptional auth token for the docker exporter server. If no token is set authentication is disabled.DOCKER_EXPORTER_AUTH_TOKEN
--log-levelLog level for the exporter.infoDOCKER_EXPORTER_LOG_LEVEL
--ignore-labelSet the label name for ignoring docker containers. (See Ignoring Containers)docker-exporter.ignoreDOCKER_EXPORTER_IGNORE_LABEL

Exported Metrics

Metric NameDescriptionLabels
docker_container_block_io_read_bytesBlock I/O read bytes totalname
docker_container_block_io_write_bytesBlock I/O write bytes totalname
docker_container_cpu_usage_percentageCPU usage in percentagename
docker_container_infoInfos about the containername, image_name, image
docker_container_memory_total_bytesTotal memory in bytesname
docker_container_memory_usage_bytesMemory usage in bytesname
docker_container_memory_usage_percentageMemory usage in percentagename
docker_container_network_rx_bytesNetwork received bytes totalname, network
docker_container_network_rx_dropped_packetsNetwork dropped packets totalname, network
docker_container_network_rx_errorsNetwork received errorsname, network
docker_container_network_rx_packetsNetwork received packets totalname, network
docker_container_network_tx_bytesNetwork sent bytes totalname, network
docker_container_network_tx_dropped_packetsNetwork dropped packets totalname, network
docker_container_network_tx_errorsNetwork sent errorsname, network
docker_container_network_tx_packetsNetwork sent packets totalname, network
docker_container_pids_currentCurrent number of pidsname
docker_container_stateState of the containername, state
docker_container_uptimeUptime of the container in secondsname
docker_exporter_scrape_durationDuration of the scrape in seconds
docker_exporter_scrape_errorsNumber of scrape errors

Ignoring Containers

You can ignore containers by setting the label docker-exporter.ignore on the container. The label name can be configured with the --ignore-label flag.

services:
  nginx:
    image: nginx
    labels:
      docker-exporter.ignore: "true"

# Packages

No description provided by the author