make telegraf work

This commit is contained in:
root on odroid 2022-12-17 13:51:08 +00:00
parent ac283a1f35
commit 039a8528ff
4 changed files with 38 additions and 18 deletions

View File

@ -118,14 +118,16 @@
# Configuration for sending metrics to InfluxDB
[[outputs.influxdb]]
#[[outputs.influxdb]]
## The full HTTP or UDP URL for your InfluxDB instance.
##
## Multiple URLs can be specified for a single cluster, only ONE of the
## urls will be written to each interval.
# urls = ["unix:///var/run/influxdb.sock"]
# urls = ["udp://127.0.0.1:8089"]
urls = ["http://influxdb:8086"]
# urls = ["http://influxdb:8086"]
# token = "I_J7ynLoO9yWcLx1YrB0QntORdJtdoDLHun9umnLs62MHK_31GniQ032edP6G01Q6We9j7UH0pFP-IG_-kPh7A=="
## The target database for metrics; will be created as needed.
## For UDP url endpoint database needs to be configured on server side.

View File

@ -37,17 +37,17 @@
hostname = ""
## If set to true, do no set the "host" tag in the telegraf agent.
omit_hostname = false
[[outputs.influxdb_v2]]
urls = ["http://influxdb:8086"]
# token = "2f3MkMT2_NFQXKJEt02jnm4zUiDTwObceXQ1Vth7Tv-7KxTLoLcBvlkKBrcVZMfPlYzNkV27-cu9crf7hbYpBA=="
token = "I_J7ynLoO9yWcLx1YrB0QntORdJtdoDLHun9umnLs62MHK_31GniQ032edP6G01Q6We9j7UH0pFP-IG_-kPh7A=="
## Organization is the name of the organization you wish to write to; must exist.
organization = "odroid"
## Destination bucket to write into.
bucket = "power/plug"
#[[outputs.influxdb_v2]]
# urls = ["http://influxdb:8086"]
#
## token = "2f3MkMT2_NFQXKJEt02jnm4zUiDTwObceXQ1Vth7Tv-7KxTLoLcBvlkKBrcVZMfPlYzNkV27-cu9crf7hbYpBA=="
# token = "I_J7ynLoO9yWcLx1YrB0QntORdJtdoDLHun9umnLs62MHK_31GniQ032edP6G01Q6We9j7UH0pFP-IG_-kPh7A=="
#
# ## Organization is the name of the organization you wish to write to; must exist.
# organization = "odroid"
#
# ## Destination bucket to write into.
# bucket = "power/plug"
# Read metrics from MQTT topic(s)
# https://github.com/influxdata/telegraf/blob/release-1.23/plugins/inputs/mqtt_consumer/README.md
@ -57,20 +57,32 @@
## example: servers = ["tcp://localhost:1883"]
## servers = ["ssl://localhost:1883"]
## servers = ["ws://localhost:1883"]
servers = ["tcp://mqtt:1883"]
servers = ["tcp://mqtt:8883"]
username = "telegraf"
password = "iaveexieyuz0Faewa7rieghoyaeseesh"
## Topics that will be subscribed to.
# "plug/#",
# "plug/desk/SENSOR",
topics = [
"plug/desk/SENSOR",
"zigbee2mqtt/devices/#",
]
# https://github.com/influxdata/telegraf/tree/master/plugins/parsers/json
data_format = "json"
name_override = "mqtt"
json_time_key = "Time"
json_time_format = "2006-01-02T15:04:05"
name_override = "temperature"
# json_time_key = "Time"
# json_time_format = "2006-01-02T15:04:05"
[[outputs.postgresql]]
# https://github.com/influxdata/telegraf/blob/release-1.24/plugins/outputs/postgresql/README.md
connection = "postgres://postgres:ood2eeZu@timescaledb"
tags_as_foreign_keys = true
create_templates = [
'''CREATE TABLE {{ .table }} ({{ .columns }})''',
'''SELECT create_hypertable({{ .table|quoteLiteral }}, 'time', chunk_time_interval => INTERVAL '1h')''',
'''ALTER TABLE {{ .table }} SET (timescaledb.compress, timescaledb.compress_segmentby = 'tag_id')''',
]

View File

@ -85,4 +85,10 @@ services:
- timescaledb
volumes:
- ./config/telegraf/:/etc/telegraf/
command:
- telegraf
- --config
- /etc/telegraf/telegraf.conf
- --config-directory
- /etc/telegraf/telegraf.d/