This commit is contained in:
hubobel 2026-01-12 16:30:16 +01:00
parent 9b100825e7
commit d7e2e1a512
14 changed files with 190 additions and 1 deletions

2
Pool/telegraf/.env Normal file
View file

@ -0,0 +1,2 @@
MQTT_USERNAME=mqtt_user
MQTT_PASSWORD=mqtt_pw

View file

@ -0,0 +1,19 @@
services:
telegraf:
image: docker.io/telegraf:latest
container_name: telegraf
restart: unless-stopped
healthcheck:
test: [ "CMD-SHELL", "pidof telegraf >/dev/null 2>&1 || exit 1" ]
interval: 10s
timeout: 3s
retries: 12
environment:
- MQTT_USERNAME=${MQTT_USERNAME}
- MQTT_PASSWORD=${MQTT_PASSWORD}
volumes:
- ./telegraf.conf:/etc/telegraf/telegraf.conf:ro
networks:
default:
name: mqtt5-network
external: true

View file

@ -0,0 +1,79 @@
# Configuration for telegraf agent
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = ""
## Override default hostname, if empty use os.Hostname()
hostname = ""
## If set to true, do no set the "host" tag in the telegraf agent.
omit_hostname = false
[[outputs.influxdb_v2]]
## The URLs of the InfluxDB cluster nodes.
urls = ["http://influx-influxdb-1:8086"]
## Token for authentication.
token = "1wml0Wzrno-VPHxw0N4CSJh42aTAE-zCCAnAj8BLY_YxsmexXO6_8o7i1HDdAPzDUndCCsejWKq9GJXeYFDhpQ=="
## Organization is the name of the organization you wish to write to; must exist.
organization = "Bischoffsheim"
## Destination bucket to write into.
bucket = "Temperaturen"
[[inputs.mqtt_consumer]]
servers = ["tcp://mqtt5:1883"]
topics = ["daten/status/+"] # deckt "daten/status/temperature:100" ab
qos = 1
persistent_session = true
client_id = "telegraf_mqtt_influx3"
username = "${MQTT_USERNAME}"
password = "${MQTT_PASSWORD}"
topic_tag = "topic"
data_format = "json_v2"
[[inputs.mqtt_consumer.json_v2]]
measurement_name = "temperature"
# id als Tag (saubere Gruppierung / Filter in Influx)
[[inputs.mqtt_consumer.json_v2.tag]]
path = "id"
rename = "sensor_id"
type = "int"
# Felder
[[inputs.mqtt_consumer.json_v2.field]]
path = "tC"
rename = "tC"
type = "float"
[[inputs.mqtt_consumer.json_v2.field]]
path = "tF"
rename = "tF"
type = "float"
[[inputs.mqtt_consumer]]
servers = ["tcp://mqtt5:1883"]
topics = ["daten/status/power/+"]
username = "${MQTT_USERNAME}"
password = "${MQTT_PASSWORD}"
data_format = "value"
data_type = "float"
name_override = "power"
topic_tag = "topic"