Created
July 27, 2023 10:58
-
-
Save djlondon/dd8fb4acd8c91eacd16de9f9f7ffb2c0 to your computer and use it in GitHub Desktop.
influx-telegraf-compose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# extract buckets from conf file | |
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit ; pwd -P ) | |
conf_path="$parent_path"/outputs.conf | |
BUCKETS=$(grep -o -P '(?<=bucket \= ").*(?=")' "$conf_path") | |
export BUCKETS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
influxdb: | |
image: influxdb:latest | |
ports: | |
- "8086:8086" | |
networks: | |
- influx-network | |
volumes: | |
- db-data:/var/lib/influxdb2 | |
- ./scripts/influx:/docker-entrypoint-initdb.d | |
environment: | |
- DOCKER_INFLUXDB_INIT_MODE=setup | |
- DOCKER_INFLUXDB_INIT_USERNAME=admin | |
- DOCKER_INFLUXDB_INIT_PASSWORD=$PASSWORD | |
- DOCKER_INFLUXDB_INIT_ORG=demo | |
- DOCKER_INFLUXDB_INIT_BUCKET=demo | |
- DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=$TOKEN | |
- BUCKETS | |
telegraf: | |
image: "telegraf" | |
volumes: | |
- "./outputs.conf:/config/telegraf.d/outputs.conf" | |
networks: | |
- influx-network | |
depends_on: | |
- influxdb | |
environment: | |
- INFLUX_TOKEN=$TOKEN | |
- INFLUX_PORT=8086 | |
- INFLUX_HOST=influxdb | |
command: telegraf --config-directory /config/telegraf.d | |
networks: | |
influx-network: | |
volumes: | |
db-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /scripts/influx/init.sh | |
#!/bin/bash | |
set -e | |
mapfile -t buckets < <(echo "$BUCKETS") | |
for i in "${!buckets[@]}" | |
do | |
echo "$i" Creating bucket: "${buckets[$i]}" | |
influx bucket create -n "${buckets[$i]}" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[outputs.influxdb_v2]] | |
urls = ["http://$INFLUX_HOST:8086"] | |
token = "$INFLUX_TOKEN" | |
organization = "demo" | |
namepass = ["applog"] | |
bucket = "applog" | |
[[outputs.influxdb_v2]] | |
urls = ["http://$INFLUX_HOST:8086"] | |
token = "$INFLUX_TOKEN" | |
organization = "demo" | |
namepass = ["cpu", "disk", "mem", "system"] | |
bucket = "metrics" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment