Compare commits
2 commits
9d1452f160
...
f7fa2c7510
| Author | SHA1 | Date | |
|---|---|---|---|
| f7fa2c7510 | |||
| d7e2e1a512 |
14 changed files with 190 additions and 1 deletions
9
.env
Normal file
9
.env
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# InfluxDB
|
||||
INFLUXDB_URL=http://influxdb:8086
|
||||
INFLUXDB_ORG=Bischoffsheim
|
||||
INFLUXDB_BUCKET=Temperaturen
|
||||
INFLUXDB_TOKEN=1wml0Wzrno-VPHxw0N4CSJh42aTAE-zCCAnAj8BLY_YxsmexXO6_8o7i1HDdAPzDUndCCsejWKq9GJXeYFDhpQ==
|
||||
|
||||
# MQTT
|
||||
MQTT_USER=dein_user
|
||||
MQTT_PASS=dein_passwort
|
||||
16
README.md
16
README.md
|
|
@ -24,3 +24,19 @@ Stack
|
|||
<br><br>
|
||||
|
||||
<img src="pic/grafan.png" alt="mqtt" width="500"/>
|
||||
|
||||
>git clone https://git.hintergasse.de/hubobel/MTIG-Stack.git
|
||||
|
||||
>cd MTIG-Stack
|
||||
|
||||
>mkdir -p \
|
||||
> influxdb/{data,config} \
|
||||
> grafana/{data,config} \
|
||||
> mosquitto/{config,data,log} \
|
||||
> telegraf
|
||||
|
||||
>chown -R 472:472 grafana
|
||||
|
||||
>docker compose up -d --force-recreate
|
||||
|
||||
>docker ps
|
||||
|
|
|
|||
77
docker-compose.yml
Normal file
77
docker-compose.yml
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
version: "3.9"
|
||||
|
||||
services:
|
||||
influxdb:
|
||||
image: influxdb:latest
|
||||
container_name: influxdb
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8086:8086"
|
||||
volumes:
|
||||
- ./influxdb/data:/var/lib/influxdb2
|
||||
- ./influxdb/config:/etc/influxdb2
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-fsS", "http://localhost:8086/health"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
|
||||
grafana:
|
||||
image: grafana/grafana:latest
|
||||
container_name: grafana
|
||||
restart: unless-stopped
|
||||
user: "0"
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- ./grafana/data:/var/lib/grafana
|
||||
- ./grafana/config:/etc/grafana
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
depends_on:
|
||||
influxdb:
|
||||
condition: service_healthy
|
||||
|
||||
mqtt5:
|
||||
image: eclipse-mosquitto:latest
|
||||
container_name: mqtt5
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "1883:1883"
|
||||
- "9001:9001"
|
||||
volumes:
|
||||
- ./mosquitto/config:/mosquitto/config
|
||||
- ./mosquitto/data:/mosquitto/data
|
||||
- ./mosquitto/log:/mosquitto/log
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "mosquitto_pub -h localhost -p 1883 -t healthcheck/ping -n >/dev/null 2>&1 || exit 1"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 12
|
||||
|
||||
telegraf:
|
||||
image: telegraf:latest
|
||||
container_name: telegraf
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- ./telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro
|
||||
depends_on:
|
||||
mqtt5:
|
||||
condition: service_healthy
|
||||
influxdb:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pidof telegraf >/dev/null 2>&1 || exit 1"]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 12
|
||||
|
||||
networks:
|
||||
default:
|
||||
name: mqtt5-network
|
||||
external: true
|
||||
87
telegraf.conf
Normal file
87
telegraf.conf
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
# -------------------------------------------------------------------
|
||||
# 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 = ""
|
||||
hostname = ""
|
||||
omit_hostname = false
|
||||
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# OUTPUT: InfluxDB v2
|
||||
# -------------------------------------------------------------------
|
||||
[[outputs.influxdb_v2]]
|
||||
urls = ["${INFLUXDB_URL}"]
|
||||
token = "${INFLUXDB_TOKEN}"
|
||||
organization = "${INFLUXDB_ORG}"
|
||||
bucket = "${INFLUXDB_BUCKET}"
|
||||
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# INPUT 1: MQTT JSON (Temperaturen)
|
||||
# Topics: daten/status/+
|
||||
# -------------------------------------------------------------------
|
||||
[[inputs.mqtt_consumer]]
|
||||
servers = ["tcp://mqtt5:1883"]
|
||||
topics = ["daten/status/+"]
|
||||
|
||||
qos = 1
|
||||
persistent_session = true
|
||||
client_id = "telegraf_mqtt_temperature"
|
||||
|
||||
username = "${MQTT_USER}"
|
||||
password = "${MQTT_PASS}"
|
||||
|
||||
topic_tag = "topic"
|
||||
data_format = "json_v2"
|
||||
|
||||
[[inputs.mqtt_consumer.json_v2]]
|
||||
measurement_name = "temperature"
|
||||
|
||||
[[inputs.mqtt_consumer.json_v2.tag]]
|
||||
path = "id"
|
||||
rename = "sensor_id"
|
||||
type = "int"
|
||||
|
||||
[[inputs.mqtt_consumer.json_v2.field]]
|
||||
path = "tC"
|
||||
rename = "tC"
|
||||
type = "float"
|
||||
|
||||
[[inputs.mqtt_consumer.json_v2.field]]
|
||||
path = "tF"
|
||||
rename = "tF"
|
||||
type = "float"
|
||||
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# INPUT 2: MQTT Plain Values (Power)
|
||||
# Topics: daten/status/power/+
|
||||
# Payload: z. B. 396.963
|
||||
# -------------------------------------------------------------------
|
||||
[[inputs.mqtt_consumer]]
|
||||
servers = ["tcp://mqtt5:1883"]
|
||||
topics = ["daten/status/power/+"]
|
||||
|
||||
qos = 1
|
||||
persistent_session = true
|
||||
client_id = "telegraf_mqtt_power"
|
||||
|
||||
username = "${MQTT_USER}"
|
||||
password = "${MQTT_PASS}"
|
||||
|
||||
data_format = "value"
|
||||
data_type = "float"
|
||||
name_override = "power"
|
||||
|
||||
topic_tag = "topic"
|
||||
Loading…
Add table
Add a link
Reference in a new issue