Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
{
"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
You can’t perform that action at this time.