forked from knyar/prometheus-remote-backfill
-
Notifications
You must be signed in to change notification settings - Fork 2
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
default tar filename has extra dash in custom metric mode #31
Open
karishmalalani
wants to merge
7
commits into
yugabyte:master
Choose a base branch
from
karishmalalani:file-archive
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+34
−7
Open
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
60f9a7f
default tar filename has extra dash in custom metric mode
06f7a33
Merge branch 'master' into file-archive
3f68e30
Merge branch 'master' into file-archive
5be619b
default tar filename has extra dash in custom metric mode
f48b879
Revert "default tar filename has extra dash in custom metric mode"
aa8dd48
Filename has extra dash in custom metric mode
8951996
Use strings.Builder
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
Filename has extra dash in custom metric mode
Changes were made as per feedback
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 |
---|---|---|
|
@@ -646,39 +646,30 @@ func addToArchive(tw *tar.Writer, filename string) error { | |
} | ||
|
||
func generateDefaultTarFilename() string { | ||
var prefix string | ||
|
||
// Define a regular expression to match the node_prefix key-value pair in the metric string | ||
re := regexp.MustCompile(`node_prefix="([^"]+)"`) | ||
var filename string | ||
|
||
// Try to extract node_prefix from the metric | ||
if *metric != "" { | ||
matches := re.FindStringSubmatch(*metric) | ||
if len(matches) > 1 { | ||
prefix = matches[1] // Use the captured node_prefix value | ||
} | ||
} | ||
// Start with the default prefix "promdump" | ||
filename = "promdump" | ||
|
||
// If node_prefix is not found in metric, use nodePrefix flag | ||
if prefix == "" && *nodePrefix != "" { | ||
prefix = *nodePrefix | ||
} | ||
// Check if nodePrefix is provided and append it to the filename if not empty | ||
if nodePrefix != nil && *nodePrefix != "" { | ||
filename = fmt.Sprintf("%s-%s", filename, *nodePrefix) | ||
|
||
// If neither is available, use a default prefix | ||
if prefix == "" { | ||
return fmt.Sprintf("promdump-%s.tar", time.Now().Format("20060102-150405")) | ||
} | ||
|
||
// Generate the filename based on the compression type | ||
switch *tarCompression { | ||
case "gzip": | ||
return fmt.Sprintf("promdump-%s-%s.tar.gz", prefix, time.Now().Format("20060102-150405")) | ||
case "bzip2": | ||
return fmt.Sprintf("promdump-%s-%s.tar.bz2", prefix, time.Now().Format("20060102-150405")) | ||
default: | ||
return fmt.Sprintf("promdump-%s-%s.tar", prefix, time.Now().Format("20060102-150405")) | ||
// Append the timestamp | ||
filename = fmt.Sprintf("%s-%s", filename, time.Now().Format("20060102-150405")) | ||
if tarCompression != nil { | ||
switch *tarCompression { | ||
case "gzip": | ||
return filename + ".tar.gz" | ||
case "bzip2": | ||
return filename + ".tar.bz2" | ||
} | ||
} | ||
|
||
// Default to ".tar" if no compression type is specified | ||
return filename + ".tar" | ||
} | ||
|
||
func getBatch(ctx context.Context, promApi v1.API, metric string, beginTS time.Time, endTS time.Time, periodDur time.Duration, batchDur time.Duration) ([]*model.SampleStream, error) { | ||
|
@@ -1427,6 +1418,14 @@ func main() { | |
} | ||
} | ||
} | ||
if *out != "" { | ||
|
||
_, err := cleanFiles(*out, customMetricCount, false) | ||
if err != nil { | ||
log.Printf("Error cleaning files : %v", err) | ||
} | ||
|
||
} | ||
Comment on lines
+1424
to
+1431
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. Please keep changes to one issue per PR. |
||
} else { | ||
logger.Println("main: preserving metric export files because the --keep_files flag is set") | ||
} | ||
|
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.
The
nodePrefix != nil
portion of this conditional is spurious. This condition will always be true since it's a pointer to a (possibly nil) string. Simplify this toif *nodePrefix != "" {
.