Skip to content

Instantly share code, notes, and snippets.

@graphaelli
Last active October 31, 2019 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graphaelli/dc24106ef4efe4de4d374097d4093118 to your computer and use it in GitHub Desktop.
Save graphaelli/dc24106ef4efe4de4d374097d4093118 to your computer and use it in GitHub Desktop.
DELETE block_ip
PUT block_ip
{
"mappings": {
"properties": {
"source": {
"properties": {
"ip": {
"type": "ip"
}
}
},
"drop": {
"type": "boolean"
}
}
}
}
POST block_ip/_doc/172.18.0.8
{
"source": {"ip": "172.18.0.8"},
"drop": true
}
PUT /_enrich/policy/block-ip-policy
{
"match": {
"indices": "block_ip",
"match_field": "source.ip",
"enrich_fields": ["drop"]
}
}
POST /_enrich/policy/block-ip-policy/_execute
POST _ingest/pipeline/_simulate
{
"pipeline": {
"processors": [
{
"enrich": {
"policy_name": "block-ip-policy",
"field": "source.ip",
"target_field": "_action"
}
},
{
"drop": {
"if": "ctx._action != null && ctx._action.drop"
}
}
]
},
"docs": [
{
"_source": {
"source": {
"ip": "172.18.0.8"
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment