Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pascalandy/437162cde548340a070f1f252c7bea82 to your computer and use it in GitHub Desktop.
Save pascalandy/437162cde548340a070f1f252c7bea82 to your computer and use it in GitHub Desktop.
Monitor Docker Swarm with the InfluxData TICK Stack
version: '3'
services:
# FRONT
chronograf:
# Full tag list: https://hub.docker.com/r/library/chronograf/tags/
image: chronograf
deploy:
replicas: 1
placement:
constraints:
- node.role == manager
restart_policy:
condition: on-failure
volumes:
# Mount for chronograf database
- chronograf-data:/var/lib/chronograf
ports:
# The WebUI for Chronograf is served on port 8888
- "8888:8888"
networks:
- influx
depends_on:
- kapacitor
- influxdb
# MIDDLE
kapacitor:
# Full tag list: https://hub.docker.com/r/library/kapacitor/tags/
image: kapacitor
deploy:
replicas: 1
placement:
constraints:
- node.role == manager
restart_policy:
condition: on-failure
volumes:
# Mount for kapacitor data directory
- kapacitor-data:/var/lib/kapacitor
# Mount for kapacitor configuration
- /etc/kapacitor/config:/etc/kapacitor
ports:
# The API for Kapacitor is served on port 9092
- "9092:9092"
networks:
- influx
depends_on:
- influxdb
# BACK
telegraf:
# Full tag list: https://hub.docker.com/r/library/telegraf/tags/
image: telegraf
deploy:
mode: global
restart_policy:
condition: on-failure
volumes:
# Mount for telegraf configuration
- /etc/telegraf:/etc/telegraf
# Mount for Docker API access
- /var/run/docker.sock:/var/run/docker.sock
networks:
- influx
depends_on:
- influxdb
# DATABASE
influxdb:
# Full tag list: https://hub.docker.com/r/library/influxdb/tags/
image: influxdb
deploy:
replicas: 1
placement:
constraints:
- node.role == manager
restart_policy:
condition: on-failure
volumes:
# Mount for influxdb data directory
- influxdb-data:/var/lib/influxdb
# Mount for influxdb configuration
- /etc/influxdb/config:/etc/influxdb
ports:
# The API for InfluxDB is served on port 8086
- "8086:8086"
networks:
- influx
networks:
influx:
volumes:
chronograf-data:
kapacitor-data:
influxdb-data:
@pascalandy
Copy link
Author

pascalandy commented Jul 1, 2017

Requirements

a docker swarm with n managers, p workers

1/ Prepare configuration files

on managers :
create /etc/kapacitor/config/kapacitor.conf from
https://github.com/influxdata/sandbox/blob/master/kapacitor/config/kapacitor.conf
create /etc/influxdb/config/influxdb.conf from
https://github.com/influxdata/sandbox/blob/master/influxdb/config/influxdb.conf
on managers & workers :
create /etc/telegraf/telegraf.conf from
https://github.com/influxdata/sandbox/blob/master/telegraf/telegraf.conf
In telegraf.conf replace $HOSTNAME with the name of the node (otherwise it will be <CONTAINER_ID>)

2/ Copy and Run the stack

on a manager :
copy the above docker-compose-tick.yml file
run command :

docker stack deploy --compose-file docker-compose-tick.yml tick

Advises
If you have more than one manager (and you should), as distributed filesystem is not yet available within docker, to avoid data loss upon restart, I advise you to :

In docker-compose-tick.yml set the constraint node to one manager by hostname :

constraints:
  - node.hostname == <ONE_MANAGER_NODE_HOSTNAME>

At the end of telegraf.conf, only keep inputs.influxdb configuration on the manager node where influxdb is constrained :

[[inputs.influxdb]]
  urls = ["http://influxdb:8086/debug/vars"]

3/ Set up

Go to Chronograf URL : http://<LAN_IP_OF_A_NODE>:8888
Homepage > Set Connection String to http://influxdb:8086

Menu ALERTING > Configure Kapacitor > set URL to http://kapacitor:9092
Caution

influxdb and kapacitor components are not clustered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment