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

Add infra agent config option #30137

Merged
merged 15 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions pkg/config/config_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,14 @@ api_key:
#
# disable_realtime_checks: false

## @param infra_agent - object - optional
## Enables Infrastructure Monitoring
carlosroman marked this conversation as resolved.
Show resolved Hide resolved
##
#infra_agent:
## @env DD_INFRA_AGENT_ENABLE - boolean - optional - default: true
## Enables or disables Infrastructure Monitoring
Guillaume-Barrier marked this conversation as resolved.
Show resolved Hide resolved
# enabled: true

{{- if .InternalProfiling -}}
## @param profiling - custom object - optional
## Enter specific configurations for internal profiling.
Expand Down
12 changes: 12 additions & 0 deletions pkg/config/setup/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ var serverlessConfigComponents = []func(pkgconfigmodel.Setup){
debugging,
vector,
podman,
infraAgent, // run after serializer as some flags are overridden
}

func init() {
Expand Down Expand Up @@ -1648,6 +1649,17 @@ func podman(config pkgconfigmodel.Setup) {
config.BindEnvAndSetDefault("podman_db_path", "")
}

func infraAgent(config pkgconfigmodel.Setup) {
// Disables metric data submission (including Custom Metrics) so that hosts stop showing up in Datadog.
// Used namely for Error Tracking Standalone where Infrastructure Monitoring is not needed.
if enabled := os.Getenv("DD_INFRA_AGENT_ENABLE"); enabled == "false" {
carlosroman marked this conversation as resolved.
Show resolved Hide resolved
config.BindEnvAndSetDefault("enable_payloads.events", false)
config.BindEnvAndSetDefault("enable_payloads.series", false)
config.BindEnvAndSetDefault("enable_payloads.service_checks", false)
config.BindEnvAndSetDefault("enable_payloads.sketches", false)
}
}

// LoadProxyFromEnv overrides the proxy settings with environment variables
func LoadProxyFromEnv(config pkgconfigmodel.Config) {
// Viper doesn't handle mixing nested variables from files and set
Expand Down
18 changes: 17 additions & 1 deletion pkg/config/setup/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ use_proxy_for_cloud_metadata: true
func TestServerlessConfigNumComponents(t *testing.T) {
// Enforce the number of config "components" reachable by the serverless agent
// to avoid accidentally adding entire components if it's not needed
require.Len(t, serverlessConfigComponents, 22)
require.Len(t, serverlessConfigComponents, 23)
}

func TestServerlessConfigInit(t *testing.T) {
Expand All @@ -1405,6 +1405,22 @@ func TestServerlessConfigInit(t *testing.T) {
// ensure some non-serverless configs are not declared
assert.False(t, conf.IsKnown("sbom.enabled"))
assert.False(t, conf.IsKnown("inventories_enabled"))

// ensure infra events payloads are enabled
assert.True(t, conf.GetBool("enable_payloads.events"))
}

func TestServerlessConfigInitInfraDisabled(t *testing.T) {
conf := pkgconfigmodel.NewConfig("datadog", "DD", strings.NewReplacer(".", "_")) // nolint: forbidigo // legit use case
t.Setenv("DD_INFRA_AGENT_ENABLE", "false")

initCommonWithServerless(conf)

// ensure infra payloads are disabled
assert.False(t, conf.GetBool("enable_payloads.events"))
assert.False(t, conf.GetBool("enable_payloads.series"))
assert.False(t, conf.GetBool("enable_payloads.service_check"))
assert.False(t, conf.GetBool("enable_payloads.sketches"))
}

func TestAgentConfigInit(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Each section from every release note are combined when the
# CHANGELOG.rst is rendered. So the text needs to be worded so that
# it does not depend on any information only available in another
# section. This may mean repeating some details, but each section
# must be readable independently of the other.
#
# Each section note must be formatted as reStructuredText.
---
enhancements:
- |
Infrastructure Monitoring can now be disabled through a single flag in the config.
Guillaume-Barrier marked this conversation as resolved.
Show resolved Hide resolved
Loading