Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the possibility of other aggregations #153

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)

## [Unreleased]
### Changed
- elasticsearch-query.rb: changed literal aggregation name and 'type' to config vars
- check-es-query-average.rb: changed literal aggregation name average and type avg to use the new config vars

## [4.0.0] - 2019-05-07
### Breaking Changes
Expand Down
2 changes: 2 additions & 0 deletions bin/check-es-query-average.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ def kibana_info
end

def run
config[:aggr_name] = 'average'
config[:aggr_type] = 'avg'
response = client.search(build_request_options)
if config[:invert]
if response['aggregations']['average']['value'] < config[:crit]
Expand Down
2 changes: 1 addition & 1 deletion lib/sensu-plugins-elasticsearch/elasticsearch-query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def build_request_options
}
},
'aggregations' => {
'average' => { 'avg' => { 'field' => config[:aggr_field] } }
config[:aggr_name] => { config[:aggr_type] => { 'field' => config[:aggr_field] } }
}
}
else
Expand Down