# Manage EMQX metrics and logs with telegraf
# Install telegraf-operator and deploy telegraf
Refer to docs of telegraf-operator (opens new window)
# Configure emqx_prometheus
plugin
Refer to docs of install-emqx-prometheus-plugin
# Configure class.yaml
apiVersion: v1
kind: Secret
metadata:
name: telegraf-operator-classes
namespace: telegraf-operator
stringData:
...
# configuration about collecting metrics
metrics: |+
# please configure the ApiPort、EmqxApiUsername、EmqxApiPassword correctlly
[[inputs.http]]
urls = ["http://127.0.0.1:{{ApiPort}}/api/v4/emqx_prometheus"]
method = "GET"
timeout = "5s"
username = "{{EmqxApiUsername}}"
password = "{{EmqxApiPassword}}"
data_format = "json"
[inputs.http.tags]
collection = "metric"
...
logs: |+
[[inputs.tail]]
files = ["/opt/emqx/log/emqx.log.[1-9]"]
from_beginning = false
max_undelivered_lines = 64
character_encoding = "utf-8"
data_format = "grok"
grok_patterns = ['^%{TIMESTAMP_ISO8601:timestamp:ts-"2006-01-02T15:04:05.999999999-07:00"} \[%{LOGLEVEL:level}\] (?m)%{GREEDYDATA:messages}$']
[inputs.tail.tags]
collection = "log"
...
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
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
Please refer to the document to configure outputs plugins you choosed (opens new window)