Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timestamp stage with multiple formats #2590

Closed
aminjam opened this issue Sep 2, 2020 · 3 comments · Fixed by #2615
Closed

timestamp stage with multiple formats #2590

aminjam opened this issue Sep 2, 2020 · 3 comments · Fixed by #2615
Labels
help wanted We would love help on these issues. Please come help us!

Comments

@aminjam
Copy link
Contributor

aminjam commented Sep 2, 2020

Is your feature request related to a problem? Please describe.
Yes, We consume data that can have multiple types of timestamp formats (RFC3339Nano, Unix, or "2006-01-02 03:04:05.000000000 +0000 UTC"). All timestamps arrive under the same json key but different formats. Currently we inspect the input beforehand, find out the format, and create a unique promtail config for a given selector.

Describe the solution you'd like
It would be ideal to define multiple formats under timestamp stage. timestamp stage would then process each format and if it errors, it would try the next one on the list. An example timestamp stage would look like the following:

- json:
   expressions:
     timestamp:
- timestamp:
   source: timestamp
   format: RFC339Nano
    fallback_formats:
    - Unix
    - 2006-01-02 03:04:05.000000000 +0000 UTC

Describe alternatives you've considered
Pre-process the input and create unique promtail configs.

@slim-bean slim-bean added the help wanted We would love help on these issues. Please come help us! label Sep 4, 2020
@slim-bean
Copy link
Collaborator

This is an interesting idea! There would be some overhead of this approach in CPU terms but I think we are balancing that against ease of use. As you describe this can be accomplished now but only in a very verbose and config heavy way.

I think this is a good idea, however we are pretty swamped at the moment, if this is something you are able to help contribute a PR for that would be great, else I'm happy to keep the issue open and see if anyone else comes along or we have some time to take a look!

@aminjam
Copy link
Contributor Author

aminjam commented Sep 8, 2020

Yes, I'd be happy to PR this feature. As far as the UX goes for this feature, which one of the following options would you prefer?

  1. format field separated by new line characters (original proposal)
    • Pros: Backward compatible
    • Cons: New line might not be the best way of defining multiple options. On the surface, it looks like the following logic would break. Also there are many ways of having multi-line strings in YAML and hard to support all possible ways.
  2. Introduce a new optional array field for timestamp stage (e.g. backup_formats)
    • Pros: Backward compatible.
    • Cons: It feels like format field is not needed and could be optional
  3. Convert the format field to an array of strings instead of string
    • Pros: It's more natural to think of the following feature as a list of formats to try
    • Cons: Backward Incompatible
  4. Combine Option 2 & 3. Mark format field as optional and add formats field as an array of strings
    • Pros: Backward compatible and it's more natural to think of the following feature as a list of formats to try
    • Cons: ?
  5. Others?

@cyriltovena
Copy link
Contributor

I'm in favor of 2. and name the array fallback_formats.

winkingturtle-vmw added a commit to aminjam/loki that referenced this issue Sep 25, 2020
slim-bean pushed a commit that referenced this issue Sep 28, 2020
Fixes #2590

Co-authored-by: Amin Jamali <ajamali@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted We would love help on these issues. Please come help us!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants