• Stars
    star
    157
  • Rank 233,851 (Top 5 %)
  • Language
    Go
  • License
    MIT License
  • Created about 9 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Collect docker container resource usage

Collect docker container resource usage

This is collectd plugin and docker image to collect resource usage from docker containers. Resource usage collected from docker stats API and sent to graphite installation. Containers can be added and removed on the fly, no need to restart collectd.

Configuration

This plugin treats containers as tasks that run as parts of apps.

Setting the App name of a Container

  • Set the label collectd_docker_app directly on the container
  • Set collectd_docker_app_label on the container that points to which actual label to use. e.g.collectd_docker_app_label=app_id will use app_id label on the container
  • Set environment variable COLLECTD_DOCKER_APP on the container
  • Set COLLECTD_DOCKER_APP_ENV on the container that points to which actual environment variable to use. For example, marathon sets MARATHON_APP_ID and by setting COLLECTD_DOCKER_APP_ENV to MARATHON_APP_ID you would get the marathon app id.

These keys can be changed globally by setting APP_LABEL_KEY or APP_ENV_KEY when running the collectd container. For example, if you set APP_ENV_KEY to MARATHON_APP_ID on the collectd container, then this will use MARATHON_APP_ID on all running containers.

Setting the Task name of a Container

  • Set the label collectd_docker_task directly on the container
  • Set collectd_docker_task_label on the container that points to which actual label to use. e.g.collectd_docker_task_label=task_id will use task_id label on the container
  • Set environment variable COLLECTD_DOCKER_TASK on the container
  • Set COLLECTD_DOCKER_TASK_ENV on the container that points to which actual environment variable to use. For example, mesos sets MESOS_TASK_ID and by setting COLLECTD_DOCKER_TASK_ENV to MESOS_TASK_ID you would get the mesos task id.

These keys can be changed globally by setting TASK_LABEL_KEY or TASK_ENV_KEY when running the collectd container. For example, if you set TASK_ENV_KEY to MESOS_TASK_ID on the collectd container, then this will use MESOS_TASK_ID on all running containers.

Limitations

  • If a container's app name cannot be identified, it will be not monitored. So if you are not seeing metrics, then it means you must check whether the app name is configured correctly.
  • The string <app>.<task> is limited by 63 characters. So it is also useful to set COLLECTD_DOCKER_APP_ENV_TRIM_PREFIX and/or COLLECTD_DOCKER_TASK_ENV_TRIM_PREFIX on the containers.

Reported metrics

Metric names look line this:

collectd.<host>.docker_stats.<app>.<task>.<type>.<metric>

Gauges:

  • CPU

    • cpu.user
    • cpu.system
    • cpu.total
  • Memory overview

    • memory.limit
    • memory.max
    • memory.usage
  • Memory breakdown

    • memory.active_anon
    • memory.active_file
    • memory.cache
    • memory.inactive_anon
    • memory.inactive_file
    • memory.mapped_file
    • memory.pg_fault
    • memory.pg_in
    • memory.pg_out
    • memory.rss
    • memory.rss_huge
    • memory.unevictable
    • memory.writeback
  • Network (bridge mode only)

    • net.rx_bytes
    • net.rx_dropped
    • net.rx_errors
    • net.rx_packets
    • net.tx_bytes
    • net.tx_dropped
    • net.tx_errors
    • net.tx_packets

Grafana dashboard

Grafana 2 dashboard is included.

screenshot

Graphite metrics extracted from the dashboard

  • CPU usage per second
aliasByNode(scaleToSeconds(nonNegativeDerivative(collectd.$host.docker_stats.$app.$task.gauge.cpu.total), 1), 3, 4, 1)
  • Memory limit
alias(averageSeries(collectd.$host.docker_stats.$app.$task.gauge.memory.limit), 'limit')
  • Memory usage
aliasByNode(collectd.$host.docker_stats.$app.$task.gauge.memory.usage, 3, 4, 1)
  • Network bytes per second tx
aliasByNode(scaleToSeconds(nonNegativeDerivative(collectd.$host.docker_stats.$app.$task.gauge.net.tx_bytes), 1), 3, 4, 1, 7)
  • Network bytes per second rx
aliasByNode(scaleToSeconds(nonNegativeDerivative(collectd.$host.docker_stats.$app.$task.gauge.net.rx_bytes), 1), 3, 4, 1, 7)
  • Network packets per second tx
aliasByNode(scaleToSeconds(nonNegativeDerivative(collectd.$host.docker_stats.$app.$task.gauge.net.tx_packets), 1), 3, 4, 1, 7)
  • Network packets per second rx
aliasByNode(scaleToSeconds(nonNegativeDerivative(collectd.$host.docker_stats.$app.$task.gauge.net.rx_packets), 1), 3, 4, 1, 7)

Running

Minimal command:

docker run -d -v /var/run/docker.sock:/var/run/docker.sock \
    -e GRAPHITE_HOST=<graphite host> -e COLLECTD_HOST=<colllectd host> \
    bobrik/collectd-docker

Environment variables

  • COLLECTD_HOST - host to use in metric name, defaults to MESOS_HOST if defined.
  • COLLECTD_INTERVAL - metric update interval in seconds, defaults to 10.
  • GRAPHITE_HOST - host where carbon is listening for data.
  • GRAPHITE_PORT - port where carbon is listening for data, 2003 by default.
  • GRAPHITE_PREFIX - prefix for metrics in graphite, collectd. by default.
  • APP_LABEL_KEY - container label to use for app name, collectd_docker_app by default.
  • APP_ENV_KEY - container environment variable to use for app name, COLLECTD_DOCKER_APP by default.
  • TASK_LABEL_KEY - container label to use for task name, collectd_docker_task by default.
  • TASK_ENV_KEY - container environment variable to use for task name, COLLECTD_DOCKER_TASK by default.

