influxdata / influxdata/telegraf
Feature Request: Support custom time formats for fields in Postgres output
- Dominant language
- Go
- Stars
- 17.8k
- Forks
- 5.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 161
Description
### Use Case
I need to write multiple timestamp columns (e.g., `created_at`, `updated_at`, `event_time`)
to a PostgreSQL table with `timestamptz` type. Currently, Telegraf fields only support
`string`, `float64`, `int64`, `uint64`, and `bool`. There is no way to pass a native
`time.Time` value through the metric pipeline so that outputs like `outputs.postgresql`
can create `timestamp with time zone` columns for data fields (not just the metric's
`time` column).
### Expected behavior
Allow `time.Time` as a valid field value type in `telegraf.Metric`, and have
`outputs.postgresql` (and potentially other SQL outputs) map it to `timestamptz`
or `timestamp` column types.
### Actual behavior
Fields with timestamp data must be stored as strings or integers, which requires:
1. Either pre-processing outside Telegraf to convert before insertion
2. Or maintaining a custom fork with a processor plugin that converts string/numeric
fields to `time.Time` and patching the metric core + postgresql output
### Additional info
This is distinct from the existing `timestamp_column_name` option in `outputs.postgresql`,
which only controls the type of the metric's `time` column. The need here is for
**arbitrary fields** to carry timestamp values.
Contributor guide
Assessment
This issue has not been assessed yet.