generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 628
adding example for CIDR block in Data Prepper #11203
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
Merged
natebower
merged 9 commits into
opensearch-project:main
from
AntonEliatra:adding-cidrContains-example-config
Nov 12, 2025
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b6ef246
adding example for CIDR block in Data Prepper
AntonEliatra eafd7ff
adding example for CIDR block in Data Prepper
AntonEliatra fb01c68
Update _data-prepper/pipelines/cidrcontains.md
kolchfa-aws d7bf298
Update cidrcontains.md
AntonEliatra b13158e
adding command to test the pipeline
AntonEliatra 6b31e89
Update cidrcontains.md
AntonEliatra c49abad
Update cidrcontains.md
AntonEliatra fd986d3
Update cidrcontains.md
AntonEliatra 454230a
Update _data-prepper/pipelines/cidrcontains.md
kolchfa-aws File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,3 +22,82 @@ cidrContains('/client.ip', '192.168.0.0/16', '10.0.0.0/8') | |
| {% include copy.html %} | ||
|
|
||
| This function returns `true` if the IP address matches any of the specified CIDR blocks or `false` if it does not. | ||
|
|
||
| ## Example | ||
|
|
||
| The following pipeline drops any documents that are not part of the specified CIDR blocks: | ||
|
|
||
| ```yaml | ||
| cidr-allowlist-pipeline: | ||
| source: | ||
| http: | ||
| path: /events | ||
| ssl: true | ||
| sslKeyCertChainFile: "certs/dp.crt" | ||
|
||
| sslKeyFile: "certs/dp.key" | ||
| processor: | ||
| - drop_events: | ||
| # Drop events whose client IP is NOT in specific CIDR allowlist | ||
| drop_when: 'not cidrContains(/client/ip, "10.0.0.0/8", "192.168.0.0/16", "fd00::/8")' | ||
| sink: | ||
| - opensearch: | ||
| hosts: ["https://opensearch:9200"] | ||
| insecure: true | ||
| username: admin | ||
| password: "admin_pass" | ||
| index_type: custom | ||
| index: "logs-%{yyyy.MM.dd}" | ||
| ``` | ||
| {% include copy.html %} | ||
|
|
||
| You can test this pipeline using the following command: | ||
|
|
||
| ```bash | ||
| curl -ksS -X POST "https://localhost:2021/events" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '[ | ||
| {"client":{"ip":"10.23.45.6"},"msg":"allowed 10/8"}, | ||
| {"client":{"ip":"8.8.8.8"},"msg":"should be dropped"}, | ||
| {"client":{"ip":"fd00::1234"},"msg":"allowed ULA IPv6"} | ||
| ]' | ||
| ``` | ||
| {% include copy.html %} | ||
|
|
||
| The documents stored in OpenSearch contain the following information: | ||
|
|
||
| ```json | ||
| { | ||
| ... | ||
| "hits": { | ||
| "total": { | ||
| "value": 2, | ||
| "relation": "eq" | ||
| }, | ||
| "max_score": 1, | ||
| "hits": [ | ||
| { | ||
| "_index": "logs-2025.10.14", | ||
| "_id": "Ng1i4pkBLPEKXekW48BU", | ||
| "_score": 1, | ||
| "_source": { | ||
| "client": { | ||
| "ip": "10.23.45.6" | ||
| }, | ||
| "msg": "allowed 10/8" | ||
| } | ||
| }, | ||
| { | ||
| "_index": "logs-2025.10.14", | ||
| "_id": "Nw1i4pkBLPEKXekW48BU", | ||
| "_score": 1, | ||
| "_source": { | ||
| "client": { | ||
| "ip": "fd00::1234" | ||
| }, | ||
| "msg": "allowed ULA IPv6" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.