Note that this docker image is very minimal and libc inside does not support search directive in /etc/resolv.conf. You have to supply full hostname in GRAPHITE_HOST that can be resolved with nameserver.

License

MIT

More Repositories

1

pupergrep

Real-time grep for your logs right in your favorite modern browser made with Twitter Bootstrap.
JavaScript
184
star
2

mesos-compose

Mesos cluster in one command
Makefile
102
star
3

docker-image-cleaner

Clean up images you don't use in docker
Go
78
star
4

docker-curator

Tagged docker images for elasticsearch curator.
Dockerfile
70
star
5

zoidberg

Per-app service discovery for mesos and marathon with pluggable discovery mechanisms
Go
60
star
6

docker-collectd-mesos

Dockerized version of collectd-mesos to monitor your mesos cluster with graphite.
Smarty
56
star
7

ansible-grafana

Ansible role for grafana deployment
52
star
8

nginx_image_filter

Nginx image_filter module with ability to add placement for cropped images.
C
50
star
9

bay

p2p distribution for docker images
Go
34
star
10

collectd-mesos-tasks

Collect task resource usage in mesos
Python
33
star
11

marathoner

Service discovery for marathon
Go
26
star
12

zoidberg-nginx

Nginx with dynamic upstreams managed by zoidberg
Perl
25
star
13

ralph

Ralph is a service discovery for twemproxy on mesos
Go
24
star
14

time-container

Time capsule and apple share in docker.
Shell
22
star
15

docker-radosgw

Run your own distributed s3 storage in docker.
Nginx
17
star
16

locker

Lock server written in node.js
JavaScript
17
star
17

docker-kibana

kibana 4 in docker
Shell
14
star
18

ceph-collectd-graphite

Collect ceph metrics to graphite
Smarty
13
star
19

docker-syslog-ng

Minimal syslog-ng container (8.5mb) that listens for tcp and upd on port 514.
Shell
12
star
20

node-zabbix-agent-client

node.js client for zabbix-agent metrics
JavaScript
11
star
21

unfollowr

unfollowr is a bot for twitter to send notification if somebody stopped following you
Python
11
star
22

docker-minidlna

Minidlna image for docker
Shell
9
star
23

scrappy

Visualize Mesos cluster resource usage
Go
8
star
24

drone-ps3-controller

Control your ar.drone with ps3 controller.
JavaScript
7
star
25

zram-corruptor

Rust
7
star
26

docker-kibana4

kibana 4 in docker
Shell
7
star
27

buzzer

Dialer for Go that does retries on different IPs
Go
7
star
28

zoidbergtcp

TCP level load balancer managed by Zoidberg.
Go
6
star
29

docker-zookeeper

Customizable docker image for zookeeper.
Shell
6
star
30

docker-druid

Druid in docker, also on mesos.
Shell
6
star
31

mesos-slave

Mesos slave that can actually spawn docker containers
Shell
6
star
32

node-aligned-buffer

Create aligned buffers to make faster disk io with less iops
C++
6
star
33

docker-socat

Minimal docker image for Socat
5
star
34

ListWatcher

ListWatcher is your helper with the twitter lists you are in.
JavaScript
5
star
35

fb-js

Simple facebook api done right.
JavaScript
5
star
36

mesos-spark

Run spark jobs on mesos cluster
4
star
37

kasa_exporter

Prometheus exporter for TP-Link Kasa smart home products.
Rust
4
star
38

node-mess

Mess is Fisher–Yates shuffle algorithm implementation for node.js
JavaScript
4
star
39

ansible-kibana

Ansible role for kibana deployment
4
star
40

node-custom-debug

Launch debugger on your favorite port from your javascript code!
4
star
41

callisto

Callisto is my own Gentoo overlay
Shell
4
star
42

logstasher

Logstasher provides logstash-friendly logging interface for Go
Go
4
star
43

mesos-where-am-i

Simple http server that responds with own location on mesos
Go
3
star
44

node-locker

Full-featured async client for locker lock server
JavaScript
3
star
45

php-locker

PHP client for locker lock server
PHP
3
star
46

docker-logstash-kafka

Docker image for logstash with kafka plugin installed.
2
star
47

cloudflare-access-tab-auto-close

Google Chrome plugin to automatically close Cloudflare Access tabs on successful authentication
JavaScript
2
star
48

simple_redis

Node.js client for http://console.simpleredis.com/
JavaScript
2
star
49

twitter_bot

Create twitter bots that will eternally iterate over own followers.
JavaScript
2
star
50

node-require-bug

node.js bug with require
JavaScript
2
star
51

esreindexer

Makes reindexing of existing data in elasticsearch easy.
Go
2
star
52

http-replicator

Replicate HTTP requests to many hosts
Go
2
star
53

postads

Add post ads and manage their visibility flexible
PHP
2
star
54

heap.js

Heap data structure for node.js
JavaScript
1
star
55

gentoo-air-installer

Application to install and use Adobe AIR applications in Gentoo linux with Adobe AIR SDK
1
star
56

docker-logstash

Just tagged images of logstash for docker, nothing else.
1
star
57

rust-hyper-error-chain-weirness

Rust
1
star
58

bsuir

university labs etc.
C++
1
star
59

node-daemon-bug

JavaScript
1
star
60

docker-collectd-elasticsearch

Collectd for elasticsearch in docker container
Smarty
1
star
61

pylocker

Python client for locker lock server
Python
1
star
62

dmesg_heartbeat

Rust
1
star
63

node-heapdump-leak

Possible leak in node.js
JavaScript
1
star