ajout docker plugin for telegraf
This commit is contained in:
parent
edf4f15d7c
commit
fad1d7ade9
@ -18,6 +18,11 @@ urls = ["http://SERVER-IP:8086"] # required
|
||||
|
||||
## Usage
|
||||
|
||||
- get docker UID for telegraf (agent only)
|
||||
```bash
|
||||
./get-docker-id.sh
|
||||
```
|
||||
|
||||
- start stack
|
||||
```bash
|
||||
docker-compose up -d
|
||||
@ -56,4 +61,4 @@ docker-compose logs -f
|
||||
# To do:
|
||||
|
||||
- [ ] script install
|
||||
- [ ] ajout Cadvisor + Prometheus
|
||||
- [ ] Prometheus + Alertmanager
|
||||
|
@ -4,22 +4,28 @@ services:
|
||||
|
||||
telegraf:
|
||||
image: telegraf:1.18-alpine
|
||||
# image: telegraf:latest #(for arm64)
|
||||
# image: telegraf:latest #(for amd64)
|
||||
container_name: telegraf
|
||||
restart: unless-stopped
|
||||
# for docker
|
||||
hostname: ${HOSTNAME}
|
||||
user: "telegraf:${DOCKER_GID}"
|
||||
volumes:
|
||||
- ./telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro
|
||||
- ./telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
ports:
|
||||
- '8125:8125/udp'
|
||||
|
||||
cadvisor:
|
||||
image: gcr.io/cadvisor/cadvisor
|
||||
# + image arm64
|
||||
container_name: cadvisor
|
||||
volumes:
|
||||
- /:/rootfs:ro
|
||||
- /var/run:/var/run:rw
|
||||
- /sys:/sys:ro
|
||||
- /var/lib/docker:/var/lib/docker:ro
|
||||
- /cgroup:/cgroup:ro
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- '8080:8080'
|
||||
# cadvisor:
|
||||
# image: gcr.io/cadvisor/cadvisor
|
||||
# # + image arm64
|
||||
# container_name: cadvisor
|
||||
# volumes:
|
||||
# - /:/rootfs:ro
|
||||
# - /var/run:/var/run:rw
|
||||
# - /sys:/sys:ro
|
||||
# - /var/lib/docker:/var/lib/docker:ro
|
||||
# - /cgroup:/cgroup:ro
|
||||
# restart: unless-stopped
|
||||
# ports:
|
||||
# - '8080:8080'
|
@ -12,6 +12,7 @@ services:
|
||||
volumes:
|
||||
- influxdb_data:/var/lib/influxdb
|
||||
- ./influxdb/imports:/imports
|
||||
- ./influxdb/config:/etc/influxdb/
|
||||
|
||||
# Dashboard
|
||||
grafana:
|
||||
@ -36,8 +37,12 @@ services:
|
||||
# image: telegraf:latest #(for amd64)
|
||||
container_name: telegraf
|
||||
restart: unless-stopped
|
||||
# for docker
|
||||
hostname: ${HOSTNAME}
|
||||
user: "telegraf:${DOCKER_GID}"
|
||||
volumes:
|
||||
- ./telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro
|
||||
- ./telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
depends_on:
|
||||
- influxdb
|
||||
links:
|
||||
@ -45,20 +50,21 @@ services:
|
||||
ports:
|
||||
- '8125:8125/udp'
|
||||
|
||||
# containers metrics
|
||||
cadvisor:
|
||||
image: gcr.io/cadvisor/cadvisor
|
||||
# + image arm64
|
||||
container_name: cadvisor
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- /:/rootfs:ro
|
||||
- /var/run:/var/run:rw
|
||||
- /sys:/sys:ro
|
||||
- /var/lib/docker:/var/lib/docker:ro
|
||||
- /cgroup:/cgroup:ro
|
||||
ports:
|
||||
- '8080:8080'
|
||||
# # containers metrics
|
||||
# cadvisor:
|
||||
# image: gcr.io/cadvisor/cadvisor
|
||||
# # + image arm64
|
||||
# container_name: cadvisor
|
||||
# restart: unless-stopped
|
||||
# volumes:
|
||||
# - /:/rootfs:ro
|
||||
# - /var/run:/var/run:rw
|
||||
# - /sys:/sys:ro
|
||||
# - /var/lib/docker:/var/lib/docker:ro
|
||||
# - /cgroup:/cgroup:ro
|
||||
# ports:
|
||||
# - '8080:8080'
|
||||
|
||||
# gather metrics and launch alerts
|
||||
prometheus:
|
||||
image: prom/prometheus:v2.17.1
|
||||
@ -101,3 +107,4 @@ services:
|
||||
volumes:
|
||||
grafana_data: {}
|
||||
influxdb_data: {}
|
||||
prometheus_data: {}
|
||||
|
9
get-docker-id.sh
Executable file
9
get-docker-id.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
DOCKER_GID=`stat -c '%g' /var/run/docker.sock`
|
||||
REPORT_HOSTNAME=`hostname`
|
||||
|
||||
echo "DOCKER_GID=${DOCKER_GID}" >> ${SCRIPT_DIR}/.env
|
||||
echo "HOSTNAME=${HOSTNAME}" >> ${SCRIPT_DIR}/.env
|
15
influxdb/influxdb.conf
Normal file
15
influxdb/influxdb.conf
Normal file
@ -0,0 +1,15 @@
|
||||
[meta]
|
||||
dir = "/var/lib/influxdb/meta"
|
||||
|
||||
[data]
|
||||
dir = "/var/lib/influxdb/data"
|
||||
engine = "tsm1"
|
||||
wal-dir = "/var/lib/influxdb/wal"
|
||||
|
||||
[http]
|
||||
enabled = true
|
||||
bind-address = ":8086"
|
||||
auth-enabled = true # Set to true
|
||||
log-enabled = true
|
||||
username = ""
|
||||
password = ""
|
@ -70,8 +70,8 @@
|
||||
## Write timeout (for the InfluxDB client), formatted as a string.
|
||||
## If not provided, will default to 5s. 0s means no timeout (not recommended).
|
||||
timeout = "5s"
|
||||
# username = "telegraf"
|
||||
# password = "metricsmetricsmetricsmetrics"
|
||||
username = ""
|
||||
password = ""
|
||||
# Set the user agent for HTTP POSTs (can be useful for log differentiation)
|
||||
# user_agent = "telegraf"
|
||||
# Set UDP payload size, defaults to InfluxDB UDP Client default (512 bytes)
|
||||
@ -212,3 +212,76 @@
|
||||
|
||||
[[inputs.linux_sysctl_fs]]
|
||||
# no configuration
|
||||
|
||||
# Read metrics about docker containers
|
||||
[[inputs.docker]]
|
||||
## Docker Endpoint
|
||||
## To use TCP, set endpoint = "tcp://[ip]:[port]"
|
||||
## To use environment variables (ie, docker-machine), set endpoint = "ENV"
|
||||
endpoint = "unix:///var/run/docker.sock"
|
||||
|
||||
## Set to true to collect Swarm metrics(desired_replicas, running_replicas)
|
||||
## Note: configure this in one of the manager nodes in a Swarm cluster.
|
||||
## configuring in multiple Swarm managers results in duplication of metrics.
|
||||
gather_services = false
|
||||
|
||||
## Only collect metrics for these containers. Values will be appended to
|
||||
## container_name_include.
|
||||
## Deprecated (1.4.0), use container_name_include
|
||||
#container_names = []
|
||||
|
||||
## Set the source tag for the metrics to the container ID hostname, eg first 12 chars
|
||||
source_tag = false
|
||||
|
||||
## Containers to include and exclude. Collect all if empty. Globs accepted.
|
||||
container_name_include = []
|
||||
container_name_exclude = ["prometheus", "cadvisor", "grafana", "telegraf", "influxdb", "pushgateway"]
|
||||
|
||||
## Container states to include and exclude. Globs accepted.
|
||||
## When empty only containers in the "running" state will be captured.
|
||||
## example: container_state_include = ["created", "restarting", "running", "removing", "paused", "exited", "dead"]
|
||||
## example: container_state_exclude = ["created", "restarting", "running", "removing", "paused", "exited", "dead"]
|
||||
# container_state_include = []
|
||||
# container_state_exclude = []
|
||||
|
||||
## Timeout for docker list, info, and stats commands
|
||||
timeout = "5s"
|
||||
|
||||
## Whether to report for each container per-device blkio (8:0, 8:1...),
|
||||
## network (eth0, eth1, ...) and cpu (cpu0, cpu1, ...) stats or not.
|
||||
## Usage of this setting is discouraged since it will be deprecated in favor of 'perdevice_include'.
|
||||
## Default value is 'true' for backwards compatibility, please set it to 'false' so that 'perdevice_include' setting
|
||||
## is honored.
|
||||
perdevice = true
|
||||
|
||||
## Specifies for which classes a per-device metric should be issued
|
||||
## Possible values are 'cpu' (cpu0, cpu1, ...), 'blkio' (8:0, 8:1, ...) and 'network' (eth0, eth1, ...)
|
||||
## Please note that this setting has no effect if 'perdevice' is set to 'true'
|
||||
# perdevice_include = ["cpu"]
|
||||
|
||||
## Whether to report for each container total blkio and network stats or not.
|
||||
## Usage of this setting is discouraged since it will be deprecated in favor of 'total_include'.
|
||||
## Default value is 'false' for backwards compatibility, please set it to 'true' so that 'total_include' setting
|
||||
## is honored.
|
||||
total = false
|
||||
|
||||
## Specifies for which classes a total metric should be issued. Total is an aggregated of the 'perdevice' values.
|
||||
## Possible values are 'cpu', 'blkio' and 'network'
|
||||
## Total 'cpu' is reported directly by Docker daemon, and 'network' and 'blkio' totals are aggregated by this plugin.
|
||||
## Please note that this setting has no effect if 'total' is set to 'false'
|
||||
# total_include = ["cpu", "blkio", "network"]
|
||||
|
||||
## docker labels to include and exclude as tags. Globs accepted.
|
||||
## Note that an empty array for both will include all labels as tags
|
||||
docker_label_include = []
|
||||
docker_label_exclude = []
|
||||
|
||||
## Which environment variables should we use as a tag
|
||||
#tag_env = ["JAVA_HOME", "HEAP_SIZE"]
|
||||
|
||||
## Optional TLS Config
|
||||
# tls_ca = "/etc/telegraf/ca.pem"
|
||||
# tls_cert = "/etc/telegraf/cert.pem"
|
||||
# tls_key = "/etc/telegraf/key.pem"
|
||||
## Use TLS but skip chain & host verification
|
||||
# insecure_skip_verify = false
|
||||
|
Loading…
x
Reference in New Issue
Block a user