-
Notifications
You must be signed in to change notification settings - Fork 98
Ingest pipeline best practices #1381
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
base: main
Are you sure you want to change the base?
Ingest pipeline best practices #1381
Conversation
There are a couple of things I need help with.
|
Thanks a lot for opening this Philipp! I've added the "Team:Obs" label since under the new docs organization that's where the ingest content will land. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@philippkahr I started reviewing this PR, but I didn't get very far (yet!). There's a lot of content to get into! I'm just going to post the comments/questions/suggestions I have so far so I can see if I'm on the right track. I can jump back in next week.
Some themes in my early feedback include:
- I see some opportunities to simplify the examples to really emphasize the point you're making in each section.
- It might be helpful to write out in plain language what the example is trying to achieve before jumping into a code snippet. (I provided a couple suggestions below.)
- There are probably opportunities to remove redundant information.
|
||
## if statements | ||
|
||
### Contains and lots of ORs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just seems like a best practice for writing code in general. There's nothing specific about ingest pipelines (or am I missing something)?
### Contains operation and null check | ||
|
||
This includes an initial null check, which is not necessary. | ||
|
||
```painless | ||
"if": "ctx.event?.action !=null | ||
&& ['bandwidth','spoofed syn flood prevention','dns authentication','tls attack prevention', | ||
'tcp syn flood detection','tcp connection limiting','http rate limiting', | ||
'block malformed dns traffic','tcp connection reset','udp flood detection', | ||
'dns rate limiting','malformed http filtering','icmp flood detection', | ||
'dns nxdomain rate limiting','invalid packets'].contains(ctx.event.action)" | ||
``` | ||
|
||
This behaves nearly the same: | ||
|
||
```painless | ||
"if": "['bandwidth','spoofed syn flood prevention','dns authentication','tls attack prevention', | ||
'tcp syn flood detection','tcp connection limiting','http rate limiting', | ||
'block malformed dns traffic','tcp connection reset','udp flood detection', | ||
'dns rate limiting','malformed http filtering','icmp flood detection', | ||
'dns nxdomain rate limiting','invalid packets'].contains(ctx.event?.action)" | ||
``` | ||
|
||
The difference is in the execution itself which should not matter since it is Java under the hood and pretty fast as this. In reality what happens is the following when doing the first one with the initial: `ctx.event?.action != null` If action is null, then it will exit here and not even perform the contains operation. In our second example we basically run the contains operation x times, for every item in the array and have `valueOfarray.contains('null')` then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example confuses me. Why would you want to run the contains operation n times if you already know ctx.event.action
is null
and it's going to return false
.
Co-authored-by: Colleen McGinnis <[email protected]>
based on the discussions here: #1052
this is my first PR against the docs, and I am building a couple of new pages. I think it makes sense to split it out. I am putting it into that part of the docs. https://www.elastic.co/docs/manage-data/ingest/transform-enrich/ingest-pipelines The tips and tricks are generic and not specific to just o11y, or security.