Created
January 21, 2022 19:40
-
-
Save lmasikl/00367efb9301c613bb542378c2b2a85c to your computer and use it in GitHub Desktop.
Telegraf config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[agent] | |
interval = "10s" | |
round_interval = true | |
metric_batch_size = 100 | |
metric_buffer_limit = 1000 | |
collection_jitter = "0s" | |
flush_interval = "10s" | |
flush_jitter = "0s" | |
precision = "0s" | |
[[inputs.mqtt_consumer]] | |
servers = ["tcp://127.0.0.1:1883"] | |
topics = [ | |
"house/sensors/data", | |
] | |
data_format = "json_v2" | |
[[inputs.file.json_v2]] | |
measurement_name = "value" | |
measurement_name_path = "value" | |
timestamp_path = "timestamp" | |
timestamp_format = "unix_us" | |
timestamp_timezone = "UTC" | |
[[inputs.file.json_v2.object]] | |
path = "" | |
[[inputs.file.json_v2.object.field]] | |
path = "sensorID" | |
rename = "device_id" | |
type = "string" | |
[[inputs.file.json_v2.object.field]] | |
path = "type" | |
type = "int" | |
[[outputs.sql]] | |
driver = "pgx" | |
data_source_name = "postgresql://postgres:postgres@127.0.0.1:5432/metrics" | |
timestamp_column = "timestamp" | |
table_template = "create table metrics | |
( | |
device_id varchar(17) not null, | |
timestamp timestamp not null, | |
value float not null, | |
type smallint not null | |
);" | |
table_exists_template = "SELECT 1 FROM metrics LIMIT 1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment