-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Support other duration formats than Go duration format #2925
Comments
This is an acceptable feature request but lack of example on how we can achieve this. The left side should be explicit, some examples could be:
What do you think ? any better name ? should we try to infer the type without the function ? like this:
Not sure yet of all of this I think we need to design this correctly first, specially that we want to probably support more format in the future, I expect people asking for other date and duration format. |
Definitely. I was hopping you already had some plan 😉
Note: I have not read relevant Loki source code yet, so my words may make no sense at all. My understanding is that Using Go duration format to express the constant part seems perfectly fine. An user might prefer one duration format or some other but it's mostly nitpicking. It takes 10s to understand how Go duration format works. The main issue is how to convert myField into a duration that can be compared to the constant. All your proposals change how to express the constant which surprised me. I would have thought that you would propose to use
I have not played much with label_format yet but I think it would do the trick. However, having to use a label_format for a such common operation might be too cumbersome. Maybe we can find some shorter syntax like:
If I don't plan to reuse the label for another purpose it seems both concise and allows to leverage template functions. What do you thing? |
I think it's a good idea to start with for sure template function are easier to add. However template are hard to scale it's the most inefficient stage in the language currently but we can solve that at some point. |
@cykl the issue title is missing the word "other" I think. @cyriltovena Would it be possible to enable sorting / filtering a string alphabetically for this?
While not as user friendly as
Would you deem this worthy its own issue? I can think of some use cases for alphabetically sorting strings (e.g. postal codes that are not numeric) |
Yeah but let's create another issue for this then. |
This is interesting! +1 Just putting the possible options based on above discussions. So the use case is basically to compare time and duration in different format. say,
Q: Currently LogQL support duration type not date. Do we have to support date format as well? (that can also taken as completely new feature and tracked on separate issue) IMO, keeping single type of format on right hand side of the op is much simpler and less confusing for users of LogQL as well. Assuming, we keep right hand side like as it is now (Duration format with Go style.), all we need to do is somehow make And I think recognising this label in ISO format implicitly is better. Why?
Examples
I also think template seems like overkill for this. |
After discussion with @cyriltovena, looks like there is some real problem in making LogQL grammar to understand the label duration type implicitly. Here is the another possible approach. Basic idea is to extend current We can add optional argument to
Both if Scope:
Examples:
Here we considered only "go" and "iso" format style, but we can extend it into different format types like ".net", "java", "ruby" etc.. on demand. In future we can do same for |
Is your feature request related to a problem? Please describe.
LogQL only support Go duration format. Applications not written in Go are unlikely to produce durations in Go duration format which lead to a degraded query experience.
duration > 35000000000
rather thanduration > 35s
which is cumbersome and error prone.Describe the solution you'd like
I had like to be able to parse common duration representations (ISO 8601 duration, fractional (seconds|milliseconds) etc.).
Describe alternatives you've considered
Additional context
I haven't had time to evaluate all the consequences of this request nor to devise a solution. However, I'm sure this issue will itch enough users to worth an anemic issue.
The text was updated successfully, but these errors were encountered: