Hi @jpowers ,
thanks for the quick reply. I have tested your solution, and it does improve things, but the issue does not seem to be completely fixed. In fact, by including “created_at” in the included_keys and changing timestamp_path to timestamp_key, the date, minutes and hours seem to be ok, but not seconds (and I am assuming milliseconds). Here is my new config:
[agent]
## Default data collection interval for all inputs
interval = "10s"
## Rounds collection interval to 'interval'
## ie, if interval="10s" then always collect on :00, :10, :20, etc.
round_interval = true
## Telegraf will cache metric_buffer_limit metrics for each output, and will
## flush this buffer on a successful write.
metric_buffer_limit = 10000
## Flush the buffer whenever full, regardless of flush_interval.
flush_buffer_when_full = true
## Collection jitter is used to jitter the collection by a random amount.
## Each plugin will sleep for a random time within jitter before collecting.
## This can be used to avoid many plugins querying things like sysfs at the
## same time, which can have a measurable effect on the system.
collection_jitter = "0s"
## Default flushing interval for all outputs. You shouldn't set this below
## interval. Maximum flush_interval will be flush_interval + flush_jitter
flush_interval = "10s"
## Jitter the flush interval by a random amount. This is primarily to avoid
## large write spikes for users running a large number of telegraf instances.
## ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s
flush_jitter = "0s"
## Run telegraf in debug mode
debug = true
## Run telegraf in quiet mode
quiet = false
## Override default hostname, if empty use os.Hostname()
hostname = ""
# Read formatted metrics from one or more HTTP endpoints
[[inputs.http_listener_v2]]
#name_override = "Test"
## Address and port to host HTTP listener on
service_address = ":8080"
## Path to listen to.
path = "/telegraf1"
## HTTP methods to accept.
methods = ["POST", "PUT"]
## maximum duration before timing out read of the request
# read_timeout = "10s"
## maximum duration before timing out write of the response
# write_timeout = "10s"
## Maximum allowed http request body size in bytes.
## 0 means to use the default of 524,288,000 bytes (500 mebibytes)
# max_body_size = "500MB"
## Set one or more allowed client CA certificate file names to
## enable mutually authenticated TLS connections
# tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"]
## Add service certificate and key
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Optional username and password to accept for HTTP basic authentication.
## You probably want to make sure you have TLS configured above for this.
basic_username = "test"
basic_password = "test"
## 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"
#Parse `stationBeanList` array only
#json_query = "data"
#Exclude url and host items from tags
#tagexclude = ["url", "host"]
#Set station metadata as tags
#tag_keys = [
# "meter_id",
# "meter_external_reference",
# "meter_external_id",
# "kwh",
# "kwh_delta",
# "grid_id",
# "grid_name",
# "meter_type_id",
# "meter_type_name"
#]
#Latest station information reported at `lastCommunicationTime`
#json_time_key = "created_at"
#Time is reported in Golang "reference time" format
#json_time_format = "2006-01-02T15:04:05Z07:00"
#Time is reported in UTC
#json_timezone = "UTC"
data_format = "json_v2"
[[inputs.http_listener_v2.json_v2]]
measurement_name = "steamaco_v2"
[[inputs.http_listener_v2.json_v2.object]]
path = "data"
timestamp_key = "created_at"
timestamp_format = "2006-01-02T15:04:05Z"
#timestamp_timezone = "UTC"
included_keys = [
"kwh",
"created_at"
]
#tags = [
# "meter_id",
# "meter_external_reference",
# "meter_external_id",
# "kwh",
# "kwh_delta",
# "grid_id",
# "grid_name",
# "meter_type_id",
# "meter_type_name"
#]
# [inputs.http.json_v2.object.renames]
# id = "meter_id"
# bit_harvester = "bit_harvester_id"
[[outputs.influxdb_v2]]
## Multiple URLs can be specified for a single cluster, only ONE of the
## urls will be written to each interval.
urls = ["${INFLUX_HOST}"]
token = "${INFLUX_TOKEN}"
bucket = "test"
And here is what I am sending:
{
"data" : [
{
"created_at" : "2021-12-07T15:19:02Z",
"meter_id" : 14,
"meter_external_reference": "1002848",
"meter_external_id" : 12,
"kwh" : 499,
"kwh_delta" : 13,
"core_external_reference" : "1231231",
"core_external_id" : 0,
"grid_id" : 52,
"grid_name" : "Ogheye",
"meter_type_id" : 2,
"meter_type_name" : "Essential Service"
}
]
}
This is the resulting time I am getting:
2021-12-07T15:19:10.000Z
I have opened an issue here