-
Notifications
You must be signed in to change notification settings - Fork 306
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
How should output-elasticsearch deal with a missing @timestamp? #779
Comments
Just for reference, this issue happens because sprintf time interpolation behaves differently from normal interpolation:
|
In case anyone is watching this issue, I just posted a massive update to the description of the issue. The focus is now solely on Also, I brought back my original approach to the matter on the table (trying to accommodate for the missing |
In my mind, approaches 1 and 3 are tied as my favourites. I'd start with 1 because it's less work (it's essentially the current state + possible improvements), then if we want, we can continue working towards option 3. My 3rd favourite approach is # 2, but I can live with it. However if we want to go the opinionated route, we'll have to be clear with our users that use cases removing |
Thanks for the excellent writeup @webmat . Whatever solution we come up with here, we should consider consistency with My suspicion here is that there is no one right answer here. What are your thoughts WRT creating two separate You'd use |
Opposing concepts:
Field removal
A proposal
WDYT? |
@colinsurprenant I agree that I'm worried about that approach due to the amount of magic there, it seems like it violates the principle of least surprise if you can remove something but it still exists in some contexts. What did you think of my proposal to let plugin authors decide what level of strictness was needed for interpolation on a case by case basis? |
@andrewvc seems to add more complexity to me. OTOH what I propose is basically surfacing a fact that is true today which is that the timestamp has some special behaviour: we even have a It seems to me that conceptually it will be easy to explain and understand for the users that there is one special field in the |
@colinsurprenan That's a good point. I see that it does solve the problems you mention. It does have the cost of being yet another 'special' thing to document. Here's a thought, what if we deprecate We'd also adjust sprintf for timestamps to treat that like an ordinary field. |
To clarify what I mean by 'like an ordinary field', I mean that we'd follow the same interpolation rules. I do think we need a strict interpolation variant regardless of the timestamp decision to let plugin authors decide if interpolation issues are fatal. |
An alternative approach would be if we had a rule that any field that starts with |
Having the timestamp in The problem we face is that over time This is why I still think that we should not change the interface to get the |
This comment is not a response to the recent comments (that's coming after). If anyone strongly in favour of Option 2 wants to flesh out this section more, in the issue body, you're welcome to do so. It's never how I used Logstash personally. So while I understand the point of view, I'm probably not making all of the arguments that can be made. |
I feel like the current discussion always goes really deep right away. But I'd like to shed light on one assumption that seems to be underlying all of this. That I'd like to flesh out clearly what it is that breaks. I can start with the obvious one, which triggered all of this. Breaks:
If we fix this (assuming we try the lenient route), what else could this break? Is this it, or are there other things I'm not seeing? |
@andrewvc If we were to introduce new Right now the behaviour is:
The new behaviour, if we take that route could be:
Reset. Now that I phrase it this way, I wonder if multiple implementations of Introducing multiple versions of Perhaps we should be considering adding a Logstash-level option to decide behaviour on interpolation failures, instead? Options:
The behaviour we have in current versions of Logtstash (at least wrt to # logstash.yml
interpolation.field: none
interpolation.time: crash Given the different role of different plugins, I haven't fully thought through the implications here. But I think this more directly addresses "should we crash" or not. With this approach, the answer becomes the beloved "It Depends ™" (but you decide). |
We have definitely broadened the discussion away from only the output-es problem, but that's a good thing. Maybe we should move the discussion into a logstash issue. Generally speaking when I referenced things that will break, in the context of trying to fix the larger issue by getting rid of the
This is why I believe that the |
One thing's for sure, moving |
@colinsurprenant If we made if [@timestamp] {
# ...
} else {
# ...
} |
OK, so new thought having chewed through all the excellent points both @colinsurprenant and @webmat have made. I particularly like your proposal for per-field support @webmat but I think doing an extra file is awkward. What if we implemented it at the LS config language level? What if say So, the guidance for a user not wanting to serialize the timestamp, but to use it, would be to use that sprintf format, and to move the timestamp from |
Yes! I like the idea of having two ways of interpolation. A strict one and a lax one. Tongue in cheek caveat: Now Rubyists will get confused by two things, rather than one. The hash syntax without the commas, and now the look-alike string interpolation delimiters that actually have no relation with Ruby's 😆 Kidding aside, I like this. It gives maximum granularity (both can even be used in one string template, at the extreme), without introducing anything scattered all over the place (logstash.yml, plugin args). It's just two different delimiters. Love it! |
@webmat that's a good point, we already have The strict behavior, BTW, should be to either log and warn, or go to the DLQ IMHO. |
@webmat the behavior with if [@timestamp] {
# ...
} else {
# ...
} would be to never take the |
@colinsurprenant I think it's a useful feature on its own yes. It'd actually still be useful for Let's imagine a situation where the real timestamp is in The exciting thing about the approach of having the user pick the syntax is that it puts the choice of behavior in the hands of the user. It also is a generally useful enhancement, which is great because it reduces the total complexity of the system. Most importantly, however, it keeps the usage of field removal/writing consistent. I'm not against having exceptional cases, but exceptional cases often indicate an impedance mismatch in the modeling of a problem. If we can solve a problem without that and put the user in control, that feels like a win. |
@andrewvc lets keep in mind that we already have a different behaviour for
|
@colinsurprenant it makes sense to reduce the number of special cases, and the amount of complexity. We should probably remove all those special guarantees. IMHO we should just make Let's imagine we're teaching a course on Logstash, we could either explain:
Moving to it being a normal field would actually clean up a lot of weirdness in how examples work. In some examples we read a string version of a timestamp into One other thought, have you considered that the 'hide-able' approach makes the logical nullity of timestamps weird to express. If you want to express "I don't have a timestamp" then you need to make some other field for that called |
I guess It is a question of how much we need to change to solve which scope of problem, in what timeframe taking into account the BWC issues. The point of my proposed solution is to be simple, applicable today, backward compatible and does not require any modifications in the plugins or user configurations. But the tradeoff is to have a exceptional behaviour when removing the It's all good if we agree to go wide and completely redefine the timestamp handling and behaviour in logstash and plugins too. |
Considering logstash 7.0 is far away but not too much, this is a great time to be considering breaking changes and the upgrade+deprecation path for them in the 6.4/6.5 minors. IMO, I think that moving the timestamp field to the BWC-wise, this shouldn't break almost any plugin, as they should be using Tbh I don't see an urgency is solving this in any immediate time frame, this situation pops up once in a while and we could just improve the wording in the exception we output, but otherwise we have the breathing room to make "the right decision" without pressure to deliver a fix. |
Events without
@timestamp
can be difficult to process in certain situations. According to code that dates back to 2013 (and probably before), its presence should be guaranteed. Logstash has never enforced this by preventing the removal of@timestamp
per se, however.So whenever a problem arises from a missing
@timestamp
, people may simply see an innocuous error like the following, and conclude that there's a bug in Logstash:One point of view about this is that the event should actually be considered invalid and whatever lead to this situation is likely to cause data loss.
There are two schools of thoughts or approaches we can take for these:
In either case, in order to prevent needless confusion and support requests, we should at the very least output a log message that's a bit more verbose than the one above, in explaining what the problem actually is. With this event it's missing
@timestamp
and the customer tries to index it to a timestamped index (likelogstash-%{+YYYY.MM.dd}
).Are non-timestamped events legitimate?
The behaviour currently (unless the above situation happens) is to successfully index the event. I would argue there's a legitimate use case for removing
@timestamp
in Logstash pipelines. It's counterintuitive because Logstash was born to process time-based data. But once someone has a Logstash installation, Logstash is a great way to ingest non time-based data periodically to their ElasticSearch cluster.Examples of non time-based data to reimport regularly:
Another supporting argument for the legitimacy of non time-based support in Logstash is the fact that our plugins are gradually getting better at supporting non time-sensitive scenarios:
The last point in demonstrating the legitimacy of processing non-timestamped data with Logstash is the very first Logstash configuration one sees, during the ElasticSearch training.
Here we're ingesting bunch of data, but we're not interested in keeping
@timestamp
(among others).Approach 1: Support these events as best as possible
The current behaviour is that events with no
@timestamps
work in most cases. People can do this, and are doing it. There are still some improvements we can make:@timestamp
to a timestamped index.ERROR
for every event in this situation, and keep Logstash running.Approach 2: Interpret this as a problem with the user's configuration and crash
A lot of the feedback around #777 was not about the PR, but went in the direction that "not having a
@timestamp
on the event" was not officially supported. So this definitely stuck a chord with a few people :-)In any case, nobody denies that we can improve the error message when the timestamp error happens.
Now, do we want to take a harder line to the effect that we do not want to support a missing
@timestamp
at all? If so, the current behaviour is not strict enough. We may want to take the following additional steps:@timestamp
as soon as we see them (whether or not the timestamp is needed).@timestamp
.1+2=3: Let users decide
Any given user may really want Logstash to behave like 1, or to behave like 2. Presumably, the default could be the friendlier approach 1, and people who take great pains to construct a pipeline that has the least data loss possible (e.g. use only non-lossy transports & plugins, careful use of PQ & DLQ) could optionally decide that such events should indeed cause a hard crash.
Why this discussion?
This issue came out of the discussion here #777, which in turn came from reports such as #739. Requesting feedback on #777 in Slack immediately led to discussions of going towards approach #2.
The text was updated successfully, but these errors were encountered: