Hello all. I’ve been scouring for a solution for several days now with no luck. I know the power of Telegraf but I have config paralysis now. Please help…
I am consuming a REST api that returns JSON data like this:
{
"Rsp": {
"Status": "Partial",
"Result": [
{
"Door": "US_CA_SJC8_DDO_F01_E-MAIN-ENT-EXT_INT_PRM.DR",
"First name": "Abe",
"Last name": "Froman",
"Email address": "sausageking@chicago.com",
"Event timestamp": "2025-01-16T17:56:16+00:00",
"Time zone": "(UTC-08:00) Pacific Time (US & Canada)"
},
{
"Door": "US_NY_JFK21_DDO_F08_PARKVIEW_INT_PRM.DR",
"First name": "Ed",
"Last name": "Rooney",
"Email address": "e.rooney@chicagohs.edu",
"Event timestamp": "2025-01-16T17:56:20+00:00",
"Time zone": "(UTC-05:00) Eastern Time (US & Canada)"
}
]
}
}
As you can see from the above the “Event timestamp” is a non standard time format that does NOT adhere to RFC3339 because it contains the “+00:00” where a Z should be.
I am using the http input with json_v2 like so:
[[inputs.http]]
## One or more URLs from which to read formatted metrics
urls = [
"https://someurl.com"
]
## HTTP method
method = "POST"
## Optional HTTP headers
headers = {"Cache-Control" = "no-cache", "Accept" = "text/json"}
## Optional HTTP Basic Auth Credentials
username = "secret"
password = "passcode"
insecure_skip_verify = true
## Amount of time allowed to complete the HTTP request
timeout = "90s"
## List of success status codes
success_status_codes = [200]
# Overwrite measurement name from default `http` to `citibikenyc`
name_override = "access_granted"
# Exclude url and host items from tags
tagexclude = ["url", "host"]
## Data format to consume.
## Each data format has its own unique set of configuration options, read
## more about them here:
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
data_format = "json_v2"
# Add a subtable to use the `json_v2` parser
[[inputs.http.json_v2]]
# Add an object subtable for to parse a JSON object
[[inputs.http.json_v2.object]]
path = "Rsp.Result"
# tags = ["Door","First name", "Last name", "Email address", "Time zone"]
tags = ["Door"]
timestamp_key = "Event timestamp"
# Time is reported in unix timestamp format
timestamp_format = "2006-01-02T15:04:05+00:00"
# timestamp_format = "RFC3339"
#timestamp_timezone = "UTC"
#disable_prepend_keys = true
I have tried:
[[processors.date]]
[[processors.regex]]
[[processors.timestamp]]
[[processors.converter]]
But have NOT been successful with any of them.
What is the simplest way to replace the “+” with a “Z” thus conforming to RFC3339 per this while still using it as a timestamp.