update telegraf config

This commit is contained in:
root on odroid 2023-04-13 12:48:33 +00:00
parent b1422d2569
commit d17b816a7b
2 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,77 @@
# Configuration for telegraf agent
[agent]
## Default data collection interval for all inputs
interval = "10s"
round_interval = true
metric_batch_size = 1000
## Maximum number of unwritten metrics per output. Increasing this value
## allows for longer periods of output downtime without dropping metrics at the
## cost of higher maximum memory usage.
metric_buffer_limit = 10000
## Collection jitter is used to jitter the collection by a random amount.
## Each plugin will sleep for a random time within jitter before collecting.
## This can be used to avoid many plugins querying things like sysfs at the
## same time, which can have a measurable effect on the system.
collection_jitter = "0s"
## Default flushing interval for all outputs. Maximum flush_interval will be
## flush_interval + flush_jitter
flush_interval = "10s"
## Jitter the flush interval by a random amount. This is primarily to avoid
## large write spikes for users running a large number of telegraf instances.
## ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s
flush_jitter = "0s"
## By default or when set to "0s", precision will be set to the same
## timestamp order as the collection interval, with the maximum being 1s.
## ie, when interval = "10s", precision will be "1s"
## when interval = "250ms", precision will be "1ms"
## Precision will NOT be used for service inputs. It is up to each individual
## service input to set the timestamp at the appropriate precision.
## Valid time units are "ns", "us" (or "µs"), "ms", "s".
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
# Read metrics from MQTT topic(s)
# https://github.com/influxdata/telegraf/blob/release-1.23/plugins/inputs/mqtt_consumer/README.md
[[inputs.mqtt_consumer]]
## Broker URLs for the MQTT server or cluster. To connect to multiple
## clusters or standalone servers, use a separate plugin instance.
## example: servers = ["tcp://localhost:1883"]
## servers = ["ssl://localhost:1883"]
## servers = ["ws://localhost:1883"]
servers = ["tcp://mqtt:8883"]
username = "telegraf"
password = "iaveexieyuz0Faewa7rieghoyaeseesh"
## Topics that will be subscribed to.
# "plug/#",
# "plug/desk/SENSOR",
topics = [
"plug/#",
]
# https://github.com/influxdata/telegraf/tree/master/plugins/parsers/json
data_format = "json"
name_override = "plug"
# 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')''',
]