I have below data but i need to build a query which will give the average of CpuAverageLoad of specific Nodetype. Kibana cannot used because of some license issue.
> { "took" : 6, "timed_out" : false, "_shards" : {
> "total" : 5,
> "successful" : 5,
> "failed" : 0 }, "hits" : {
> "total" : 11,
> "max_score" : 1.0,
> "hits" : [
> {
> "_index" : "kpi",
> "_type" : "kpi",
> "_id" : "AWIZB9Ds_xnN0Y7Qo1A7",
> "_score" : 1.0,
> "_source" : {
> "date" : "2018-03-12 12:36:05",
> "kpi" : [
> {
> "CpuAverageLoad" : 3,
> "HaGroupId" : "1001",
> "LbGroupId" : "",
> "MemFree" : 100,
> "MemUsed" : 0,
> "NodeId" : "kishan",
> "NodeType" : "tpt",
> "State" : "online",
> "Static_limit" : 0
> },
> {
> "CpuAverageLoad" : 0,
> "HaGroupId" : "102",
> "LbGroupId" : "",
> "MemFree" : 0,
> "MemUsed" : 0,
> "NodeId" : "kalyan",
> "NodeType" : "tpt1",
> "State" : "online"
> }
> ]
> }
> },
> ......
> {
> "_index" : "kpi",
> "_type" : "kpi",
> "_id" : "AWIZCLsE_xnN0Y7Qo1A8",
> "_score" : 1.0,
> "_source" : {
> "date" : "2018-03-12 12:37:05",
> "kpi" : [
> {
> "CpuAverageLoad" : 3,
> "HaGroupId" : "1001",
> "LbGroupId" : "",
> "MemFree" : 100,
> "MemUsed" : 0,
> "NodeId" : "kishan",
> "NodeType" : "tpt",
> "State" : "online",
> "Static_limit" : 0
> },
> {
> "CpuAverageLoad" : 0,
> "HaGroupId" : "102",
> "LbGroupId" : "",
> "MemFree" : 0,
> "MemUsed" : 0,
> "NodeId" : "kalyan",
> "NodeType" : "tpt1",
> "State" : "online"
> }
> ]
> }
> },
> {
> "_index" : "kpi",
> "_type" : "kpi",
> "_id" : "AWIZCVc9H8WRs8qwDKh5",
> "_score" : 1.0,
> "_source" : {
> "date" : "2018-03-12 12:37:45",
> "kpi" : [
> {
> "CpuAverageLoad" : 0,
> "HaGroupId" : "1001",
> "LbGroupId" : "",
> "MemFree" : 100,
> "MemUsed" : 0,
> "NodeId" : "kishan",
> "NodeType" : "tpt",
> "State" : "online",
> "Static_limit" : 0
> },
> {
> "CpuAverageLoad" : 0,
> "HaGroupId" : "102",
> "LbGroupId" : "",
> "MemFree" : 0,
> "MemUsed" : 0,
> "NodeId" : "kalyan",
> "NodeType" : "tpt1",
> "State" : "online"
> }
> ]
> }
> },
> {
> "_index" : "kpi",
> "_type" : "kpi",
> "_id" : "AWIZCkGnH8WRs8qwDKh6",
> "_score" : 1.0,
> "_source" : {
> "date" : "2018-03-12 12:38:45",
> "kpi" : [
> {
> "CpuAverageLoad" : 1,
> "HaGroupId" : "1001",
> "LbGroupId" : "",
> "MemFree" : 100,
> "MemUsed" : 0,
> "NodeId" : "kishan",
> "NodeType" : "tpt",
> "State" : "online",
> "Static_limit" : 0
> },
> {
> "CpuAverageLoad" : 0,
> "HaGroupId" : "102",
> "LbGroupId" : "",
> "MemFree" : 0,
> "MemUsed" : 0,
> "NodeId" : "kalyan",
> "NodeType" : "tpt1",
> "State" : "online"
> }
> ]
> }
> }
> ] } }
I have tried with below query
curl -XGET 'localhost:9200/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query": {
"bool" : {
"must" : {
"script" : {
"script" : {
"inline" : "doc['kpi.CpuAverageLoad'].value > params.param1",
"lang" : "painless",
"params" : {
"param1" : 5
}
}
}
}
}
}
}
I am unable to build a porper query which we give me the average of CpuAverageLoad for specific nodetype i mention