diff --git a/cmd/agent/gui/views/templates/generalStatus.tmpl b/cmd/agent/gui/views/templates/generalStatus.tmpl index bece40e2162fb..fd993865c4cdc 100644 --- a/cmd/agent/gui/views/templates/generalStatus.tmpl +++ b/cmd/agent/gui/views/templates/generalStatus.tmpl @@ -268,24 +268,23 @@ {{- end}} {{- end -}} - {{/* The subsection `On-disk storage` is not inside `{{- with .forwarderStats -}}` as it need to access `.config` */}} - On-disk storage - - {{- if .config.forwarder_storage_max_size_in_bytes }} - {{- if .forwarderStats.FileStorage.CurrentSizeInBytes }} - Disk usage in bytes: {{ .forwarderStats.FileStorage.CurrentSizeInBytes }}
- Number of files: {{ .forwarderStats.FileStorage.FilesCount }}
- Number of files dropped: {{ .forwarderStats.FileStorage.FilesRemovedCount }}
- Deserialization errors count: {{ .forwarderStats.FileStorage.DeserializeErrorsCount }}
- Outdated files removed at startup: {{ .forwarderStats.RemovalPolicy.OutdatedFilesCount }}
+ {{- with .forwarderStats -}} + On-disk storage + + {{- if .forwarder_storage_max_size_in_bytes }} + {{- if .FileStorage.CurrentSizeInBytes }} + Disk usage in bytes: {{ .FileStorage.CurrentSizeInBytes }}
+ Number of files: {{ .FileStorage.FilesCount }}
+ Number of files dropped: {{ .FileStorage.FilesRemovedCount }}
+ Deserialization errors count: {{ .FileStorage.DeserializeErrorsCount }}
+ Outdated files removed at startup: {{ .RemovalPolicy.OutdatedFilesCount }}
+ {{- else }} + Enabled, not in-use.
+ {{- end}} {{- else }} - Enabled, not in-use.
+ On-disk storage is disabled. Configure `forwarder_storage_max_size_in_bytes` to enable it.
{{- end}} - {{- else }} - On-disk storage is disabled. Configure `forwarder_storage_max_size_in_bytes` to enable it.
- {{- end}} -
- {{- with .forwarderStats -}} +
{{- if .APIKeyStatus}} API Keys Status diff --git a/pkg/status/render/render.go b/pkg/status/render/render.go index a8edf8dd03b88..7805edb2fa768 100644 --- a/pkg/status/render/render.go +++ b/pkg/status/render/render.go @@ -15,12 +15,7 @@ import ( "path" "text/template" - "github.com/DataDog/datadog-agent/comp/netflow/server" - "github.com/DataDog/datadog-agent/comp/otelcol/otlp" - checkstats "github.com/DataDog/datadog-agent/pkg/collector/check/stats" "github.com/DataDog/datadog-agent/pkg/config" - "github.com/DataDog/datadog-agent/pkg/snmp/traps" - "github.com/DataDog/datadog-agent/pkg/util/log" ) var fmap = Textfmap() @@ -31,28 +26,6 @@ func FormatStatus(data []byte) (string, error) { if renderError != "" || err != nil { return renderError, err } - forwarderStats := stats["forwarderStats"] - if forwarderStatsMap, ok := forwarderStats.(map[string]interface{}); ok { - forwarderStatsMap["config"] = stats["config"] - } else { - log.Warn("The Forwarder status format is invalid. Some parts of the `Forwarder` section may be missing.") - } - - aggregatorStats := stats["aggregatorStats"] - s, err := checkstats.TranslateEventPlatformEventTypes(aggregatorStats) - if err != nil { - log.Debugf("failed to translate event platform event types in aggregatorStats: %s", err.Error()) - } else { - aggregatorStats = s - } - dogstatsdStats := stats["dogstatsdStats"] - logsStats := stats["logsStats"] - dcaStats := stats["clusterAgentStatus"] - endpointsInfos := stats["endpointsInfos"] - systemProbeStats := stats["systemProbeStats"] - processAgentStatus := stats["processAgentStatus"] - snmpTrapsStats := stats["snmpTrapsStats"] - netflowStats := stats["netflowStats"] title := fmt.Sprintf("Agent (v%s)", stats["version"]) stats["title"] = title @@ -62,55 +35,20 @@ func FormatStatus(data []byte) (string, error) { return renderStatusTemplate(b, "/collector.tmpl", stats) } jmxFetchFunc := func() error { return renderStatusTemplate(b, "/jmxfetch.tmpl", stats) } - forwarderFunc := func() error { return renderStatusTemplate(b, "/forwarder.tmpl", forwarderStats) } - endpointsFunc := func() error { return renderStatusTemplate(b, "/endpoints.tmpl", endpointsInfos) } - logsAgentFunc := func() error { return renderStatusTemplate(b, "/logsagent.tmpl", logsStats) } - systemProbeFunc := func() error { - if systemProbeStats != nil { - return renderStatusTemplate(b, "/systemprobe.tmpl", systemProbeStats) - } - return nil - } - processAgentFunc := func() error { return renderStatusTemplate(b, "/process-agent.tmpl", processAgentStatus) } - traceAgentFunc := func() error { return renderStatusTemplate(b, "/trace-agent.tmpl", stats["apmStats"]) } - aggregatorFunc := func() error { return renderStatusTemplate(b, "/aggregator.tmpl", aggregatorStats) } - dogstatsdFunc := func() error { return renderStatusTemplate(b, "/dogstatsd.tmpl", dogstatsdStats) } - clusterAgentFunc := func() error { - if config.Datadog.GetBool("cluster_agent.enabled") || config.Datadog.GetBool("cluster_checks.enabled") { - return renderStatusTemplate(b, "/clusteragent.tmpl", dcaStats) - } - return nil - } - snmpTrapFunc := func() error { - if traps.IsEnabled(config.Datadog) { - return renderStatusTemplate(b, "/snmp-traps.tmpl", snmpTrapsStats) - } - return nil - } - - netflowFunc := func() error { - if server.IsEnabled() { - return renderStatusTemplate(b, "/netflow.tmpl", netflowStats) - } - return nil - } - - autodiscoveryFunc := func() error { - if config.IsContainerized() { - return renderAutodiscoveryStats(b, stats["adEnabledFeatures"], stats["adConfigErrors"], - stats["filterErrors"]) - } - return nil - } - remoteConfigFunc := func() error { - return renderStatusTemplate(b, "/remoteconfig.tmpl", stats) - } - otlpFunc := func() error { - if otlp.IsDisplayed() { - return renderStatusTemplate(b, "/otlp.tmpl", stats) - } - return nil - } + forwarderFunc := func() error { return renderStatusTemplate(b, "/forwarder.tmpl", stats) } + endpointsFunc := func() error { return renderStatusTemplate(b, "/endpoints.tmpl", stats) } + logsAgentFunc := func() error { return renderStatusTemplate(b, "/logsagent.tmpl", stats) } + systemProbeFunc := func() error { return renderStatusTemplate(b, "/systemprobe.tmpl", stats) } + processAgentFunc := func() error { return renderStatusTemplate(b, "/process-agent.tmpl", stats) } + traceAgentFunc := func() error { return renderStatusTemplate(b, "/trace-agent.tmpl", stats) } + aggregatorFunc := func() error { return renderStatusTemplate(b, "/aggregator.tmpl", stats) } + dogstatsdFunc := func() error { return renderStatusTemplate(b, "/dogstatsd.tmpl", stats) } + clusterAgentFunc := func() error { return renderStatusTemplate(b, "/clusteragent.tmpl", stats) } + snmpTrapFunc := func() error { return renderStatusTemplate(b, "/snmp-traps.tmpl", stats) } + netflowFunc := func() error { return renderStatusTemplate(b, "/netflow.tmpl", stats) } + autodiscoveryFunc := func() error { return renderStatusTemplate(b, "/autodiscovery.tmpl", stats) } + remoteConfigFunc := func() error { return renderStatusTemplate(b, "/remoteconfig.tmpl", stats) } + otlpFunc := func() error { return renderStatusTemplate(b, "/otlp.tmpl", stats) } var renderFuncs []func() error if config.IsCLCRunner() { @@ -141,14 +79,11 @@ func FormatDCAStatus(data []byte) (string, error) { return renderError, err } - forwarderStats := stats["forwarderStats"] // We nil these keys because we do not want to display that information in the collector template stats["pyLoaderStats"] = nil stats["pythonInit"] = nil stats["inventories"] = nil - endpointsInfos := stats["endpointsInfos"] - logsStats := stats["logsStats"] - orchestratorStats := stats["orchestrator"] + title := fmt.Sprintf("Datadog Cluster Agent (v%s)", stats["version"]) stats["title"] = title @@ -160,24 +95,21 @@ func FormatDCAStatus(data []byte) (string, error) { if err := renderStatusTemplate(b, "/collector.tmpl", stats); err != nil { errs = append(errs, err) } - if err := renderStatusTemplate(b, "/forwarder.tmpl", forwarderStats); err != nil { + if err := renderStatusTemplate(b, "/forwarder.tmpl", stats); err != nil { errs = append(errs, err) } - if err := renderStatusTemplate(b, "/endpoints.tmpl", endpointsInfos); err != nil { + if err := renderStatusTemplate(b, "/endpoints.tmpl", stats); err != nil { errs = append(errs, err) } - if config.Datadog.GetBool("compliance_config.enabled") { - if err := renderStatusTemplate(b, "/logsagent.tmpl", logsStats); err != nil { - errs = append(errs, err) - } + if err := renderStatusTemplate(b, "/logsagent.tmpl", stats); err != nil { + errs = append(errs, err) } - if err := renderAutodiscoveryStats(b, stats["adEnabledFeatures"], stats["adConfigErrors"], stats["filterErrors"]); err != nil { + if err := renderStatusTemplate(b, "/autodiscovery.tmpl", stats); err != nil { errs = append(errs, err) } - if config.Datadog.GetBool("orchestrator_explorer.enabled") { - if err := renderStatusTemplate(b, "/orchestrator.tmpl", orchestratorStats); err != nil { - errs = append(errs, err) - } + + if err := renderStatusTemplate(b, "/orchestrator.tmpl", stats); err != nil { + errs = append(errs, err) } if err := renderErrors(b, errs); err != nil { fmt.Println(err) @@ -209,9 +141,7 @@ func FormatSecurityAgentStatus(data []byte) (string, error) { if renderError != "" || err != nil { return renderError, err } - runnerStats := stats["runnerStats"] - complianceChecks := stats["complianceChecks"] - complianceStatus := stats["complianceStatus"] + title := fmt.Sprintf("Datadog Security Agent (v%s)", stats["version"]) stats["title"] = title @@ -220,10 +150,10 @@ func FormatSecurityAgentStatus(data []byte) (string, error) { if err := renderStatusTemplate(b, "/header.tmpl", stats); err != nil { errs = append(errs, err) } - if err := renderRuntimeSecurityStats(b, stats["runtimeSecurityStatus"]); err != nil { + if err := renderStatusTemplate(b, "/runtimesecurity.tmpl", stats); err != nil { errs = append(errs, err) } - if err := renderComplianceChecksStats(b, runnerStats, complianceChecks, complianceStatus); err != nil { + if err := renderStatusTemplate(b, "/compliance.tmpl", stats); err != nil { errs = append(errs, err) } if err := renderErrors(b, errs); err != nil { @@ -287,28 +217,6 @@ func FormatCheckStats(data []byte) (string, error) { return b.String(), nil } -func renderComplianceChecksStats(w io.Writer, runnerStats interface{}, complianceChecks, complianceStatus interface{}) error { - checkStats := make(map[string]interface{}) - checkStats["RunnerStats"] = runnerStats - checkStats["ComplianceStatus"] = complianceStatus - checkStats["ComplianceChecks"] = complianceChecks - return renderStatusTemplate(w, "/compliance.tmpl", checkStats) -} - -func renderRuntimeSecurityStats(w io.Writer, runtimeSecurityStatus interface{}) error { - status := make(map[string]interface{}) - status["RuntimeSecurityStatus"] = runtimeSecurityStatus - return renderStatusTemplate(w, "/runtimesecurity.tmpl", status) -} - -func renderAutodiscoveryStats(w io.Writer, adEnabledFeatures interface{}, adConfigErrors interface{}, filterErrors interface{}) error { - autodiscoveryStats := make(map[string]interface{}) - autodiscoveryStats["adEnabledFeatures"] = adEnabledFeatures - autodiscoveryStats["adConfigErrors"] = adConfigErrors - autodiscoveryStats["filterErrors"] = filterErrors - return renderStatusTemplate(w, "/autodiscovery.tmpl", autodiscoveryStats) -} - //go:embed templates var templatesFS embed.FS diff --git a/pkg/status/render/templates/aggregator.tmpl b/pkg/status/render/templates/aggregator.tmpl index 1f83c234defbe..d08389e8647bb 100644 --- a/pkg/status/render/templates/aggregator.tmpl +++ b/pkg/status/render/templates/aggregator.tmpl @@ -5,6 +5,7 @@ NOTE: Changes made to this template should be reflected on the following templat ========== Aggregator ========== +{{- with .aggregatorStats }} {{- if .ChecksMetricSample }} Checks Metric Sample: {{humanize .ChecksMetricSample}} {{- end }} @@ -55,3 +56,4 @@ Aggregator {{- if .HostnameUpdate}} Hostname Update: {{humanize .HostnameUpdate}} {{- end }} +{{- end }} diff --git a/pkg/status/render/templates/autodiscovery.tmpl b/pkg/status/render/templates/autodiscovery.tmpl index 3ff340819ac6e..f4f03edbc81b6 100644 --- a/pkg/status/render/templates/autodiscovery.tmpl +++ b/pkg/status/render/templates/autodiscovery.tmpl @@ -7,7 +7,7 @@ NOTE: Changes made to this template should be reflected on the following templat ============= Autodiscovery ============= -{{- with .adEnabledFeatures}} +{{- with .adEnabledFeatures -}} Enabled Features ================ {{- range $feature, $empty := . }} diff --git a/pkg/status/render/templates/clusteragent.tmpl b/pkg/status/render/templates/clusteragent.tmpl index 323e2abe1db8f..1a5e3ff1494af 100644 --- a/pkg/status/render/templates/clusteragent.tmpl +++ b/pkg/status/render/templates/clusteragent.tmpl @@ -1,18 +1,19 @@ - +{{- with .clusterAgentStatus -}} ===================== Datadog Cluster Agent ===================== -{{ if .DetectionError }} - - Could not detect the Datadog Cluster Agent's endpoint: {{ .DetectionError }} -{{ else }} - - Datadog Cluster Agent endpoint detected: {{ .Endpoint }} -{{- end }} -{{- if .ConnectionError }} - - Could not reach the Datadog Cluster Agent: {{ .ConnectionError }} -{{- end }} -{{- if not .Version }} - - Could not retrieve the version of the Datadog Cluster Agent. -{{ else }} - Successfully connected to the Datadog Cluster Agent. - - Running: {{ .Version }} -{{- end }} + {{ if .DetectionError }} + - Could not detect the Datadog Cluster Agent's endpoint: {{ .DetectionError }} + {{ else }} + - Datadog Cluster Agent endpoint detected: {{ .Endpoint }} + {{- end }} + {{- if .ConnectionError }} + - Could not reach the Datadog Cluster Agent: {{ .ConnectionError }} + {{- end }} + {{- if not .Version }} + - Could not retrieve the version of the Datadog Cluster Agent. + {{ else }} + Successfully connected to the Datadog Cluster Agent. + - Running: {{ .Version }} + {{- end }} +{{- end -}} diff --git a/pkg/status/render/templates/compliance.tmpl b/pkg/status/render/templates/compliance.tmpl index 44e6b3165d582..29656b7100fc9 100644 --- a/pkg/status/render/templates/compliance.tmpl +++ b/pkg/status/render/templates/compliance.tmpl @@ -1,10 +1,10 @@ ========== Compliance ========== -{{ if not .ComplianceStatus}} +{{ if not .complianceStatus}} Not enabled {{- else}} - {{- with .ComplianceStatus}} + {{- with .complianceStatus}} {{ if .endpoints }} {{- range $endpoint := .endpoints }} {{ $endpoint }} @@ -14,8 +14,8 @@ Compliance Checks ====== - {{ $runnerStats := .RunnerStats }} - {{- range $Check := .ComplianceChecks }} + {{ $runnerStats := .runnerStats }} + {{- range $Check := .complianceChecks }} {{ $Check.Name }} {{printDashes $Check.Name "-"}} Framework: {{ $Check.Framework }} ({{ $Check.Version }}) diff --git a/pkg/status/render/templates/dogstatsd.tmpl b/pkg/status/render/templates/dogstatsd.tmpl index 43b0fcc703ea4..530a418daa4c0 100644 --- a/pkg/status/render/templates/dogstatsd.tmpl +++ b/pkg/status/render/templates/dogstatsd.tmpl @@ -5,8 +5,10 @@ NOTE: Changes made to this template should be reflected on the following templat ========= DogStatsD ========= +{{- with .dogstatsdStats -}} {{- range $key, $value := .}} {{formatTitle $key}}: {{humanize $value}} {{- end }} +{{- end }} Tip: For troubleshooting, enable 'dogstatsd_metrics_stats_enable' in the main datadog.yaml file to generate Dogstatsd logs. Once 'dogstatsd_metrics_stats_enable' is enabled, users can also use 'dogstatsd-stats' command to get visibility of the latest collected metrics. diff --git a/pkg/status/render/templates/endpoints.tmpl b/pkg/status/render/templates/endpoints.tmpl index 865182e1d3222..968bcf3065c0c 100644 --- a/pkg/status/render/templates/endpoints.tmpl +++ b/pkg/status/render/templates/endpoints.tmpl @@ -1,20 +1,18 @@ {{/* NOTE: Changes made to this template should be reflected on the following templates, if applicable: * cmd/agent/gui/views/templates/generalStatus.tmpl -* Dockerfiles/cluster-agent/dist/templates/forwarder.tmpl */}}========== Endpoints ========== - -{{- with .}} - {{- range $key, $value := .}} - {{$key}} - API Key{{ if gt (len $value) 1}}s{{end}} ending with: +{{- with .endpointsInfos -}} +{{ range $key, $value := .}} + {{$key}} - API Key{{ if gt (len $value) 1}}s{{end}} ending with: {{- range $idx, $apikey := $value }} - {{$apikey}} {{- end}} {{- end}} {{- else }} - No endpoints information. The agent may be misconfigured. -{{- end }} +No endpoints information. The agent may be misconfigured. +{{end }} diff --git a/pkg/status/render/templates/forwarder.tmpl b/pkg/status/render/templates/forwarder.tmpl index 6306cda670b4c..93e7352045807 100644 --- a/pkg/status/render/templates/forwarder.tmpl +++ b/pkg/status/render/templates/forwarder.tmpl @@ -4,6 +4,7 @@ NOTE: Changes made to this template should be reflected on the following templat */}}========= Forwarder ========= +{{with .forwarderStats -}} {{ if .Transactions }} Transactions ============ @@ -57,7 +58,7 @@ Forwarder On-disk storage =============== - {{- if .config.forwarder_storage_max_size_in_bytes }} + {{- if .forwarder_storage_max_size_in_bytes }} {{- if .FileStorage.CurrentSizeInBytes }} Disk usage in bytes: {{ .FileStorage.CurrentSizeInBytes }} Current number of files: {{ .FileStorage.FilesCount }} @@ -88,4 +89,5 @@ Forwarder {{yellowText $key}}{{yellowText ":"}} {{yellowText $value}} {{- end }} {{- end}} +{{- end}} diff --git a/pkg/status/render/templates/logsagent.tmpl b/pkg/status/render/templates/logsagent.tmpl index ba595488478e8..25488a711b179 100644 --- a/pkg/status/render/templates/logsagent.tmpl +++ b/pkg/status/render/templates/logsagent.tmpl @@ -5,9 +5,8 @@ NOTE: Changes made to this template should be reflected on the following templat ========== Logs Agent ========== - +{{ with .logsStats }} {{- if eq .is_running false }} - Logs Agent is not running {{- end }} @@ -54,7 +53,7 @@ Logs Agent {{- end }} {{- end }} -{{ if .integrations }} +{{- if .integrations }} ============ Integrations ============ @@ -90,7 +89,7 @@ Logs Agent {{- end }} {{- end }} {{- end }} -{{ if .tailers }} +{{- if .tailers }} ======= Tailers ======= @@ -110,3 +109,4 @@ Logs Agent {{- end }} {{- end }} {{- end }} +{{- end }} diff --git a/pkg/status/render/templates/netflow.tmpl b/pkg/status/render/templates/netflow.tmpl index 7eb3bfd0298ea..5e812be3df8c2 100644 --- a/pkg/status/render/templates/netflow.tmpl +++ b/pkg/status/render/templates/netflow.tmpl @@ -1,34 +1,35 @@ - +{{- with .netflowStats -}} ========= NetFlow ========= -Total Listeners: {{.TotalListeners}} -Open Listeners: {{.OpenListeners}} -Closed Listeners: {{.ClosedListeners}} -{{ if .OpenListeners }} -=== Open Listener Details === -{{- range $index, $NetflowListenerStatus := .WorkingListenerDetails }} ---------- -BindHost: {{$NetflowListenerStatus.Config.BindHost}} -FlowType: {{$NetflowListenerStatus.Config.FlowType}} -Port: {{$NetflowListenerStatus.Config.Port}} -Workers: {{$NetflowListenerStatus.Config.Workers}} -Namespace: {{$NetflowListenerStatus.Config.Namespace}} -Flows Received: {{$NetflowListenerStatus.FlowCount}} ---------- -{{- end }} -{{ end }} + Total Listeners: {{.TotalListeners}} + Open Listeners: {{.OpenListeners}} + Closed Listeners: {{.ClosedListeners}} + {{ if .OpenListeners }} + === Open Listener Details === + {{- range $index, $NetflowListenerStatus := .WorkingListenerDetails }} + --------- + BindHost: {{$NetflowListenerStatus.Config.BindHost}} + FlowType: {{$NetflowListenerStatus.Config.FlowType}} + Port: {{$NetflowListenerStatus.Config.Port}} + Workers: {{$NetflowListenerStatus.Config.Workers}} + Namespace: {{$NetflowListenerStatus.Config.Namespace}} + Flows Received: {{$NetflowListenerStatus.FlowCount}} + --------- + {{- end }} + {{ end }} -{{ if .ClosedListeners }} -=== Closed Listener Details === -{{- range $index, $NetflowListenerStatus := .ClosedListenerDetails }} ---------- -BindHost: {{$NetflowListenerStatus.Config.BindHost}} -FlowType: {{$NetflowListenerStatus.Config.FlowType}} -Port: {{$NetflowListenerStatus.Config.Port}} -Workers: {{$NetflowListenerStatus.Config.Workers}} -Namespace: {{$NetflowListenerStatus.Config.Namespace}} -Error: {{$NetflowListenerStatus.Error}} ---------- -{{- end }} -{{ end }} + {{ if .ClosedListeners }} + === Closed Listener Details === + {{- range $index, $NetflowListenerStatus := .ClosedListenerDetails }} + --------- + BindHost: {{$NetflowListenerStatus.Config.BindHost}} + FlowType: {{$NetflowListenerStatus.Config.FlowType}} + Port: {{$NetflowListenerStatus.Config.Port}} + Workers: {{$NetflowListenerStatus.Config.Workers}} + Namespace: {{$NetflowListenerStatus.Config.Namespace}} + Error: {{$NetflowListenerStatus.Error}} + --------- + {{- end }} + {{ end }} +{{- end -}} diff --git a/pkg/status/render/templates/orchestrator.tmpl b/pkg/status/render/templates/orchestrator.tmpl index 1ab5e41b20ac2..bcc6f67268505 100644 --- a/pkg/status/render/templates/orchestrator.tmpl +++ b/pkg/status/render/templates/orchestrator.tmpl @@ -1,5 +1,6 @@ {{/* */}} +{{ with .orchestrator }} ===================== Orchestrator Explorer ===================== @@ -94,3 +95,4 @@ Orchestrator Explorer {{- end}} {{- end}} {{- end}} +{{ end }} diff --git a/pkg/status/render/templates/otlp.tmpl b/pkg/status/render/templates/otlp.tmpl index 198ea5038a6cc..42cd519f8fdf5 100644 --- a/pkg/status/render/templates/otlp.tmpl +++ b/pkg/status/render/templates/otlp.tmpl @@ -2,11 +2,12 @@ NOTE: Changes made to this template should be reflected on the following templates, if applicable: * cmd/agent/gui/views/templates/generalStatus.tmpl */}} +{{- with .otlp }} ==== OTLP ==== - {{ with .otlp }} + Status: {{ if .otlpStatus }}Enabled{{else}}Not enabled{{ end }} Collector status: {{ .otlpCollectorStatus }} {{ if .otlpCollectorStatusErr }}Error: {{ .otlpCollectorStatusErr }}{{ end }} - {{ end }} \ No newline at end of file +{{- end -}} diff --git a/pkg/status/render/templates/process-agent.tmpl b/pkg/status/render/templates/process-agent.tmpl index b7271b4aefae7..ef1e878b96349 100644 --- a/pkg/status/render/templates/process-agent.tmpl +++ b/pkg/status/render/templates/process-agent.tmpl @@ -5,6 +5,7 @@ NOTE: Changes made to this template should be reflected on the following templat ============= Process Agent ============= +{{- with .processAgentStatus }} {{- if .error }} Status: Not running or unreachable @@ -71,3 +72,4 @@ Process Agent Stale diffs discarded: {{.expvars.workloadmeta_extractor_stale_diffs}} Diffs dropped: {{.expvars.workloadmeta_extractor_diffs_dropped}} {{- end }} +{{- end }} diff --git a/pkg/status/render/templates/runtimesecurity.tmpl b/pkg/status/render/templates/runtimesecurity.tmpl index e98d80cf0884c..05789370a46c9 100644 --- a/pkg/status/render/templates/runtimesecurity.tmpl +++ b/pkg/status/render/templates/runtimesecurity.tmpl @@ -2,10 +2,10 @@ Runtime Security ================ -{{- if not .RuntimeSecurityStatus}} +{{- if not .runtimeSecurityStatus}} Not enabled {{- else}} - {{- with .RuntimeSecurityStatus}} + {{- with .runtimeSecurityStatus}} {{ if .endpoints }} {{- range $endpoint := .endpoints }} {{ $endpoint }} diff --git a/pkg/status/render/templates/snmp-traps.tmpl b/pkg/status/render/templates/snmp-traps.tmpl index a85c911cdeec5..01a88bcec3a74 100644 --- a/pkg/status/render/templates/snmp-traps.tmpl +++ b/pkg/status/render/templates/snmp-traps.tmpl @@ -2,6 +2,7 @@ NOTE: Changes made to this template should be reflected on the following templates, if applicable: * cmd/agent/gui/views/templates/generalStatus.tmpl */}} +{{- with .snmpTrapsStats }} ========== SNMP Traps ========== @@ -11,3 +12,4 @@ SNMP Traps {{- range $key, $value := .metrics}} {{formatTitle $key}}: {{humanize $value}} {{- end }} +{{- end -}} diff --git a/pkg/status/render/templates/systemprobe.tmpl b/pkg/status/render/templates/systemprobe.tmpl index 090b12ce66ced..514d5395124d3 100644 --- a/pkg/status/render/templates/systemprobe.tmpl +++ b/pkg/status/render/templates/systemprobe.tmpl @@ -1,3 +1,4 @@ +{{- with .systemProbeStats}} ============ System Probe ============ @@ -87,4 +88,5 @@ System Probe Status: Running {{- end }} {{- end }} +{{- end }} diff --git a/pkg/status/render/templates/trace-agent.tmpl b/pkg/status/render/templates/trace-agent.tmpl index e8dbc5400d3aa..cc91c08892032 100644 --- a/pkg/status/render/templates/trace-agent.tmpl +++ b/pkg/status/render/templates/trace-agent.tmpl @@ -5,7 +5,7 @@ NOTE: Changes made to this template should be reflected on the following templat ========= APM Agent ========= - +{{- with .apmStats }} {{- if .error }} Status: Not running or unreachable on localhost:{{.port}}. @@ -50,3 +50,4 @@ APM Agent Stats: {{.stats_writer.Payloads}} payloads, {{.stats_writer.StatsBuckets}} stats buckets, {{humanize .stats_writer.Bytes}} bytes {{- if gt .stats_writer.Errors 0.0}}WARNING: Stats API errors (1 min): {{.stats_writer.Errors}}{{end}} {{- end}} +{{- end}} diff --git a/pkg/status/status.go b/pkg/status/status.go index 9b8455a578e97..2c4e6b5a963c5 100644 --- a/pkg/status/status.go +++ b/pkg/status/status.go @@ -19,6 +19,7 @@ import ( hostMetadataUtils "github.com/DataDog/datadog-agent/comp/metadata/host/utils" "github.com/DataDog/datadog-agent/comp/metadata/inventoryagent" netflowServer "github.com/DataDog/datadog-agent/comp/netflow/server" + "github.com/DataDog/datadog-agent/comp/otelcol/otlp" "github.com/DataDog/datadog-agent/pkg/clusteragent/admission" "github.com/DataDog/datadog-agent/pkg/clusteragent/clusterchecks" "github.com/DataDog/datadog-agent/pkg/clusteragent/custommetrics" @@ -63,7 +64,9 @@ func GetStatus(verbose bool, invAgent inventoryagent.Component) (map[string]inte stats["logsStats"] = logsStatus.Get(verbose) - stats["otlp"] = GetOTLPStatus() + if otlp.IsDisplayed() { + stats["otlp"] = GetOTLPStatus() + } endpointsInfos, err := getEndpointsInfos() if endpointsInfos != nil && err == nil { @@ -72,7 +75,7 @@ func GetStatus(verbose bool, invAgent inventoryagent.Component) (map[string]inte stats["endpointsInfos"] = nil } - if config.Datadog.GetBool("cluster_agent.enabled") { + if config.Datadog.GetBool("cluster_agent.enabled") || config.Datadog.GetBool("cluster_checks.enabled") { stats["clusterAgentStatus"] = getDCAStatus() } @@ -132,7 +135,9 @@ func GetDCAStatus(verbose bool) (map[string]interface{}, error) { stats["config"] = getDCAPartialConfig() stats["leaderelection"] = getLeaderElectionDetails() - stats["logsStats"] = logsStatus.Get(verbose) + if config.Datadog.GetBool("compliance_config.enabled") { + stats["logsStats"] = logsStatus.Get(verbose) + } endpointsInfos, err := getEndpointsInfos() if endpointsInfos != nil && err == nil { @@ -246,10 +251,6 @@ func getPartialConfig() map[string]string { conf["fips_local_address"] = config.Datadog.GetString("fips.local_address") conf["fips_port_range_start"] = config.Datadog.GetString("fips.port_range_start") - forwarderStorageMaxSizeInBytes := config.Datadog.GetInt("forwarder_storage_max_size_in_bytes") - if forwarderStorageMaxSizeInBytes > 0 { - conf["forwarder_storage_max_size_in_bytes"] = strconv.Itoa(forwarderStorageMaxSizeInBytes) - } return conf } @@ -322,6 +323,10 @@ func expvarStats(stats map[string]interface{}, invAgent inventoryagent.Component forwarderStatsJSON := []byte(expvar.Get("forwarder").String()) forwarderStats := make(map[string]interface{}) json.Unmarshal(forwarderStatsJSON, &forwarderStats) //nolint:errcheck + forwarderStorageMaxSizeInBytes := config.Datadog.GetInt("forwarder_storage_max_size_in_bytes") + if forwarderStorageMaxSizeInBytes > 0 { + forwarderStats["forwarder_storage_max_size_in_bytes"] = strconv.Itoa(forwarderStorageMaxSizeInBytes) + } stats["forwarderStats"] = forwarderStats collector.PopulateStatus(stats) @@ -376,9 +381,13 @@ func expvarStats(stats map[string]interface{}, invAgent inventoryagent.Component stats["agent_metadata"] = map[string]string{} } - stats["snmpTrapsStats"] = traps.GetStatus() + if traps.IsEnabled(config.Datadog) { + stats["snmpTrapsStats"] = traps.GetStatus() + } - stats["netflowStats"] = netflowServer.GetStatus() + if netflowServer.IsEnabled() { + stats["netflowStats"] = netflowServer.GetStatus() + } complianceVar := expvar.Get("compliance") if complianceVar != nil {