Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render agent status using status component #22115

Merged
merged 61 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
0f59b67
add noop status providers
GustavoCaso Jan 4, 2024
453cda1
add forwarder status provider
GustavoCaso Jan 4, 2024
e45cc7c
add status component to agent run command
GustavoCaso Jan 12, 2024
3a91cdb
add collector provider to agent run command
GustavoCaso Jan 12, 2024
1eb74fe
More status aggregator provider to pkg/aggregator
GustavoCaso Jan 12, 2024
d4f5a4b
move dogstatsd status provider to component
GustavoCaso Jan 12, 2024
1d8a81c
use the status component to render agent status CLI
GustavoCaso Jan 12, 2024
0dfbbbc
move hostname and hostinfo to metadata host component
GustavoCaso Jan 15, 2024
c86dbc2
move ntp status provider to corechekcs
GustavoCaso Jan 15, 2024
9dce83c
move inventory payload status to comp folder
GustavoCaso Jan 15, 2024
83262e7
move snmp status to a provider
GustavoCaso Jan 15, 2024
bc1ab3d
move netflow status to component
GustavoCaso Jan 15, 2024
7be6241
move compliance status to provider
GustavoCaso Jan 15, 2024
490fc18
make sure to use the right template helper for text output
GustavoCaso Jan 15, 2024
e33ab13
add missing hostInfo information for host metadata
GustavoCaso Jan 16, 2024
9f3f645
add jmx status provider
GustavoCaso Jan 16, 2024
d1d2176
add logs agent provider to agent logs component
GustavoCaso Jan 16, 2024
89b0f78
propagate the verbose parameter to the providers
GustavoCaso Jan 16, 2024
11184bd
propagate the verbose parameter to agent logs provider
GustavoCaso Jan 16, 2024
4488bb3
move OTLP status to component
GustavoCaso Jan 16, 2024
6eabf2e
move endpoints status to status provider
GustavoCaso Jan 16, 2024
f5ec44b
move cluster agent status to provider
GustavoCaso Jan 16, 2024
75745cb
move system probe output to provider
GustavoCaso Jan 17, 2024
519cdd3
propagate verbose option to JMX provider
GustavoCaso Jan 17, 2024
0285368
add http proxy warning status provider
GustavoCaso Jan 17, 2024
c15497c
add autodicovery status provider
GustavoCaso Jan 17, 2024
6eac3f3
move remoteconfiguration status output to component
GustavoCaso Jan 17, 2024
19c4792
fix jmx subcommand
GustavoCaso Jan 17, 2024
ba5d523
fix lint errors
GustavoCaso Jan 17, 2024
0bc45d2
update collector provider to use their own templates
GustavoCaso Jan 17, 2024
126c3b9
create apm trace status component
GustavoCaso Jan 17, 2024
a2cfb0f
fix lint error
GustavoCaso Jan 18, 2024
9c546f9
Merge branch 'main' into render-agent-status-using-status-component
GustavoCaso Jan 19, 2024
e5ba6b1
fix bad statet from merging main
GustavoCaso Jan 19, 2024
4c3ec7c
create process agent status provider
GustavoCaso Jan 19, 2024
39b41d9
update header status provider to display path and fips information
GustavoCaso Jan 19, 2024
cbd32cc
do not check for NoopProviders
GustavoCaso Jan 19, 2024
c8fbb61
add GetProvider() function to extrenal providers
GustavoCaso Jan 19, 2024
2e5db66
- Move renderText and renderHTML helper function to core status compo…
GustavoCaso Jan 19, 2024
b4596c1
Merge branch 'main' into render-agent-status-using-status-component
GustavoCaso Jan 22, 2024
5834253
Fix lint issues
GustavoCaso Jan 22, 2024
0f0d1a3
make sure to pass the python version to the agent run command
GustavoCaso Jan 22, 2024
97951b1
update forwarder go mod files
GustavoCaso Jan 22, 2024
05e5e3d
fix lint issues
GustavoCaso Jan 22, 2024
c4c2a1e
fix window agent run command
GustavoCaso Jan 22, 2024
5bb878e
fix defaultforwarder go.mod issues
GustavoCaso Jan 22, 2024
db2c86b
move dogstastd status to its own component
GustavoCaso Jan 22, 2024
d02ef68
make the status params python version as a callaback function
GustavoCaso Jan 23, 2024
6f72347
fix type and e2e test
GustavoCaso Jan 23, 2024
988f41e
update status version for forwarder module
GustavoCaso Jan 24, 2024
f7735ae
Merge branch 'main' into render-agent-status-using-status-component
GustavoCaso Jan 24, 2024
de1d9a0
add deleted comment from previos merge conflict
GustavoCaso Jan 24, 2024
aa1be20
fix module dependencies issues
GustavoCaso Jan 24, 2024
18eee5e
fix net status test
GustavoCaso Jan 24, 2024
2b4835f
create separate demultiplexerStatus struct
GustavoCaso Jan 24, 2024
91750b8
attempt to fix go module issue
GustavoCaso Jan 24, 2024
04b8205
wip
GustavoCaso Jan 24, 2024
b3854d3
Change git diff-files to git diff in check mod tidy
KevinFairise2 Jan 24, 2024
cb06adc
set the correct content-type header base in the format
GustavoCaso Jan 24, 2024
c4e09f0
fix typo
GustavoCaso Jan 25, 2024
6a69662
fix issues with config not being loaded at boot time
GustavoCaso Jan 25, 2024
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
2 changes: 2 additions & 0 deletions cmd/agent/subcommands/jmx/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/flare"
"github.com/DataDog/datadog-agent/comp/core/log/logimpl"
"github.com/DataDog/datadog-agent/comp/core/secrets"
"github.com/DataDog/datadog-agent/comp/core/status"
"github.com/DataDog/datadog-agent/comp/core/tagger"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors"
Expand Down Expand Up @@ -137,6 +138,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
fx.Provide(func() demultiplexer.Component { return nil }),
fx.Provide(func() inventorychecks.Component { return nil }),
fx.Provide(func() packagesigning.Component { return nil }),
fx.Provide(func() status.Component { return nil }),
fx.Provide(tagger.NewTaggerParamsForCoreAgent),
tagger.Module(),
)
Expand Down
36 changes: 36 additions & 0 deletions cmd/agent/subcommands/run/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ import (
"github.com/DataDog/datadog-agent/comp/core/log"
"github.com/DataDog/datadog-agent/comp/core/log/logimpl"
"github.com/DataDog/datadog-agent/comp/core/secrets"
"github.com/DataDog/datadog-agent/comp/core/status"
"github.com/DataDog/datadog-agent/comp/core/status/statusimpl"
"github.com/DataDog/datadog-agent/comp/core/sysprobeconfig"
"github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl"
"github.com/DataDog/datadog-agent/comp/core/tagger"
Expand All @@ -57,6 +59,7 @@ import (
"github.com/DataDog/datadog-agent/comp/dogstatsd/replay"
dogstatsdServer "github.com/DataDog/datadog-agent/comp/dogstatsd/server"
dogstatsddebug "github.com/DataDog/datadog-agent/comp/dogstatsd/serverDebug"
dogstatsdStatusimpl "github.com/DataDog/datadog-agent/comp/dogstatsd/status/statusimpl"
"github.com/DataDog/datadog-agent/comp/forwarder"
"github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder"
orchestratorForwarderImpl "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator/orchestratorimpl"
Expand All @@ -76,13 +79,17 @@ import (
netflowServer "github.com/DataDog/datadog-agent/comp/netflow/server"
"github.com/DataDog/datadog-agent/comp/otelcol"
otelcollector "github.com/DataDog/datadog-agent/comp/otelcol/collector"
processagentStatusImpl "github.com/DataDog/datadog-agent/comp/process/status/statusimpl"
"github.com/DataDog/datadog-agent/comp/remote-config/rcclient"
traceagentStatusImpl "github.com/DataDog/datadog-agent/comp/trace/status/statusimpl"
"github.com/DataDog/datadog-agent/pkg/api/healthprobe"
"github.com/DataDog/datadog-agent/pkg/autodiscovery/providers"
"github.com/DataDog/datadog-agent/pkg/cloudfoundry/containertagger"
"github.com/DataDog/datadog-agent/pkg/collector"
"github.com/DataDog/datadog-agent/pkg/collector/check"
"github.com/DataDog/datadog-agent/pkg/collector/corechecks/embed/jmx"
"github.com/DataDog/datadog-agent/pkg/collector/corechecks/net"
"github.com/DataDog/datadog-agent/pkg/collector/python"
"github.com/DataDog/datadog-agent/pkg/commonchecks"
pkgconfig "github.com/DataDog/datadog-agent/pkg/config"
"github.com/DataDog/datadog-agent/pkg/config/remote/data"
Expand All @@ -92,8 +99,16 @@ import (
"github.com/DataDog/datadog-agent/pkg/pidfile"
"github.com/DataDog/datadog-agent/pkg/serializer"
"github.com/DataDog/datadog-agent/pkg/snmp/traps"
snmpStatus "github.com/DataDog/datadog-agent/pkg/snmp/traps/status"
autodiscoveryStatus "github.com/DataDog/datadog-agent/pkg/status/autodiscovery"
clusteragentStatus "github.com/DataDog/datadog-agent/pkg/status/clusteragent"
collectorStatus "github.com/DataDog/datadog-agent/pkg/status/collector"
endpointsStatus "github.com/DataDog/datadog-agent/pkg/status/endpoints"
"github.com/DataDog/datadog-agent/pkg/status/health"
httpproxyStatus "github.com/DataDog/datadog-agent/pkg/status/httpproxy"
jmxStatus "github.com/DataDog/datadog-agent/pkg/status/jmx"
otlpStatus "github.com/DataDog/datadog-agent/pkg/status/otlp"
systemprobeStatus "github.com/DataDog/datadog-agent/pkg/status/systemprobe"
pkgTelemetry "github.com/DataDog/datadog-agent/pkg/telemetry"
"github.com/DataDog/datadog-agent/pkg/util"
pkgcommon "github.com/DataDog/datadog-agent/pkg/util/common"
Expand Down Expand Up @@ -189,6 +204,7 @@ func run(log log.Component,
_ langDetectionCl.Component,
agentAPI internalAPI.Component,
_ packagesigning.Component,
statusComponent status.Component,
) error {
defer func() {
stopAgent(cliParams, server, demultiplexer, agentAPI)
Expand Down Expand Up @@ -249,6 +265,7 @@ func run(log log.Component,
invAgent,
agentAPI,
invChecks,
statusComponent,
); err != nil {
return err
}
Expand Down Expand Up @@ -282,6 +299,24 @@ func getSharedFxOption() fx.Option {
collectors.GetCatalog(),
fx.Provide(defaults.DefaultParams),
workloadmeta.Module(),
fx.Supply(
status.Params{
PythonVersionGetFunc: func() string { return python.GetPythonVersion() },
},
status.NewInformationProvider(collectorStatus.Provider{}),
status.NewHeaderInformationProvider(net.Provider{}),
status.NewInformationProvider(jmxStatus.Provider{}),
status.NewInformationProvider(endpointsStatus.Provider{}),
hush-hush marked this conversation as resolved.
Show resolved Hide resolved
status.NewInformationProvider(snmpStatus.GetProvider()),
status.NewInformationProvider(clusteragentStatus.GetProvider()),
status.NewInformationProvider(systemprobeStatus.GetProvider()),
status.NewInformationProvider(httpproxyStatus.GetProvider()),
status.NewInformationProvider(autodiscoveryStatus.GetProvider()),
),
traceagentStatusImpl.Module(),
processagentStatusImpl.Module(),
dogstatsdStatusimpl.Module(),
statusimpl.Module(),
apiimpl.Module(),

dogstatsd.Bundle(),
Expand Down Expand Up @@ -352,6 +387,7 @@ func startAgent(
invAgent inventoryagent.Component,
agentAPI internalAPI.Component,
invChecks inventorychecks.Component,
_ status.Component,
) error {

var err error
Expand Down
3 changes: 3 additions & 0 deletions cmd/agent/subcommands/run/command_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/log"
"github.com/DataDog/datadog-agent/comp/core/log/logimpl"
"github.com/DataDog/datadog-agent/comp/core/secrets"
"github.com/DataDog/datadog-agent/comp/core/status"
"github.com/DataDog/datadog-agent/comp/core/sysprobeconfig"
"github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl"
"github.com/DataDog/datadog-agent/comp/core/tagger"
Expand Down Expand Up @@ -104,6 +105,7 @@ func StartAgentWithDefaults(ctxChan <-chan context.Context) (<-chan error, error
_ netflowServer.Component,
agentAPI internalAPI.Component,
pkgSigning packagesigning.Component,
statusComponent status.Component,
) error {

defer StopAgentWithDefaults(server, demultiplexer, agentAPI)
Expand All @@ -127,6 +129,7 @@ func StartAgentWithDefaults(ctxChan <-chan context.Context) (<-chan error, error
invAgent,
agentAPI,
invChecks,
statusComponent,
)
if err != nil {
return err
Expand Down
13 changes: 7 additions & 6 deletions cmd/agent/subcommands/status/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl"
"github.com/DataDog/datadog-agent/pkg/api/util"
pkgconfig "github.com/DataDog/datadog-agent/pkg/config"
"github.com/DataDog/datadog-agent/pkg/status/render"
"github.com/DataDog/datadog-agent/pkg/util/fxutil"
"github.com/DataDog/datadog-agent/pkg/util/scrubber"

Expand Down Expand Up @@ -150,6 +149,12 @@ func requestStatus(config config.Component, cliParams *cliParams) error {
v.Set("verbose", "true")
}

if cliParams.prettyPrintJSON || cliParams.jsonStatus {
v.Set("format", "json")
} else {
v.Set("format", "text")
}

url := url.URL{
Scheme: "https",
Host: fmt.Sprintf("%v:%v", ipcAddress, config.GetInt("cmd_port")),
Expand All @@ -170,11 +175,7 @@ func requestStatus(config config.Component, cliParams *cliParams) error {
} else if cliParams.jsonStatus {
s = string(r)
} else {
formattedStatus, err := render.FormatStatus(r)
if err != nil {
return err
}
s = scrubMessage(formattedStatus)
s = scrubMessage(string(r))
}

if cliParams.statusFilePath != "" {
Expand Down
12 changes: 12 additions & 0 deletions comp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ Package serverdebug implements a component to run the dogstatsd server debug

Package statsd implements a component to get a statsd client.

### [comp/dogstatsd/status](https://pkg.go.dev/github.com/DataDog/datadog-agent/comp/dogstatsd/status)

Package status implements the core status component information provider interface

## [comp/etw](https://pkg.go.dev/github.com/DataDog/datadog-agent/comp/etw) (Component Bundle)

*Datadog Team*: windows-agent
Expand Down Expand Up @@ -323,6 +327,10 @@ Package rtcontainercheck implements a component to handle realtime Container dat

Package runner implements a component to run data collection checks in the Process Agent.

### [comp/process/status](https://pkg.go.dev/github.com/DataDog/datadog-agent/comp/process/status)

Package status implements the core status component information provider interface

### [comp/process/submitter](https://pkg.go.dev/github.com/DataDog/datadog-agent/comp/process/submitter)

Package submitter implements a component to submit collected data in the Process Agent to
Expand Down Expand Up @@ -362,3 +370,7 @@ Package trace implements the "trace" bundle, providing components for the Trace

Package config implements a component to handle trace-agent configuration. This
component temporarily wraps pkg/trace/config.

### [comp/trace/status](https://pkg.go.dev/github.com/DataDog/datadog-agent/comp/trace/status)

Package status implements the core status component information provider interface
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ package demultiplexerimpl
import (
"context"

"go.uber.org/fx"

demultiplexerComp "github.com/DataDog/datadog-agent/comp/aggregator/demultiplexer"
"github.com/DataDog/datadog-agent/comp/aggregator/diagnosesendermanager"
"github.com/DataDog/datadog-agent/comp/core/log"
"github.com/DataDog/datadog-agent/comp/core/status"
"github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder"
orchestratorforwarder "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator"
"github.com/DataDog/datadog-agent/pkg/aggregator"
"github.com/DataDog/datadog-agent/pkg/aggregator/sender"
"github.com/DataDog/datadog-agent/pkg/util/fxutil"
"github.com/DataDog/datadog-agent/pkg/util/hostname"
"go.uber.org/fx"
)

// Module defines the fx options for this component.
Expand Down Expand Up @@ -51,7 +53,8 @@ type provides struct {
// implements diagnosesendermanager.Component). This has the nice consequence of preventing having
// demultiplexerimpl.Module and diagnosesendermanagerimpl.Module in the same fx.App because there would
// be two ways to create diagnosesendermanager.Component.
SenderManager diagnosesendermanager.Component
SenderManager diagnosesendermanager.Component
StatusProvider status.InformationProvider
}

func newDemultiplexer(deps dependencies) (provides, error) {
Expand All @@ -78,6 +81,9 @@ func newDemultiplexer(deps dependencies) (provides, error) {
return provides{
Comp: demultiplexer,
SenderManager: demultiplexer,
StatusProvider: status.NewInformationProvider(demultiplexerStatus{
Log: deps.Log,
}),
}, nil
}

Expand Down
74 changes: 74 additions & 0 deletions comp/aggregator/demultiplexer/demultiplexerimpl/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2023-present Datadog, Inc.

// Package demultiplexerimpl defines the aggregator demultiplexer
package demultiplexerimpl

import (
"embed"
"encoding/json"
"expvar"
"io"

checkstats "github.com/DataDog/datadog-agent/pkg/collector/check/stats"

"github.com/DataDog/datadog-agent/comp/core/log"
"github.com/DataDog/datadog-agent/comp/core/status"
)

//go:embed status_templates
var templatesFS embed.FS

type demultiplexerStatus struct {
Log log.Component
}

func (d demultiplexerStatus) getStatusInfo() map[string]interface{} {
stats := make(map[string]interface{})

d.populateStatus(stats)

return stats
}

func (d demultiplexerStatus) populateStatus(stats map[string]interface{}) {
aggregatorStatsJSON := []byte(expvar.Get("aggregator").String())
aggregatorStats := make(map[string]interface{})
json.Unmarshal(aggregatorStatsJSON, &aggregatorStats) //nolint:errcheck
stats["aggregatorStats"] = aggregatorStats
s, err := checkstats.TranslateEventPlatformEventTypes(stats["aggregatorStats"])
if err != nil {
d.Log.Debugf("failed to translate event platform event types in aggregatorStats: %s", err.Error())
} else {
stats["aggregatorStats"] = s
}
}

// Name returns the name
func (d demultiplexerStatus) Name() string {
return "Aggregator"
}

// Section return the section
func (d demultiplexerStatus) Section() string {
return "aggregator"
}

// JSON populates the status map
func (d demultiplexerStatus) JSON(_ bool, stats map[string]interface{}) error {
d.populateStatus(stats)

return nil
}

// Text renders the text output
func (d demultiplexerStatus) Text(_ bool, buffer io.Writer) error {
return status.RenderText(templatesFS, "aggregator.tmpl", buffer, d.getStatusInfo())
}

// HTML renders the html output
func (d demultiplexerStatus) HTML(_ bool, buffer io.Writer) error {
return status.RenderHTML(templatesFS, "aggregatorHTML.tmpl", buffer, d.getStatusInfo())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{- with .aggregatorStats }}
{{- if .ChecksMetricSample }}
Checks Metric Sample: {{humanize .ChecksMetricSample}}
{{- end }}
{{- if .DogstatsdMetricSample}}
Dogstatsd Metric Sample: {{humanize .DogstatsdMetricSample}}
{{- end }}
{{- if .Event}}
Event: {{humanize .Event}}
{{- end }}
{{- if .EventsFlushed}}
Events Flushed: {{humanize .EventsFlushed}}
{{- end }}
{{- if .EventsFlushErrors}}
Events Flush Errors: {{humanize .EventsFlushErrors}}
{{- end }}
{{- if .NumberOfFlush}}
Number Of Flushes: {{humanize .NumberOfFlush}}
{{- end }}
{{- if .SeriesFlushed}}
Series Flushed: {{humanize .SeriesFlushed}}
{{- end }}
{{- if .SeriesFlushErrors}}
Series Flush Errors: {{humanize .SeriesFlushErrors}}
{{- end }}
{{- if .ServiceCheck}}
Service Check: {{humanize .ServiceCheck}}
{{- end }}
{{- if .ServiceCheckFlushed}}
Service Checks Flushed: {{humanize .ServiceCheckFlushed}}
{{- end }}
{{- if .ServiceCheckFlushErrors}}
Service Checks Flush Errors: {{humanize .ServiceCheckFlushErrors}}
{{- end }}
{{- if .SketchesFlushed}}
Sketches Flushed: {{humanize .SketchesFlushed}}
{{- end }}
{{- if .SketchesFlushErrors}}
Sketches Flush Errors: {{humanize .SketchesFlushErrors}}
{{- end }}
{{- if .ChecksHistogramBucketMetricSample }}
Checks Histogram Bucket Metric Sample: {{humanize .ChecksHistogramBucketMetricSample}}
{{- end }}
{{- if .EventPlatformEvents }}
{{- range $k, $v := .EventPlatformEvents }}
{{ $k }}: {{humanize $v}}
{{- end }}
{{- end }}
{{- if .HostnameUpdate}}
Hostname Update: {{humanize .HostnameUpdate}}
{{- end }}
{{- end }}
Loading
Loading