-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add timestamps to Zeek events #331
Conversation
8745708
to
53d214b
Compare
Some thoughts:
I didn't check the Zeek side, but unless we really need to expose the timestamp to the Python bindings, I would avoid touching the Python bindings. We already have a ticket for removing them #303. |
Actually, that was my first thought. Looking at the Zeek and Python APIs, I was under the impression that the data model wouldn't allow us to append fields as we couldn't disambiguate between alternate event prototypes and the use of an additional timestamp. I think I was wrong here. At the "broker-level" this seems to be possible, as events aren't flat but nested vectors. That is, arguments are represented by a dedicated vector that can be followed by fields of other types, right? So this would be my preferred solution. |
53d214b
to
0cf2e12
Compare
I just moved the timestamp to the end of the message :)
No preference here. Given that websockets are a relatively new feature, I guess both options would be okay.
We can remove that part. However, seems handy for now and probably doesn't hurt. |
The trailing timestamp seems reasonable to me, but haven't thought too much about interoperability. Might be a bit of a question what the Zeek side does if there's an event with no timestamp (the 0.0 default), but that could fall back to current network_time on a layer above. The one point that comes to mind is whether we should make the timestamp nanosecond uint64_t here in broker and convert to double unix seconds up in Zeek land (where that's just what's used right now). There should not be Zeek events with timestamps before 1 Jan 1970, even when reading really old pcaps and non that are 500+ years in the future. Reference zeek/zeek#1643 |
One more thought: Could we go for a a more extensible header-style field instead of the atomic field that is just a timestamp? That is, append a Mainly, while the current idea is to only attach network time to an event, what if in the future more information is need or different approaches want to be evaluated? That would require another broker change and another round of appending-a-field-trying-to-stay-compatible. An extensible header format avoids that at the cost of extra complexity. So the event headers (maybe there's a better name) would just be the following currently and populated up in Zeek land: Broker wouldn't actually need to know about about TIMESTAMP_NETWORK - that's a const up in Zeek land.
I would hope the extra marshaling / processing overhead is negligible compared to the involved IO and that encoding overhead is acceptable. Some examples that are not too far fetched IMO:
Trying out or adding any of these wouldn't require a broker level change and just a Zeek patch instead. |
I don't see a benefit in doing so as long as Zeek doesn't support nanosecond timestamps.
I think this makes sense once there is a need for another field. For now that scenario is theoretical. To avoid the over-engineering trap, I would leave it as is for now. |
Hmm, rather strong opinion about the nanoseconds/timestamp: broker already defines a Lines 23 to 24 in 5811420
For the more extensible/generic approach, I don't think it's theoretical at all: You currently have a case of adding the network timestamp to an event and you weren't able to do that without patching broker. Adding a bit more flexibility is mostly forward looking to allow experimentation/extensions without needing another patch or discussions about protocol changes. But well, that's my input / opinion. I'll leave it to @Neverlord or others. |
a6ee3a7
to
d0d8ce0
Compare
In light of zeek/zeek#1643 maybe happening sometime in the future, I'd rather it be sent in nanoseconds just to make life easier later. |
The fact that there is a built-in broker type for timestamps somehow disappeared from my radar. I agree that it makes sense to use this. Open questions:
|
A couple of thoughts:
|
7efcf82
to
4a4389e
Compare
Discussing how to implement the generic approach to add metadata to events, it turned out that getting this right probably needs to address a couple of related problems. I tried to capture these in new issues. To prevent blocking zeek/zeek#2929, it seems we should move on here and reiterate once the generic metadata mechanism landed.
Thinking a bit about the use cases I had in mind, it would indeed make sense to handle missing timestamps in Zeek instead of defaulting to 0. At the Zeek-level, we can set the timestamp to current network time for events received without a timestamp. To me, that seems to be reasonable. I have done the necessary adaptions, added a compatibility test in Zeek (zeek/zeek@1aead4f), and rebased on current master. I guess we are ready for another review/merge. |
Hmm, I was missing the If you think it's too much I'm happy to give it a whirl. |
Feel free to open another PR. If you get that merged this week, I am happy to close this one and adapt #zeek/zeek/2929 to the new mechanism. |
Proposal is here: #343 I didn't remove the constructor and ts accessors, so this is actually compatible at this point with the Zeek branch. I'll try to get @Neverlord 's thoughts tomorrow. |
I am closing this in favour of #343. |
This adds timestamps to the Zeek event message type for zeek/zeek#2929. Currently, the changeset would be missing a protocol version bump. @Neverlord brought up that a new protocol version is a far-reaching change and suggested to introduce a new message type for timestamped events. My gut feeling is that a clear-cut by bumping the version would be the easiest as it avoids the complexity of maintaining some meaningful interoperability. However, I can see this would be a rather radical measure for a tiny feature. To decide which path to go, we are looking for some feedback (tagging @ckreibich, @rsmmr, @timwoj and @awelzel).