With log pipelines, is there a way to use a different field if one field is not available? #6439
-
|
When processing my docker logs, I have 2 or 3 different places I can get the timestamp. Is there a way to try to set it using one field, and then if that field is missing, then try a different one? Specifically I'm using the regex processor to pull the timestamp out of the actual log message. But that doesn't always work, so is there a way I can fall back to the timestamp that my log shipper adds? Vector in this case. So, normally the timestamp is pulled out of the "message" field, but if that doesn't work, I want to use the "timestamp" field. I'm asking because I am seeing messages in my greptime logs like: I don't see anything in the docs about this being possible, but I figured I'd ask. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Hi, jerrac However, you can try to use a workaround. With Let me know if there are any further questions! |
Beta Was this translation helpful? Give feedback.
Hi, jerrac
First off, you can use the
ignore_missingoption to continue the process without breaking and returning an error.Secondly, we don't have a pick-one-valid-from-an-array processor or mechanism. This can surely be done in a vrl script. But this is an interesting idea, we might need to do some investigation to see if there exists a general idea to form a processor.
However, you can try to use a workaround. With
ignore_missingadded, rename the output of thedateprocessor totimestamp. In this case, ifdateprocessor outputs the result, it overrides thetimestampand is used in the result; otherwise the processor is skipped and the originaltimestampis used. This is also possible…