🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

github.com/davidborzek/docker-exporter

Package Overview
Dependencies
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/davidborzek/docker-exporter

Source
Go Modules
Version
v0.3.0
Version published
Created
Source

docker exporter

Go Report Card

Simple and lightweight Prometheus exporter for docker container metrics.

Prerequisites

  • Go

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"

FAQs

Package last updated on 04 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts