Skip to content

Instantly share code, notes, and snippets.

@cdahlqvist
Created November 7, 2018 20:25
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 cdahlqvist/6cee3b0aeec82f704c0868b247e50005 to your computer and use it in GitHub Desktop.
Save cdahlqvist/6cee3b0aeec82f704c0868b247e50005 to your computer and use it in GitHub Desktop.
{
"trigger": {
"schedule": {
"interval": "10s"
}
},
"input": {
"http" : {
"request" : {
"host" : "127.0.0.1:9200",
"port" : 9200,
"path" : "/_ccr/stats",
"auth" : {
"basic" : {
"username" : "elastic",
"password" : "changeme"
}
}
}
}
},
"condition" : {
"script" : {
"source" : "if (ctx.payload.follow_stats.indices != null && ctx.payload.follow_stats.indices.size() > 0) { return true; } else { return false;}"
}
},
"actions": {
"index_payload" : {
"transform": {
"script": "def stats = ctx.payload.follow_stats.indices.stream().map(p -> p.shards).collect(Collectors.toList()).stream().flatMap(List::stream).collect(Collectors.toList()); stats.forEach(f -> f.put('@timestamp', ctx['execution_time'])); ctx.payload._doc = stats.toArray();"
},
"index" : {
"index" : "ccr-stats",
"doc_type" : "_doc"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment