Use script to filter the logs based on specific value of field

Can I add an condition for metrics aggregation on y axis to check for the specific field value. I'm trying to create a bar chart with 2 y axis aggregation. In one aggregation I want count of all the docs and for another aggregation I only want count of logs with specific field value.

Here For "Total Submission" aggregation I'm taking count of all the logs but for "SonarQube failed checks" aggregation I only want the count of the logs for which the field "name" has the "release_sonarqube_check" value. For that I'm using
{ "script" : "doc['name'].value=release_sonarqube_check"} script but it's not even adding in msearch request body. Can someone suggest if it's possible and what might be the correct way to write script for that?

@Hey @Parth_Kalaria, you can use the "JSON Input" to specify a script like the following example, but it won't give you what you're looking for: https://www.elastic.co/guide/en/elasticsearch/reference/master/search-aggregations-metrics-cardinality-aggregation.html#_script_3

Instead, I'd recommend using a configuration similar to the following, which doesn't rely on the JSON Input:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.