container-metrics

command module
v0.0.0-...-7839030 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2018 License: MIT Imports: 11 Imported by: 0

README

Simple container metrics in Go

Collect Docker container and daemon statistics with Prometheus.

Motivation

I'm running a Home Lab on resource constrained devices, and wanted a simple metrics collector with low CPU, memory and disk requirements as an alternative to (the otherwise fantastic) Telegraf collector.

The end result is a small static binary, packaged as a Docker image, weighing only 3 MB (compressed).

Usage

The easiest way to get started is to use the Docker image available.

$ docker run -d --name container-metrics \
	-p 8080:8080 \
	-v /var/run/docker.sock:/var/run/docker.sock:ro \
	rycus86/container-metrics #[flags]

The application accepts the following flags:

  • -p or -port: HTTP port to listen on (default: 8080)
  • -i or -interval: Interval for reading metrics from the engine (default: 5s)
  • -t or -timeout: Timeout for calling endpoints on the engine (default: 30s)
  • -l or -labels: Labels to keep (comma separated, accepts regex)
  • -d or -debug: Enable debug messages
  • -v or -verbose: Enable verbose messages - assumes debug

You can also build the application with Go, currently tested with version 1.10, then simply run it on the host:

$ ./container-metrics -p 8080 -i 15s -l com.docker.compose.service,com.mycompany.custom

Metrics collected

Currently, the following Gauge metrics are exported.

Engine metrics
  • cntm_engine_num_images: Number of images
  • cntm_engine_num_containers: Number of containers
  • cntm_engine_num_containers_running: Number of running containers
  • cntm_engine_num_containers_stopped: Number of stopped containers
  • cntm_engine_num_containers_paused: Number of paused containers
Container CPU metrics
  • cntm_cpu_usage_total_seconds: Total CPU usage
  • cntm_cpu_usage_system_seconds: CPU usage in system mode
  • cntm_cpu_usage_user_seconds: CPU usage in user mode
  • cntm_cpu_usage_percent: Total CPU usage in percent
Container memory metrics
  • cntm_memory_total_bytes: Total memory available
  • cntm_memory_usage_bytes: Memory usage
  • cntm_memory_usage_percent: Memory usage in percent
Container I/O metrics
  • cntm_io_read_bytes: I/O bytes read
  • cntm_io_write_bytes: I/O bytes written
Container network metrics
  • cntm_net_rx_bytes: Network receive bytes
  • cntm_net_rx_packets: Network receive packets
  • cntm_net_rx_dropped: Network receive packets dropped
  • cntm_net_rx_errors: Network receive errors
  • cntm_net_tx_bytes: Network transmit bytes
  • cntm_net_tx_packets: Network transmit packets
  • cntm_net_tx_dropped: Network transmit packets dropped
  • cntm_net_tx_errors: Network transmit errors

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL