diff --git a/changelog/fragments/1759335344-fix-troubleshooting-message-url-for-versions-after-9.yaml b/changelog/fragments/1759335344-fix-troubleshooting-message-url-for-versions-after-9.yaml new file mode 100644 index 00000000000..2883c5388d9 --- /dev/null +++ b/changelog/fragments/1759335344-fix-troubleshooting-message-url-for-versions-after-9.yaml @@ -0,0 +1,42 @@ +# REQUIRED +# Kind can be one of: +# - breaking-change: a change to previously-documented behavior +# - deprecation: functionality that is being removed in a later release +# - bug-fix: fixes a problem in a previous version +# - enhancement: extends functionality but does not break or fix existing behavior +# - feature: new functionality +# - known-issue: problems that we are aware of in a given version +# - security: impacts on the security of a product or a user’s deployment. +# - upgrade: important information for someone upgrading from a prior version +# - other: does not fit into any of the other categories +kind: bug-fix + +# REQUIRED for all kinds +# Change summary; a 80ish characters long description of the change. +summary: Fix troubleshooting docs URL for 9.x+ to prevent invalid version links +# this field accommodate a description without length limits. +# description: + +# REQUIRED for breaking-change, deprecation, known-issue +# impact: + +# REQUIRED for breaking-change, deprecation, known-issue +# action: + +# REQUIRED for all kinds +# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc. +component: elastic-agent + +# AUTOMATED +# OPTIONAL to manually add other PR URLs +# PR URL: A link the PR that added the changeset. +# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added. +# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number. +# Please provide it if you are adding a fragment for a different PR. +# pr: https://github.com/owner/repo/1234 + +# AUTOMATED +# OPTIONAL to manually add other issue URLs +# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of). +# If not present is automatically filled by the tooling with the issue linked to the PR number. +# issue: https://github.com/owner/repo/1234 diff --git a/internal/pkg/agent/cmd/apply_flavor.go b/internal/pkg/agent/cmd/apply_flavor.go index f184df21185..d5051a3cb5c 100644 --- a/internal/pkg/agent/cmd/apply_flavor.go +++ b/internal/pkg/agent/cmd/apply_flavor.go @@ -24,7 +24,7 @@ func newApplyFlavorCommandWithArgs(_ []string, streams *cli.IOStreams) *cobra.Co Short: "Apply Flavor cleans up unnecessary components from agent installation directory", Run: func(c *cobra.Command, _ []string) { if err := applyCmd(); err != nil { - fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage) logExternal(fmt.Sprintf("%s apply flavor failed: %s", paths.BinaryName, err)) os.Exit(1) } diff --git a/internal/pkg/agent/cmd/common.go b/internal/pkg/agent/cmd/common.go index 5c98b07cff9..f6772fd4861 100644 --- a/internal/pkg/agent/cmd/common.go +++ b/internal/pkg/agent/cmd/common.go @@ -6,9 +6,7 @@ package cmd import ( "flag" - "fmt" "os" - "strings" "github.com/spf13/cobra" @@ -17,15 +15,12 @@ import ( "github.com/elastic/elastic-agent/internal/pkg/basecmd" "github.com/elastic/elastic-agent/internal/pkg/cli" - "github.com/elastic/elastic-agent/internal/pkg/release" "github.com/elastic/elastic-agent/version" ) -func troubleshootMessage() string { - v := strings.Split(release.Version(), ".") - version := strings.Join(v[:2], ".") - return fmt.Sprintf("For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/%s/fleet-troubleshooting.html", version) -} +const ( + troubleshootMessage = "For help, please see our troubleshooting guide at https://www.elastic.co/docs/troubleshoot/ingest/fleet/common-problems" +) // NewCommand returns the default command for the agent. func NewCommand() *cobra.Command { diff --git a/internal/pkg/agent/cmd/container.go b/internal/pkg/agent/cmd/container.go index df211417491..a9b1be3eab1 100644 --- a/internal/pkg/agent/cmd/container.go +++ b/internal/pkg/agent/cmd/container.go @@ -170,7 +170,7 @@ occurs on every start of the container set FLEET_FORCE to 1. } func logError(streams *cli.IOStreams, err error) { - fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage) } func logInfo(streams *cli.IOStreams, a ...interface{}) { diff --git a/internal/pkg/agent/cmd/diagnostics.go b/internal/pkg/agent/cmd/diagnostics.go index ef13a4704a2..b9bb8317718 100644 --- a/internal/pkg/agent/cmd/diagnostics.go +++ b/internal/pkg/agent/cmd/diagnostics.go @@ -28,7 +28,7 @@ func newDiagnosticsCommand(_ []string, streams *cli.IOStreams) *cobra.Command { Long: "This command gathers diagnostics information from the Elastic Agent and writes it to a zip archive.", Run: func(c *cobra.Command, args []string) { if err := diagnosticCmd(streams, c); err != nil { - fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage) os.Exit(1) } }, diff --git a/internal/pkg/agent/cmd/diagnostics_otel.go b/internal/pkg/agent/cmd/diagnostics_otel.go index 8b4685e46ec..05a4c78b455 100644 --- a/internal/pkg/agent/cmd/diagnostics_otel.go +++ b/internal/pkg/agent/cmd/diagnostics_otel.go @@ -25,7 +25,7 @@ func newOtelDiagnosticsCommand(streams *cli.IOStreams) *cobra.Command { Long: "This command gathers diagnostics information from the EDOT and writes it to a zip archive", RunE: func(cmd *cobra.Command, _ []string) error { if err := otelDiagnosticCmd(streams, cmd); err != nil { - fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage) os.Exit(1) } return nil diff --git a/internal/pkg/agent/cmd/enroll.go b/internal/pkg/agent/cmd/enroll.go index 48a7de905a0..b80d81f7d59 100644 --- a/internal/pkg/agent/cmd/enroll.go +++ b/internal/pkg/agent/cmd/enroll.go @@ -45,7 +45,7 @@ func newEnrollCommandWithArgs(_ []string, streams *cli.IOStreams) *cobra.Command Long: "This command will enroll the Elastic Agent into Fleet.", Run: func(c *cobra.Command, args []string) { if err := doEnroll(streams, c); err != nil { - fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage) logExternal(fmt.Sprintf("%s enroll failed: %s", paths.BinaryName, err)) os.Exit(1) } diff --git a/internal/pkg/agent/cmd/inspect.go b/internal/pkg/agent/cmd/inspect.go index 8caa4840636..55b7b20455c 100644 --- a/internal/pkg/agent/cmd/inspect.go +++ b/internal/pkg/agent/cmd/inspect.go @@ -62,7 +62,7 @@ wait that amount of time before using the variables for the configuration. ctx, cancel := context.WithCancel(context.Background()) service.HandleSignals(func() {}, cancel) if err := inspectConfig(ctx, paths.ConfigFile(), opts, streams); err != nil { - fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage) os.Exit(1) } }, @@ -115,7 +115,7 @@ variables for the configuration. service.HandleSignals(func() {}, cancel) if err := inspectComponents(ctx, paths.ConfigFile(), opts, streams); err != nil { - fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage) os.Exit(1) } }, diff --git a/internal/pkg/agent/cmd/install.go b/internal/pkg/agent/cmd/install.go index 9e48532c9ae..8c4ff4e941e 100644 --- a/internal/pkg/agent/cmd/install.go +++ b/internal/pkg/agent/cmd/install.go @@ -49,7 +49,7 @@ would like the Agent to operate. `, Run: func(c *cobra.Command, _ []string) { if err := installCmd(streams, c); err != nil { - fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage) logExternal(fmt.Sprintf("%s install failed: %s", paths.BinaryName, err)) os.Exit(1) } diff --git a/internal/pkg/agent/cmd/logs.go b/internal/pkg/agent/cmd/logs.go index 76978057de5..21009602d99 100644 --- a/internal/pkg/agent/cmd/logs.go +++ b/internal/pkg/agent/cmd/logs.go @@ -170,7 +170,7 @@ func newLogsCommandWithArgs(_ []string, streams *cli.IOStreams) *cobra.Command { Long: "This command allows to output, watch and filter Elastic Agent logs.", Run: func(c *cobra.Command, _ []string) { if err := logsCmd(streams, c, logsDir, eventLogsDir); err != nil { - fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage) os.Exit(1) } }, diff --git a/internal/pkg/agent/cmd/privileged.go b/internal/pkg/agent/cmd/privileged.go index 2d462ec16d9..29b4a611d32 100644 --- a/internal/pkg/agent/cmd/privileged.go +++ b/internal/pkg/agent/cmd/privileged.go @@ -34,7 +34,7 @@ privileged it will still perform all the same work, including stopping and start Args: cobra.ExactArgs(0), Run: func(c *cobra.Command, args []string) { if err := privilegedCmd(streams, c); err != nil { - fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage) os.Exit(1) } }, diff --git a/internal/pkg/agent/cmd/reexec_windows.go b/internal/pkg/agent/cmd/reexec_windows.go index 9b9a727cf9f..e0322a264bb 100644 --- a/internal/pkg/agent/cmd/reexec_windows.go +++ b/internal/pkg/agent/cmd/reexec_windows.go @@ -37,7 +37,7 @@ func newReExecWindowsCommand(_ []string, streams *cli.IOStreams) *cobra.Command cfg := getConfig(streams) log, err := configuredLogger(cfg, reexecName) if err != nil { - fmt.Fprintf(streams.Err, "Error configuring logger: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Error configuring logger: %v\n%s\n", err, troubleshootMessage) os.Exit(3) } diff --git a/internal/pkg/agent/cmd/run.go b/internal/pkg/agent/cmd/run.go index 73b3284e828..bc386c7263e 100644 --- a/internal/pkg/agent/cmd/run.go +++ b/internal/pkg/agent/cmd/run.go @@ -88,7 +88,7 @@ func newRunCommandWithArgs(_ []string, streams *cli.IOStreams) *cobra.Command { fleetInitTimeout, _ := cmd.Flags().GetDuration("fleet-init-timeout") testingMode, _ := cmd.Flags().GetBool("testing-mode") if err := run(nil, testingMode, fleetInitTimeout); err != nil && !errors.Is(err, context.Canceled) { - fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage) return err } return nil @@ -356,7 +356,7 @@ func runElasticAgent( return err } - monitoringServer, err := setupMetrics(l, cfg.Settings.DownloadConfig.OS(), cfg.Settings.MonitoringConfig, tracer, coord) + monitoringServer, err := setupMetrics(l, cfg.Settings.MonitoringConfig, tracer, coord) if err != nil { return err } @@ -715,12 +715,11 @@ func initTracer(agentName, version string, mcfg *monitoringCfg.MonitoringConfig) func setupMetrics( logger *logger.Logger, - operatingSystem string, cfg *monitoringCfg.MonitoringConfig, tracer *apm.Tracer, coord *coordinator.Coordinator, ) (*reload.ServerReloader, error) { - if err := report.SetupMetrics(logger, agentName, version.GetDefaultVersion()); err != nil { + if err := report.SetupMetrics(logger, agentName, version.GetDefaultVersion()); err != nil { //nolint:staticcheck // ignore deprecation return nil, err } diff --git a/internal/pkg/agent/cmd/status.go b/internal/pkg/agent/cmd/status.go index bdffc8e3420..581ceb1b7ed 100644 --- a/internal/pkg/agent/cmd/status.go +++ b/internal/pkg/agent/cmd/status.go @@ -44,7 +44,7 @@ func newStatusCommand(_ []string, streams *cli.IOStreams) *cobra.Command { Long: `This command shows the current status of the running Elastic Agent daemon.`, Run: func(c *cobra.Command, args []string) { if err := statusCmd(streams, c, args); err != nil { - fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage) os.Exit(1) } }, diff --git a/internal/pkg/agent/cmd/uninstall.go b/internal/pkg/agent/cmd/uninstall.go index a83df2e6055..fca0bc47f2b 100644 --- a/internal/pkg/agent/cmd/uninstall.go +++ b/internal/pkg/agent/cmd/uninstall.go @@ -28,7 +28,7 @@ Unless -f is used this command will ask confirmation before performing removal. `, Run: func(c *cobra.Command, _ []string) { if err := uninstallCmd(streams, c); err != nil { - fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage) logExternal(fmt.Sprintf("%s uninstall failed: %s", paths.BinaryName, err)) os.Exit(1) } diff --git a/internal/pkg/agent/cmd/unprivileged.go b/internal/pkg/agent/cmd/unprivileged.go index a6d7ea70f06..95a108d208c 100644 --- a/internal/pkg/agent/cmd/unprivileged.go +++ b/internal/pkg/agent/cmd/unprivileged.go @@ -36,7 +36,7 @@ unprivileged it will still perform all the same work, including stopping and sta Args: cobra.ExactArgs(0), Run: func(c *cobra.Command, args []string) { if err := unprivilegedCmd(streams, c); err != nil { - fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage) os.Exit(1) } }, diff --git a/internal/pkg/agent/cmd/upgrade.go b/internal/pkg/agent/cmd/upgrade.go index ce1c5fbffbc..1d47e640ab1 100644 --- a/internal/pkg/agent/cmd/upgrade.go +++ b/internal/pkg/agent/cmd/upgrade.go @@ -52,7 +52,7 @@ func newUpgradeCommandWithArgs(_ []string, streams *cli.IOStreams) *cobra.Comman Run: func(c *cobra.Command, args []string) { c.SetContext(context.Background()) if err := upgradeCmd(streams, c, args); err != nil { - fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage) os.Exit(1) } }, diff --git a/internal/pkg/agent/cmd/watch.go b/internal/pkg/agent/cmd/watch.go index ec8cc46d6a1..6cd1815abbd 100644 --- a/internal/pkg/agent/cmd/watch.go +++ b/internal/pkg/agent/cmd/watch.go @@ -63,7 +63,7 @@ func newWatchCommandWithArgs(_ []string, streams *cli.IOStreams) *cobra.Command cfg := getConfig(streams) log, err := configuredLogger(cfg, watcherName) if err != nil { - fmt.Fprintf(streams.Err, "Error configuring logger: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Error configuring logger: %v\n%s\n", err, troubleshootMessage) os.Exit(3) } @@ -106,7 +106,7 @@ func newWatchCommandWithArgs(_ []string, streams *cli.IOStreams) *cobra.Command return watchCmd(log, paths.Top(), cfg.Settings.Upgrade.Watcher, new(upgradeAgentWatcher), new(upgradeInstallationModifier)) }); err != nil { log.Errorw("Watch command failed", "error.message", err) - fmt.Fprintf(streams.Err, "Watch command failed: %v\n%s\n", err, troubleshootMessage()) + fmt.Fprintf(streams.Err, "Watch command failed: %v\n%s\n", err, troubleshootMessage) os.Exit(4) } },