-
Notifications
You must be signed in to change notification settings - Fork 5k
Add filtering option for prometheus collector #16420
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
Merged
ChrsMark
merged 14 commits into
elastic:master
from
ChrsMark:prometheus_metrics_filtering
Feb 24, 2020
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
44da42e
Add filtering option for prometheus collector
ChrsMark 470c66c
improvements
ChrsMark 7bd9a5b
Remove validation for filter co-existance
ChrsMark 67c75bc
Introduce pattern precompilation
ChrsMark c8a88a8
Remove commented code
ChrsMark d7964d9
Return regexp compiling errors
ChrsMark af59dff
review fixes
ChrsMark fcbd275
Add unit tests
ChrsMark 4e9e939
fmt update
ChrsMark 54324fe
improvements
ChrsMark 8c6a7d4
Add docs
ChrsMark 878546b
Add changelog entry
ChrsMark 4bd73a4
Merge remote-tracking branch 'upstream/master' into prometheus_metric…
ChrsMark 811ffd6
make update
ChrsMark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // Licensed to Elasticsearch B.V. under one or more contributor | ||
| // license agreements. See the NOTICE file distributed with | ||
| // this work for additional information regarding copyright | ||
| // ownership. Elasticsearch B.V. licenses this file to you under | ||
| // the Apache License, Version 2.0 (the "License"); you may | ||
| // not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| package collector | ||
|
|
||
| import ( | ||
| "github.com/elastic/beats/libbeat/logp" | ||
| ) | ||
|
|
||
| type metricsetConfig struct { | ||
| MetricsFilters MetricFilters `config:"metrics_filters"` | ||
| } | ||
|
|
||
| type MetricFilters struct { | ||
| IncludeMetrics *[]string `config:"include_metrics"` | ||
| IgnoreMetrics *[]string `config:"ignore_metrics"` | ||
|
jsoriano marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| var defaultConfig = metricsetConfig{ | ||
| MetricsFilters: MetricFilters{ | ||
| IncludeMetrics: nil, | ||
| IgnoreMetrics: nil}, | ||
| } | ||
|
|
||
| func (c *metricsetConfig) Validate() error { | ||
| if c.MetricsFilters.IncludeMetrics != nil && c.MetricsFilters.IgnoreMetrics == nil { | ||
| logp.Debug("prometheus", "include_metrics and ignore_metrics are complementary and cannot be used together. Falling back to using only include_metrics") | ||
|
jsoriano marked this conversation as resolved.
Outdated
|
||
| c.MetricsFilters.IgnoreMetrics = nil | ||
| } | ||
| return nil | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.