-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
sidecar: time limit requests to Prometheus remote read api #1267
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -37,6 +37,8 @@ func registerSidecar(m map[string]setupFunc, app *kingpin.Application, name stri | |||||
promURL := cmd.Flag("prometheus.url", "URL at which to reach Prometheus's API. For better performance use local network."). | ||||||
Default("http://localhost:9090").URL() | ||||||
|
||||||
promRetention := modelDuration(cmd.Flag("prometheus.retention", "A limit on how much retention to query from Prometheus. 0d means query all TSDB data found on disk").Default("0d")) | ||||||
|
||||||
dataDir := cmd.Flag("tsdb.path", "Data directory of TSDB."). | ||||||
Default("./data").String() | ||||||
|
||||||
|
@@ -71,6 +73,7 @@ func registerSidecar(m map[string]setupFunc, app *kingpin.Application, name stri | |||||
*clientCA, | ||||||
*httpBindAddr, | ||||||
*promURL, | ||||||
time.Duration(*promRetention), | ||||||
*dataDir, | ||||||
objStoreConfig, | ||||||
rl, | ||||||
|
@@ -90,6 +93,7 @@ func runSidecar( | |||||
clientCA string, | ||||||
httpBindAddr string, | ||||||
promURL *url.URL, | ||||||
promRetention time.Duration, | ||||||
dataDir string, | ||||||
objStoreConfig *pathOrContent, | ||||||
reloader *reloader.Reloader, | ||||||
|
@@ -100,8 +104,9 @@ func runSidecar( | |||||
|
||||||
// Start out with the full time range. The shipper will constrain it later. | ||||||
// TODO(fabxc): minimum timestamp is never adjusted if shipping is disabled. | ||||||
mint: 0, | ||||||
maxt: math.MaxInt64, | ||||||
mint: 0, | ||||||
maxt: math.MaxInt64, | ||||||
limit: promRetention, | ||||||
} | ||||||
|
||||||
confContentYaml, err := objStoreConfig.Content() | ||||||
|
@@ -318,6 +323,7 @@ type promMetadata struct { | |||||
mtx sync.Mutex | ||||||
mint int64 | ||||||
maxt int64 | ||||||
limit time.Duration | ||||||
labels labels.Labels | ||||||
} | ||||||
|
||||||
|
@@ -337,8 +343,21 @@ func (s *promMetadata) UpdateLabels(ctx context.Context, logger log.Logger) erro | |||||
func (s *promMetadata) UpdateTimestamps(mint int64, maxt int64) { | ||||||
s.mtx.Lock() | ||||||
defer s.mtx.Unlock() | ||||||
var limitt int64 | ||||||
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.
Suggested change
|
||||||
|
||||||
// Calculate our limit on how far back in time we query Prometheus. | ||||||
// Long term retention should be accessible via a Store component, | ||||||
// therefore, its possible we can ignore anything older than a few days on | ||||||
// the local Prometheus. This is disabled if limit == 0. | ||||||
if s.limit > 0 { | ||||||
limitt = int64(model.Now().Add(-s.limit)) | ||||||
} | ||||||
|
||||||
s.mint = mint | ||||||
if mint < limitt { | ||||||
s.mint = limitt | ||||||
} else { | ||||||
s.mint = mint | ||||||
} | ||||||
s.maxt = maxt | ||||||
} | ||||||
|
||||||
|
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
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.
Curious about this. Should we do retention? I would rather see
storeapi.min-time
with similar model to specify both relative and absolute time as here: #1077This is to keep it consistent with potential store gateway time partitioning.
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.
This was what I struggled with most -- how to name and handle this argument. I'll take a look at implementing the suggestions. I'm all about consistency.
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.
yy, if we are doing this then
--storeapi.min-time
,--storeapi.max-time
sounds like good options.You can copy paste the https://github.com/thanos-io/thanos/pull/1077/files#diff-dd29e6298d43e46bb651035051819cfcR14 class from my PR, to make it take same exact format.
And I will merge once I find time to finish my PR