Skip to content

Instantly share code, notes, and snippets.

@lmasikl
Created January 21, 2022 19:40
Show Gist options
  • Save lmasikl/00367efb9301c613bb542378c2b2a85c to your computer and use it in GitHub Desktop.
Save lmasikl/00367efb9301c613bb542378c2b2a85c to your computer and use it in GitHub Desktop.
Telegraf config
[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