-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Setting Prometheus Remote_write Period default value to 1m #38553
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
22f93e2
Correcting period for Prometheus remote_write
gizas fc75d6c
Merge branch 'main' of github.com:elastic/beats
gizas 102f805
Correcting period for Prometheus remote_write
gizas d905adf
Adding changelog
gizas f0ec4f7
Updating metricbeat.reference.yaml file
gizas 0517a07
Update x-pack/metricbeat/metricbeat.reference.yml
gizas cd5056b
Update x-pack/metricbeat/module/prometheus/remote_write/data.go
gizas f5c20ab
Update CHANGELOG.next.asciidoc
gizas c0e4a0c
Merge branch 'main' into remote_write_ratefix
gizas 89369c7
Correcting typos and referring to correct variable
gizas 300b1f7
Fixing conflicts
gizas cbc2d4c
Adding default value to config period of remote_write
gizas 0802621
Adding default value to config period of remote_write
gizas 11831b4
Removing spaces from doc
gizas 3fbe7c0
Merge branch 'main' into remote_write_ratefix
gizas 4cfcf01
Moving check functions to validate inside config
gizas f82c624
Moving check functions to validate inside config
gizas 0cd2e64
Merge branch 'main' into remote_write_ratefix
gizas d1d18f4
Updating reference file
gizas 6ae51f8
After running make check
gizas 689422c
Merge branch 'main' into remote_write_ratefix
gizas a696943
Merge branch 'main' into remote_write_ratefix
gizas cbf265f
Merge branch 'main' of github.com:elastic/beats into remote_write_rat…
gizas b1b674a
Merge branch 'remote_write_ratefix' of github.com:elastic/beats into …
gizas d709ca0
Merge branch 'main' into remote_write_ratefix
gizas 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 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 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 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 |
---|---|---|
|
@@ -4,12 +4,16 @@ | |
|
||
package remote_write | ||
|
||
import "errors" | ||
import ( | ||
"errors" | ||
"time" | ||
) | ||
|
||
type config struct { | ||
UseTypes bool `config:"use_types"` | ||
RateCounters bool `config:"rate_counters"` | ||
TypesPatterns TypesPatterns `config:"types_patterns" yaml:"types_patterns,omitempty"` | ||
Period time.Duration `config:"period" validate:"positive"` | ||
} | ||
|
||
type TypesPatterns struct { | ||
|
@@ -21,12 +25,21 @@ var defaultConfig = config{ | |
TypesPatterns: TypesPatterns{ | ||
CounterPatterns: nil, | ||
HistogramPatterns: nil}, | ||
Period: time.Second * 60, | ||
} | ||
|
||
func (c *config) Validate() error { | ||
if c.RateCounters && !c.UseTypes { | ||
return errors.New("'rate_counters' can only be enabled when `use_types` is also enabled") | ||
} | ||
|
||
duration, err := time.ParseDuration(c.Period.String()) | ||
{ | ||
if err != nil { | ||
return err | ||
} else if duration < 60*time.Second { | ||
// by default prometheus push data with the interval 60s, in order to calculate counter rate we are setting Period to 60secs accordingly | ||
c.Period = time.Second * 60 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we log a warning saying the period needs to be at least 60s? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
} | ||
return nil | ||
} |
This file contains 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
Oops, something went wrong.
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.
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.
could this function be a better fit for the
period
validation? check can be moved here with the info log message regarding the min valueThere 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.
I moved this to the Validate() 4cfcf01