Skip to content

Consider a Timestamp() or similar Converter in OTTL #36870

Closed
@bixu

Description

@bixu

Component(s)

pkg/ottl

Is your feature request related to a problem? Please describe.

Consider a use-case where we want to normalize too-old timestamps on incoming telemetry. For debugging purposes, we might want to keep a copy of the original timestamp. Since the original timestamp data is in nanoseconds since the epoch, the raw value can be hard for humans to interpret.

Describe the solution you'd like

We could consider adding a Converter to translate the nanosecond epoch back to a human-readable timestamp. Timestamp(), for example.

Usage could be something like

Timestamp(target, format)

where target is something like time_unix_nano and format is a string templating the timestamp. A syntax similar to that of Time() would be preferable.

Describe alternatives you've considered

I attempted to use existing functions with the Transform processor, but the experience was...messy and would be difficult to debug:

- set(attributes["timestamp"], Format("%04d-%02d-%02d %02d:%02d", [Year(UnixNano(time_unix_nano)), Month(UnixNano(time_unix_nano)), Day(UnixNano(time_unix_nano)), Hour(UnixNano(time_unix_nano)), Minute(UnixNano(time_unix_nano))]))

Additional context

See CNCF Slack discussion here.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions