Closed
Description
Component(s)
pkg/ottl
Is your feature request related to a problem? Please describe.
Be able to add the current time generated by function Now()
as a string in an attribute in a log context.
Example configuration:
transform:
error_mode: ignore
log_statements:
- context: log
statements:
- set(attributes["otelTime"], Format("%04d-%02d-%02dT%02d:%02d:%02d.%09d", [Year(Now()), Month(Now()), Day(Now()), Hour(Now()), Minute(Now()), Second(Now()), Nanosecond(Now())]))
Describe the solution you'd like
Create 2 new OTTL functions:
- Second related to https://pkg.go.dev/time#Time.Second
- Nanosecond related to https://pkg.go.dev/time#Time.Nanosecond
Describe alternatives you've considered
As an alternative, I am using the following configuration
- set(attributes["eventForwarderTimestampUnixSeconds"], UnixSeconds(Now()))
But it does not help to have a custom string format like needed by some systems I work with.
Additional context
If this change is accepted, I would like to contribute.