├── .gitignore ├── Dockerfile ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.dll 4 | *.so 5 | *.dylib 6 | 7 | # Test binary, build with `go test -c` 8 | *.test 9 | 10 | # Output of the go coverage tool, specifically when used with LiteIDE 11 | *.out 12 | 13 | # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 14 | .glide/ 15 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | 3 | RUN apk add --no-cache socat 4 | 5 | ENV IN="172.18.0.1:9323" \ 6 | OUT="9323" 7 | 8 | ENTRYPOINT socat -d -d TCP-L:$OUT,fork TCP:$IN 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Stefan Prodan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dockerd-exporter 2 | 3 | [![Docker Image](https://images.microbadger.com/badges/image/stefanprodan/dockerd-exporter.svg)](https://hub.docker.com/r/stefanprodan/dockerd-exporter/) 4 | 5 | Prometheus Docker daemon metrics exporter 6 | 7 | ### Docker Engine 8 | 9 | Create or edit /etc/systemd/system/docker.service.d/docker.conf, 10 | enable the experimental feature and set the metrics address to 0.0.0.0: 11 | 12 | ``` 13 | [Service] 14 | ExecStart= 15 | ExecStart=/usr/bin/dockerd -H fd:// \ 16 | --storage-driver=overlay2 \ 17 | --dns 8.8.4.4 --dns 8.8.8.8 \ 18 | --log-driver json-file \ 19 | --log-opt max-size=50m --log-opt max-file=10 \ 20 | --experimental=true \ 21 | --metrics-addr 0.0.0.0:9323 22 | ``` 23 | 24 | Check if the docker_gwbridge ip address is `172.18.0.1`: 25 | 26 | ```bash 27 | docker run --rm --net host alpine ip -o addr show docker_gwbridge 28 | ``` 29 | 30 | ### Docker Swarm 31 | 32 | Create an overlay network: 33 | 34 | ```sh 35 | docker network create \ 36 | --driver overlay \ 37 | netmon 38 | ``` 39 | 40 | Create dockerd-exporter global service (replace 172.18.0.1 with your docker_gwbridge address): 41 | 42 | ```sh 43 | docker service create -d \ 44 | --mode global \ 45 | --name dockerd-exporter \ 46 | --network netmon \ 47 | -e IN="172.18.0.1:9323" \ 48 | -e OUT="9323" \ 49 | stefanprodan/dockerd-exporter:latest 50 | ``` 51 | 52 | Configure Prometheus to scrape the dockerd-exporter instances: 53 | 54 | ``` 55 | scrape_configs: 56 | - job_name: 'dockerd-exporter' 57 | dns_sd_configs: 58 | - names: 59 | - 'tasks.dockerd-exporter' 60 | type: 'A' 61 | port: 9323 62 | ``` 63 | 64 | Run Prometheus on the same overlay network as dockerd-exporter. 65 | --------------------------------------------------------------------------------