alexvaut / cStatsExporter

Windows Docker Stats exporter
Apache License 2.0
15 stars 9 forks source link

cStatsExporter

Windows Docker Stats exporter for Prometheus.io. compatible with Cadvisor metrics !

Cadvisor is doing a very good job on linux while on windows there isn't anything.

cStatsExporter is exposing Cadvisor metrics from windows containers depending on what the windows docker daemon makes available (the stats are not exactly the same between linux and windows).

cStatsExporter allows to reuse the same queries, grafana dashboards... that are working already with Cadvisor as a source.

It's tested on Docker Desktop 2.1.3.0 on Windows 10 and docker EE 19.03.02 for windows server 2019.

Run with docker

docker run --rm -p 9030:9030  -v \\.\pipe\docker_engine:\\.\pipe\docker_engine alexvaut/cstatsexporter:latest

Run with docker-compose

services:
  cstatsexporter:
    image: alexvaut/cstatsexporter:latest
    volumes:
      - source: '\\.\pipe\docker_engine'
        target: '\\.\pipe\docker_engine'
        type: npipe    

Deploy with docker-compose on a docker swarm cluster

services:
  cstatsexporter:
    image: alexvaut/cstatsexporter:latest
    volumes:
      - source: '\\.\pipe\docker_engine'
        target: '\\.\pipe\docker_engine'
        type: npipe
    deploy:
      mode: global
      placement:        
        constraints:
          - "node.platform.os == windows"              

Build the docker image

go build -o main.exe .
docker build -t cstatsexporter .

Configuration

In config.yaml:

scrapeIntervalSeconds: 5
port: 9030

All the configuration parameters can be setup through environment variables. For instance, for port, setup the environment variable PORT.

Metrics:

Accessible from http://localhost:9030/metrics when publishing port 9030.

# HELP container_last_seen Last time a container was seen by the exporter.
# TYPE container_last_seen gauge
# HELP container_cpu_system_seconds_total Cumulative system cpu time consumed in seconds.
# TYPE container_cpu_system_seconds_total counter
# HELP container_cpu_usage_seconds_total Cumulative cpu time consumed in seconds.
# TYPE container_cpu_usage_seconds_total counter
# HELP container_fs_reads_bytes_total Cumulative count of bytes read.
# TYPE container_fs_reads_bytes_total counter
# HELP container_fs_reads_total Cumulative count of reads completed.
# TYPE container_fs_reads_total counter
# HELP container_fs_writes_bytes_total Cumulative count of bytes written.
# TYPE container_fs_writes_bytes_total counter
# HELP container_fs_writes_total Cumulative count of writes completed.
# TYPE container_fs_writes_total counter
# HELP container_memory_usage_bytes Current memory usage in bytes, including all memory regardless of when it was accessed.
# TYPE container_memory_usage_bytes gauge
# HELP container_memory_working_set_bytes Current working set in bytes.
# TYPE container_memory_working_set_bytes gauge
# HELP container_network_receive_bytes_total Cumulative count of bytes received.
# TYPE container_network_receive_bytes_total counter
# HELP container_network_receive_errors_total Cumulative count of errors encountered while receiving.
# TYPE container_network_receive_errors_total counter
# HELP container_network_receive_packets_dropped_total Cumulative count of packets dropped while receiving.
# TYPE container_network_receive_packets_dropped_total counter
# HELP container_network_receive_packets_total Cumulative count of packets received.
# TYPE container_network_receive_packets_total counter
# HELP container_network_transmit_bytes_total Cumulative count of bytes transmitted.
# TYPE container_network_transmit_bytes_total counter
# HELP container_network_transmit_errors_total Cumulative count of errors encountered while transmitting.
# TYPE container_network_transmit_errors_total counter
# HELP container_network_transmit_packets_dropped_total Cumulative count of packets dropped while transmitting.
# TYPE container_network_transmit_packets_dropped_total counter
# HELP container_network_transmit_packets_total Cumulative count of packets transmitted.
# TYPE container_network_transmit_packets_total counter
# HELP container_spec_cpu_quota CPU quota of the container.
# TYPE container_spec_cpu_quota gauge
# HELP container_spec_memory_limit_bytes Memory limit for the container.
# TYPE container_spec_memory_limit_bytes gauge
# HELP machine_cpu_cores Number of CPU cores on the machine.
# TYPE machine_cpu_cores gauge
# HELP machine_memory_bytes Amount of memory installed on the machine.
# TYPE machine_memory_bytes gauge
# HELP node_meta Meta information on docker swarm nodes.
# TYPE node_meta gauge
# HELP host_meta Meta information on docker swarm container hosts.
# TYPE host_meta gauge

Metadata: