Skip to content

Instantly share code, notes, and snippets.

@lenada
Created October 19, 2016 13:00
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 lenada/f36ccc69badab0db16f73a5f4300acdc to your computer and use it in GitHub Desktop.
Save lenada/f36ccc69badab0db16f73a5f4300acdc to your computer and use it in GitHub Desktop.
Elasticsearch: replace long hostnames with short ones (ELK/Logstash)
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