Kibana Filtering data based on aggregation

Viewed 105

I need to show the count of running jobs and completed in pie chart. I am receiving status of jobs in real time. To show the count of the jobs that are currently in running state I have to filter those jobs which are already completed (e.g Job a). Please suggest a way to to do this.

Job timestamp   Status
job a   1639381300  Running
job a   1639381301  Running
job a   1639381302  Completed
job b   1639381301  Running

Output(Pie Chart)

  • Count of jobs completed jobs =1
  • Count of jobs running jobs =1
1 Answers

Filter your jobs first then aggregate! Below is a sample adapt it

GET logs/_search
{
  "size": 0,
  // Now create aggregates level 3
  "aggs" : {
    "messages" : {
      // do some filtering level 2
      "filters" : {
        "other_bucket_key": "other_messages",
        "filters" : {
          // do some filtering level 1
          "errors" :   { "match" : { "body" : "error"   }},
          "warnings" : { "match" : { "body" : "warning" }}
        }
      }
    }
  }
}
Related