-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtelegraf.conf
114 lines (95 loc) · 3.54 KB
/
telegraf.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
[global_tags]
user = "${INFLUXDB_USER}"
[agent]
interval = "3s"
omit_hostname = true
[[outputs.influxdb]]
urls = ["http://${INFLUX_URL}:8086"]
database = "${INFLUXDB_DB}"
skip_database_creation = true
username = "${INFLUXDB_USER}"
password = "${INFLUXDB_USER_PASSWORD}"
[[inputs.mqtt_consumer]]
## Broker URLs for the MQTT server or cluster. To connect to multiple
## clusters or standalone servers, use a seperate plugin instance.
## example: servers = ["tcp://localhost:1883"]
## servers = ["ssl://localhost:1883"]
## servers = ["ws://localhost:1883"]
servers = ["tcp://broker:1883"]
## Topics that will be subscribed to.
topics = [
"sensors/#",
]
## The message topic will be stored in a tag specified by this value. If set
## to the empty string no topic tag will be created.
topic_tag = "topic"
tagexclude = ["user"]
## QoS policy for messages
## 0 = at most once
## 1 = at least once
## 2 = exactly once
##
## When using a QoS of 1 or 2, you should enable persistent_session to allow
## resuming unacknowledged messages.
# qos = 0
## Connection timeout for initial connection in seconds
# connection_timeout = "30s"
## Maximum messages to read from the broker that have not been written by an
## output. For best throughput set based on the number of metrics within
## each message and the size of the output's metric_batch_size.
##
## For example, if each message from the queue contains 10 metrics and the
## output metric_batch_size is 1000, setting this to 100 will ensure that a
## full batch is collected and the write is triggered immediately without
## waiting until the next flush_interval.
# max_undelivered_messages = 1000
## Persistent session disables clearing of the client session on connection.
## In order for this option to work you must also set client_id to identify
## the client. To receive messages that arrived while the client is offline,
## also set the qos option to 1 or 2 and don't forget to also set the QoS when
## publishing.
# persistent_session = false
## If unset, a random client ID will be generated.
# client_id = ""
## Username and password to connect MQTT server.
# username = "telegraf"
# password = "metricsmetricsmetricsmetrics"
## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify = false
## Data format to consume.
## Each data format has its own unique set of configuration options, read
## more about them here:
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
# data_format = "influx"
data_format = "value"
data_type = "float"
# Transforms tag and field values with regex pattern
[[processors.regex]]
[[processors.regex.tags]]
key = "topic"
pattern = "^sensors\\/(.+)\\/(.+)\\/(.+)\\/(.+)$"
replacement = "${1}"
result_key = "group"
[[processors.regex.tags]]
key = "topic"
pattern = "^sensors\\/(.+)\\/(.+)\\/(.+)\\/(.+)$"
replacement = "${2}"
result_key = "client"
[[processors.regex.tags]]
key = "topic"
pattern = "^sensors\\/(.+)\\/(.+)\\/(.+)\\/(.+)$"
replacement = "${3}"
result_key = "sensor"
[[processors.regex.tags]]
key = "topic"
pattern = "^sensors\\/(.+)\\/(.+)\\/(.+)\\/(.+)$"
replacement = "${4}"
result_key = "unit"
[[processors.rename]]
[[processors.rename.replace]]
measurement = "mqtt_consumer"
dest = "sensors"