Created
November 7, 2018 20:25
-
-
Save cdahlqvist/6cee3b0aeec82f704c0868b247e50005 to your computer and use it in GitHub Desktop.
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
{ | |
"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