Setup: Telegraf with the tail plugin and grok data format to parse a local log file that is appended to periodically.
I want to take a timestamp from the log file, convert it to UTC, and write that back into metric.time so that I can query and graph based on the timestamp that is inside the log file that telegraf is consuming. Below is my first attempt, but I get a type error when trying to set metric.time.
What format is metric.time in? Any suggestions on how to convert my UTC time data to one that I can write to metric.time?
year = str(metric.fields["year"])
month = str(metric.fields["month"])
day = str(metric.fields["day"])
hours = str(metric.fields.get("hours", "00"))
minutes = str(metric.fields.get("minutes", "00"))
seconds = str(metric.fields.get("seconds", "00"))
utc_timestamp = year + "-" + month + "-" + day + "T" + hours + ":" + minutes + ":" + seconds + "Z"
utc_parsed_time = time.parse_time(utc_timestamp)
metric.time = utc_parsed_time