After much pain I was able to create the pipeline aggregation below in the console. But, I can't figure out how I am supposed to get it into a visualization. I just want to create a guage to display the "availabile_percent"
POST /app-health/_search
{
"aggs": {
"availability_pct": {
"terms": {
"field": "entityId.keyword",
"size": 10
},
"aggs": {
"success_count": {
"sum": {
"script": {
"source": "if (doc['availability.keyword'].size()>0) { if (doc['availability.keyword'].value == 'AVAILABLE') { return 1; } } return 0;"
}
}
},
"total_count": {
"value_count": {
"script": {
"source": "return 0;"
}
}
},
"available_percent": {
"bucket_script": {
"buckets_path": {
"success": "success_count",
"total": "total_count"
},
"script": "params.success / params.total * 100"
}
}
}
}
}
}