Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion internal/pkg/agent/cmd/apply_flavor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
11 changes: 3 additions & 8 deletions internal/pkg/agent/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ package cmd

import (
"flag"
"fmt"
"os"
"strings"

"github.com/spf13/cobra"

Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/cmd/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,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{}) {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/cmd/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
},
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/cmd/enroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,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 := enroll(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)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/agent/cmd/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,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)
}
},
Expand Down Expand Up @@ -111,7 +111,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)
}
},
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/cmd/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
},
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/cmd/privileged.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
},
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/cmd/reexec_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
7 changes: 3 additions & 4 deletions internal/pkg/agent/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,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
Expand Down Expand Up @@ -351,7 +351,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
}
Expand Down Expand Up @@ -710,12 +710,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
}

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
},
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/cmd/unprivileged.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
},
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,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)
}
},
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/agent/cmd/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,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)
}

Expand All @@ -55,7 +55,7 @@ func newWatchCommandWithArgs(_ []string, streams *cli.IOStreams) *cobra.Command

if err := watchCmd(log, cfg); 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)
}
},
Expand Down