Created
October 19, 2016 13:00
-
-
Save lenada/f36ccc69badab0db16f73a5f4300acdc to your computer and use it in GitHub Desktop.
Elasticsearch: replace long hostnames with short ones (ELK/Logstash)
This file contains 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
curl -XPOST 'localhost:9200/logstash*/_update_by_query?conflicts=proceed&pretty' -d' | |
{ | |
"script": { | |
"inline": "if(ctx._source.host instanceof String) {ctx._source.host = ctx._source.host.replace( \".domain.com\", \"\" )} else if (ctx._source.host instanceof ArrayList) { ctx._source.host = ctx._source.host[0] }" | |
}, | |
"query": { | |
"match": { | |
"host": { | |
"query": "*.domain.com", | |
"type": "phrase" | |
} | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment