diagnose

package
v0.0.0-...-bc6a047 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 30 Imported by: 6

README

package diagnose

This package is used to register and run agent diagnostics which validates various aspects of agent installation, configuration and run-time environment.

Running agent diagnose all

Details and command line options are specified in agent diagnose command You can run all registered diagnosis with the diagnose command on the agent

The flare command will also run registered diagnosis and output them in a diagnose.log file.

Registering a new diagnose suite

All function and structures details can be found in loader.go file.

To register a diagnose suite one need to register a function which returns []diagnosis.Diagnosis.

Example from loader.go file:

package connectivity

import (
    ...
	"github.com/DataDog/datadog-agent/pkg/diagnose/diagnosis"
    ...
)
...
func init() {
	diagnosis.Register("connectivity-datadog-core-endpoints", diagnose)
}
...
func diagnose(diagCfg diagnosis.Config) []diagnosis.Diagnosis {
    ...
    var diagnoses []diagnosis.Diagnosis
    ...
	for _, domainResolver := range domainResolvers {
        ...
		for _, apiKey := range domainResolver.GetAPIKeys() {
			for _, endpointInfo := range endpointsInfo {
                ...
				name := "Connectivity to " + logURL
				if reportErr == nil {
					diagnoses = append(diagnoses, diagnosis.Diagnosis{
						Result:    diagnosis.DiagnosisSuccess,
						Name:      name,
						Diagnosis: fmt.Sprintf("Connectivity to `%s` is Ok\n%s", logURL, report),
					})
				} else {
					diagnoses = append(diagnoses, diagnosis.Diagnosis{
						Result:      diagnosis.DiagnosisFail,
						Name:        name,
						Diagnosis:   fmt.Sprintf("Connection to `%s` failed\n%s", logURL, report),
						Remediation: "Please validate Agent configuration and firewall to access " + logURL,
						RawError:    err,
					})
				}
			}
		}
	}

	return diagnoses
}

Context of a diagnose function execution

Normally, registered diagnose suite functions will be executed in context of the running agent service (or other services) but if Config.ForceLocal configuration is specified the registered diagnose function will be executed in the context of agent diagnose CLI command (if possible).

Documentation

Overview

Package diagnose provides the diagnose functionality for the Agent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListStdOut

func ListStdOut(w io.Writer, diagCfg diagnosis.Config)

ListStdOut enumerates registered Diagnose suites and get their diagnoses for human consumption

func RegisterCheckDatadog

func RegisterCheckDatadog(checkDatadog func() []diagnosis.Diagnosis) func(catalog *diagnosis.Catalog)

RegisterCheckDatadog registers the check-datadog diagnose suite.

func RegisterConnectivityAutodiscovery

func RegisterConnectivityAutodiscovery(catalog *diagnosis.Catalog)

RegisterConnectivityAutodiscovery registers the connectivity-datadog-autodiscovery diagnose suite.

func RegisterConnectivityDatadogCoreEndpoints

func RegisterConnectivityDatadogCoreEndpoints(diagCfg diagnosis.Config) func(catalog *diagnosis.Catalog)

RegisterConnectivityDatadogCoreEndpoints registers the connectivity-datadog-core-endpoints diagnose suite.

func RegisterConnectivityDatadogEventPlatform

func RegisterConnectivityDatadogEventPlatform(catalog *diagnosis.Catalog)

RegisterConnectivityDatadogEventPlatform registers the connectivity-datadog-event-platform diagnose suite.

func RegisterPortConflict

func RegisterPortConflict(catalog *diagnosis.Catalog)

RegisterPortConflict registers the port-conflict diagnose suite.

func RunDiagnose

func RunDiagnose(diagCfg diagnosis.Config, getSuites func() []diagnosis.Suite) (*diagnosis.DiagnoseResult, error)

RunDiagnose runs diagnoses.

func RunDiagnoseStdOut

func RunDiagnoseStdOut(w io.Writer, diagCfg diagnosis.Config, diagnoses *diagnosis.DiagnoseResult) error

RunDiagnoseStdOut runs the diagnose and outputs the results to the writer.

func RunInAgentProcess

func RunInAgentProcess(diagCfg diagnosis.Config, deps SuitesDepsInAgentProcess) (*diagnosis.DiagnoseResult, error)

RunInAgentProcess runs diagnoses in the Agent process.

func RunInCLIProcess

func RunInCLIProcess(diagCfg diagnosis.Config, deps SuitesDepsInCLIProcess) (*diagnosis.DiagnoseResult, error)

RunInCLIProcess run diagnoses in the CLI process.

func RunLocalCheck

func RunLocalCheck(diagCfg diagnosis.Config, registries ...func(*diagnosis.Catalog)) (*diagnosis.DiagnoseResult, error)

RunLocalCheck runs locally the checks created by the registries.

Types

type SuitesDeps

type SuitesDeps struct {
	SenderManager  sender.DiagnoseSenderManager
	Collector      optional.Option[collector.Component]
	SecretResolver secrets.Component
	WMeta          optional.Option[workloadmeta.Component]
	AC             autodiscovery.Component
	Tagger         tagger.Component
}

SuitesDeps stores the dependencies for the diagnose suites.

func NewSuitesDeps

NewSuitesDeps returns a new SuitesDeps.

func (*SuitesDeps) GetWMeta

GetWMeta returns the workload metadata instance

type SuitesDepsInAgentProcess

type SuitesDepsInAgentProcess struct {
	// contains filtered or unexported fields
}

SuitesDepsInAgentProcess stores the dependencies for the diagnose suites when running the Agent Process.

func NewSuitesDepsInAgentProcess

func NewSuitesDepsInAgentProcess(collector collector.Component) SuitesDepsInAgentProcess

NewSuitesDepsInAgentProcess returns a new instance of SuitesDepsInAgentProcess.

type SuitesDepsInCLIProcess

type SuitesDepsInCLIProcess struct {
	AC autodiscovery.Component
	// contains filtered or unexported fields
}

SuitesDepsInCLIProcess stores the dependencies for the diagnose suites when running the CLI Process.

func NewSuitesDepsInCLIProcess

func NewSuitesDepsInCLIProcess(
	senderManager sender.DiagnoseSenderManager,
	secretResolver secrets.Component,
	wmeta optional.Option[workloadmeta.Component],
	ac autodiscovery.Component,
	tagger tagger.Component,
) SuitesDepsInCLIProcess

NewSuitesDepsInCLIProcess returns a new instance of SuitesDepsInCLIProcess.

Directories

Path Synopsis
Package connectivity contains logic for connectivity troubleshooting between the Agent and Datadog endpoints.
Package connectivity contains logic for connectivity troubleshooting between the Agent and Datadog endpoints.
Package diagnosis contains types used by the "agent diagnose" command.
Package diagnosis contains types used by the "agent diagnose" command.
Package ports provides a diagnose suite for the ports used in the agent configuration
Package ports provides a diagnose suite for the ports used in the agent configuration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL