Repository navigation
Metric to Log Timestamp gets overwritten? How to preserve log timestamp when converting to metric and sending using prometheus remote write? #22722
|
Hi, I'm trying to use log_to_metric transformation. These are logs have timestamps that aren't current such as This is how I'm converting the log to metrics: I notice when I notice that log_to_metric transform sets the metric timestamps to the current timestamp the metric is converted. I tried adding a remap after this to change the timestamp back using |
Replies: 1 comment
|
Your approach of restoring the timestamp after conversion works. Use transforms:
convert_s3:
type: log_to_metric
inputs: [s3_metrics_as_logs]
metrics: []
all_metrics: true
restore_timestamp:
type: remap
inputs: [convert_s3]
source: |
.timestamp = parse_timestamp!(.tags.log_timestamp, "%+")The Remote Write sink should consume I tested this on Vector 0.60.0 with a local Vector Remote Write receiver. Your timestamp arrived as I couldn't reproduce the sink replacing a restored timestamp with the current time. If that still happens, please share your Vector version, a sample input event, and the full transform/sink wiring. Please don't hesitate to followup in this thread if you have further questions. |
Your approach of restoring the timestamp after conversion works. Use
%+to parse the RFC 3339 timestamp, including itsZtimezone:The Remote Write sink should consume
restore_timestamp. The literalZin your original format does not parse a timezone, so it can interpret the time using Vector's configured/default timezone. Seeparse_timestamp.I tested this on Vector 0.60.0 with a local Vector Remote Write receiver. Your timestamp a…