diagnose/

directory
v0.0.0-...-a5a9a89 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0

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).

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 firewallscanner contains logic for diagnosing firewall rules that may prevent services such as SNMP traps or Netflow from running correctly.
Package firewallscanner contains logic for diagnosing firewall rules that may prevent services such as SNMP traps or Netflow from running correctly.
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