Skip to content

Feature Request: Support metric time type #18960

@zqm6133

Description

@zqm6133

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.

Metadata

Metadata

Assignees

Labels

feature requestRequests for new plugin and for new features to existing plugins

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions