-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Description
Elasticsearch version : 6.1.1-1
Plugins installed: X-pack
JVM version : java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64
OS version : RHEL 7.4
Description of the problem including expected versus actual behavior:
I want to use bucket_selector to remove buckets from the output based on the value generated by bucket_script. But it seems that bucket_selector does not find values in script. Using avg from same bucket works fine. Using derivative in bucket_script also works fine, which I suppose should be the same because derivative, bucket_script and bucket_selector all are parent pipeline aggregations.
Using derivative in bucket_selector also is not working and produces same error.
Steps to reproduce:
I make this query:
{
"size": 0,
"_source": [],
"query": {
"bool": {
"filter": [{
"range": {
"@timestamp": {
"gte": "1522850000000",
"lte": "1522850400000",
"format": "epoch_millis"
}
}
}, {
"query_string": {
"analyze_wildcard": true,
"query": "_exists_:interface.ifHCInOctets"
}
}
]
}
},
"aggs": {
"DBF_Device": {
"terms": {
"field": "tag.agent_host",
"size": 100,
"order": {
"_term": "desc"
}
},
"aggs": {
"DBF_Interface": {
"terms": {
"field": "tag.ifDescr",
"size": 100,
"order": {
"_term": "desc"
}
},
"aggs": {
"DBF_Metric": {
"date_histogram": {
"interval": "5m",
"field": "@timestamp"
},
"aggs": {
"DBF_Metric_AVG": {
"avg": {
"field": "interface.ifHCInOctets",
"script": {
"inline": "(_value*8)/300"
}
}
},
"DBF_Metric_DER": {
"derivative": {
"buckets_path": "DBF_Metric_AVG"
}
},
"DBF_Speed": {
"max": {
"field": "interface.ifHighSpeed",
"script": {
"inline": "_value*1000000"
}
}
},
"DBF_Metric_Percent": {
"bucket_script": {
"buckets_path": {
"my_var1": "DBF_Metric_DER",
"my_var2": "DBF_Speed"
},
"script": "(params.my_var1 * 100)/ params.my_var2"
}
},
"DBF_Bucket_filter": {
"bucket_selector": {
"buckets_path": {
"my_var3": "DBF_Metric_Percent"
},
"script": "params.my_var3 > 100000000"
}
}
}
}
}
}
}
}
}
}
And I get this output:
{
"error": {
"root_cause": [],
"type": "search_phase_execution_exception",
"reason": "",
"phase": "fetch",
"grouped": true,
"failed_shards": [],
"caused_by": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"params.my_var3 > 100000000",
" ^---- HERE"
],
"script": "params.my_var3 > 100000000",
"lang": "painless",
"caused_by": {
"type": "null_pointer_exception",
"reason": null
}
}
},
"status": 503
}
Query works fine if I remove bucket_selector part. If in bucket_selector I replace DBF_Metric_Percent with DBF_Speed query also works fine.