From 8d3cab91d48913a86c4508071fc1621d299db61f Mon Sep 17 00:00:00 2001 From: Yoann La Cancellera Date: Tue, 23 Jan 2024 09:42:37 +0100 Subject: [PATCH] pt-galera-log-explainer: add --skip-merge, grep -a --skip-merge can help for cases where merge won't work: node names intentionally identical grep -a enables to read logs even though they use binary format --- src/go/pt-galera-log-explainer/internal.go | 4 ++-- src/go/pt-galera-log-explainer/main.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/go/pt-galera-log-explainer/internal.go b/src/go/pt-galera-log-explainer/internal.go index cda4b39a..0b1bb079 100644 --- a/src/go/pt-galera-log-explainer/internal.go +++ b/src/go/pt-galera-log-explainer/internal.go @@ -69,7 +69,7 @@ func timelineFromPaths(paths []string, regexes types.RegexMap) (types.Timeline, // Why it should not just identify using the file path: // so that we are able to merge files that belong to the same nodes // we wouldn't want them to be shown as from different nodes - if CLI.PxcOperator { + if CLI.PxcOperator || CLI.SkipMerge { timeline[path] = localTimeline } else if CLI.MergeByDirectory { timeline.MergeByDirectory(path, localTimeline) @@ -129,7 +129,7 @@ func execGrepAndIterate(path, compiledRegex string, stdout chan<- string) error logger.Warn().Msg("On Darwin systems, use 'pt-galera-log-explainer --grep-cmd=ggrep' as it requires grep v3") } - cmd := exec.Command(CLI.GrepCmd, "-P", compiledRegex, path) + cmd := exec.Command(CLI.GrepCmd, "-a", "-P", compiledRegex, path) out, err := cmd.StdoutPipe() if err != nil { diff --git a/src/go/pt-galera-log-explainer/main.go b/src/go/pt-galera-log-explainer/main.go index 126a728f..2fa57200 100644 --- a/src/go/pt-galera-log-explainer/main.go +++ b/src/go/pt-galera-log-explainer/main.go @@ -35,9 +35,10 @@ var CLI struct { PxcOperator bool `default:"false" help:"Analyze logs from Percona PXC operator. Off by default because it negatively impacts performance for non-k8s setups"` ExcludeRegexes []string `help:"Remove regexes from analysis. List regexes using 'pt-galera-log-explainer regex-list'"` MergeByDirectory bool `help:"Instead of relying on identification, merge contexts and columns by base directory. Very useful when dealing with many small logs organized per directories."` + SkipMerge bool `help:"Disable the ability to merge log files together. Can be used when every nodes have the same wsrep_node_name"` List list `cmd:""` - //Whois whois `cmd:""` + //Whois whois `cmd:""` // Sed sed `cmd:""` Ctx ctx `cmd:""` RegexList regexList `cmd:""`