-
Notifications
You must be signed in to change notification settings - Fork 56
New Regex flag to filter container using Regex String. #69
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
c732771
98dcf39
14f1865
4902ea4
c96daea
3096fc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,10 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/) | |
|
|
||
| ## [Unreleased] | ||
|
|
||
| ## [3.1.2] - 2018 | ||
| ### Added | ||
| - metrics-docker-stats.rb: New Regex flag to filter container using Regex String. | ||
|
||
|
|
||
| ## [3.1.1] - 2018 | ||
| ### Fixed | ||
| - check-container-logs.rb: fix nil.gsub condition on empty log lines | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,6 +66,12 @@ class DockerStatsMetrics < Sensu::Plugin::Metric::CLI::Graphite | |
| long: '--container-name CONTAINER', | ||
| default: '' | ||
|
|
||
| option :container_list_regex, | ||
| description: 'Regex for container list to collect metrics for', | ||
| short: '-R CONTAINER_LIST_REGEX', | ||
| long: '--container-list-regex CONTAINER_LIST_REGEX', | ||
| default: '' | ||
|
||
|
|
||
| option :docker_host, | ||
| description: 'Docker API URI. https://host, https://host:port, http://host, http://host:port, host:port, unix:///path', | ||
| short: '-H DOCKER_HOST', | ||
|
|
@@ -109,12 +115,24 @@ class DockerStatsMetrics < Sensu::Plugin::Metric::CLI::Graphite | |
| boolean: true, | ||
| default: false | ||
|
|
||
| def create_container_list(container_list, pattern) | ||
| matched_list = [] | ||
| container_list.each do |container| | ||
| if container =~ /#{pattern}/ | ||
| matched_list.push(container) | ||
| end | ||
| end | ||
| matched_list | ||
| end | ||
|
|
||
| def run | ||
| @timestamp = Time.now.to_i | ||
| @client = DockerApi.new(config[:docker_host]) | ||
|
|
||
| list = if config[:container] != '' | ||
| [config[:container]] | ||
| elsif config[:container_list_regex] != '' | ||
|
||
| create_container_list(list_containers, config[:container_list_regex]) | ||
| else | ||
| list_containers | ||
| end | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general the versioning and dating are left to the maintainers for several reasons: