From 9e875c455dba71b036d2425b4e9387fa826d3572 Mon Sep 17 00:00:00 2001 From: hubobel Date: Sat, 10 Jan 2026 11:12:53 +0100 Subject: [PATCH] telegraf added --- telegraf/.env | 2 ++ telegraf/docker-compose.yml | 13 +++++++ telegraf/telegraf.conf | 67 +++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 telegraf/.env create mode 100644 telegraf/docker-compose.yml create mode 100644 telegraf/telegraf.conf diff --git a/telegraf/.env b/telegraf/.env new file mode 100644 index 0000000..2db31bb --- /dev/null +++ b/telegraf/.env @@ -0,0 +1,2 @@ +MQTT_USERNAME=mqtt_user +MQTT_PASSWORD=mqtt_pw \ No newline at end of file diff --git a/telegraf/docker-compose.yml b/telegraf/docker-compose.yml new file mode 100644 index 0000000..07ea4d7 --- /dev/null +++ b/telegraf/docker-compose.yml @@ -0,0 +1,13 @@ +services: + telegraf: + image: docker.io/telegraf:latest + container_name: telegraf + environment: + - MQTT_USERNAME=${MQTT_USERNAME} + - MQTT_PASSWORD=${MQTT_PASSWORD} + volumes: + - ./telegraf.conf:/etc/telegraf/telegraf.conf:ro +networks: + default: + name: mqtt5-network + external: true \ No newline at end of file diff --git a/telegraf/telegraf.conf b/telegraf/telegraf.conf new file mode 100644 index 0000000..3f56de3 --- /dev/null +++ b/telegraf/telegraf.conf @@ -0,0 +1,67 @@ +# 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 = "SPIryLp_2qM35A-GDTE3gEoCtZqAPaiDxPwWgIUy6JQ4uU4ctBbMZDsSD3D7kf5FokBQE4F2mmyx9pvOU7ryTg==" + + ## Organization is the name of the organization you wish to write to; must exist. + organization = "Bischoffsheim" + + ## Destination bucket to write into. + bucket = "Bischoffsheim" + +[[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" \ No newline at end of file