Hello
Colleagues send sensor values from a lorawan gateway in mqtt topics.
With the help of telegraf, I consume the data on the mqtt topics. I choose to use the time value of the gateway to be able to graph with grafana. I convert it like this:
[[inputs.mqtt_consumer]]
...
...
...
# parse time
json_time_format = "2006-01-02T15:04:05.999999999Z"
json_time_key = "rxInfo_0_time"
json_timezone = "UTC"
But, it happens that the time value is null in some messages. Theoretically, at this moment, telegraf should write the data with the insertion timestamp … but it is not the case !
Does anyone have an idea of what the problem is?
Thanks
TH
Below is my complete config file:
###############################################################################
# OUTPUT PLUGINS #
###############################################################################
[[outputs.influxdb]]
urls = ["https://my.address.fr:8086"]
database = "sicpa_iot"
skip_database_creation = true
username = "user"
password = "password"
namepass = ["device_*"]
tls_cert = "/home/telegraf/ssl/telegraf_cert.crt"
tls_key = "/home/telegraf/ssl/telegraf.key"
tagexclude = ["adr","applicationID","applicationName","fCnt","fPort","gatewayID","loRaSNR","device_name","rssi","uplinkID","dr","frequency","insert_time"]
[[outputs.influxdb]]
urls = ["https://my.address.fr:8086"]
database = "sicpa_iot_with_meta"
skip_database_creation = true
username = "user"
password = "password"
namepass = ["device_*"]
tls_cert = "/home/telegraf/ssl/telegraf.crt"
tls_key = "/home/telegraf/ssl/telegraf.key"
###############################################################################
# PROCESSOR PLUGINS #
###############################################################################
[[processors.rename]]
order = 1
[[processors.rename.replace]]
field = "object_analogInput_4"
dest = "analogInput4"
[[processors.rename.replace]]
field = "object_analogInput_8"
dest = "analogInput8"
[[processors.rename.replace]]
field = "object_barometer_6"
dest = "pressure"
[[processors.rename.replace]]
field = "object_humiditySensor_7"
dest = "humidity"
[[processors.rename.replace]]
field = "object_temperatureSensor_2"
dest = "temperature"
[[processors.rename]]
order = 2
[[processors.rename.replace]]
tag = "deviceName"
dest = "device_id"
[[processors.rename.replace]]
tag = "devEUI"
dest = "device_eui"
[[processors.rename.replace]]
tag = "rxInfo_0_gatewayID"
dest = "gatewayID"
[[processors.rename.replace]]
tag = "rxInfo_0_location_altitude"
dest = "altitude"
[[processors.rename.replace]]
tag = "rxInfo_0_location_latitude"
dest = "latitude"
[[processors.rename.replace]]
tag = "rxInfo_0_location_longitude"
dest = "longitude"
[[processors.rename.replace]]
tag = "rxInfo_0_loRaSNR"
dest = "loRaSNR"
[[processors.rename.replace]]
tag = "rxInfo_0_name"
dest = "device_name"
[[processors.rename.replace]]
tag = "rxInfo_0_rssi"
dest = "rssi"
[[processors.rename.replace]]
tag = "rxInfo_0_uplinkID"
dest = "uplinkID"
[[processors.rename.replace]]
tag = "txInfo_0_dr"
dest = "dr"
[[processors.rename.replace]]
tag = "txInfo_0_frequency"
dest = "frequency"
[[processors.rename.replace]]
tag = "rxInfo_0_time"
dest = "gateway_time"
[[processors.template]]
order = 3
tag = "device"
template = 'device_{{ .Tag "device_id" }}'
[[processors.converter]]
order = 4
[processors.converter.tags]
measurement = ["device"]
[[processors.date]]
order = 5
tag_key = "gateway_time"
date_format = "2006-01-02T15:04:05.000000000Z"
date_offset = "0s"
timezone = "UTC"
###############################################################################
# AGGREGATOR PLUGINS #
###############################################################################
###############################################################################
# INPUT PLUGINS #
###############################################################################
###############################################################################
# SERVICE INPUT PLUGINS #
###############################################################################
[[inputs.mqtt_consumer]]
servers = ["ssl://my.address.fr:8883"]
topics = ["application/1/device/+/event/up"]
qos = 2
persistent_session = true
client_id = "telegraf"
username = "user"
password = "password"
data_format = "json"
tls_ca = "/home/telegraf/ssl/telegraf_ca.crt"
tls_cert = "/home/telegraf/ssl/telegraf_cert.crt"
tls_key = "/home/telegraf/ssl/telegraf.key"
tag_keys = [
"adr",
"applicationID",
"applicationName",
"deviceName",
"devEUI",
"fCnt",
"fPort",
"rxInfo_0_gatewayID",
"rxInfo_0_location_altitude",
"rxInfo_0_location_latitude",
"rxInfo_0_location_longitude",
"rxInfo_0_loRaSNR",
"rxInfo_0_name",
"rxInfo_0_rssi",
"rxInfo_0_time",
"rxInfo_0_uplinkID",
"txInfo_0_dr",
"txInfo_0_frequency"
]
fieldpass = [
"object_analogInput_4",
"object_analogInput_8",
"object_barometer_6",
"object_humiditySensor_7",
"object_temperatureSensor_2"
]
# parse time
json_time_format = "2006-01-02T15:04:05.999999999Z"
json_time_key = "rxInfo_0_time"
json_timezone = "UTC"