Skip to content

Commit

Permalink
Added the option to enable USM (#876)
Browse files Browse the repository at this point in the history
  • Loading branch information
guyarb authored Jan 30, 2023
1 parent 9084587 commit 8589b47
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ The [system-probe recipe][17] is automatically included by default. It writes th
To enable [Network Performance Monitoring][7] (NPM) in `system-probe.yaml`, set `node['datadog']['system_probe']['network_enabled']` to true.
To enable [Universal Service Monitoring][7] (NPM) in `system-probe.yaml`, set `node['datadog']['system_probe']['service_monitoring_enabled']` to true.
**Note for Windows users**: NPM is supported on Windows with Agent v6.27+ and v7.27+. It ships as an optional component that is only installed if `node['datadog']['system_probe']['network_enabled']` is set to true when the Agent is installed or upgraded. Because of this, existing installations might need to do an uninstall and reinstall of the Agent once to install the NPM component, unless the Agent is upgraded at the same time.
## Resources
Expand Down
1 change: 1 addition & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@
# When this is set to nil (default), `network_config` won't be rendered in system-probe.yaml,
# making the Agent use the default setting for this value.
default['datadog']['system_probe']['network_enabled'] = nil
default['datadog']['system_probe']['service_monitoring_enabled'] = nil

# Logs functionality settings (Agent 6/7 only)
# Set `enable_logs_agent` to:
Expand Down
2 changes: 1 addition & 1 deletion recipes/system-probe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
sysprobe_enabled = if is_windows
node['datadog']['system_probe']['network_enabled']
else
node['datadog']['system_probe']['enabled'] || node['datadog']['system_probe']['network_enabled'] || cws_enabled
node['datadog']['system_probe']['enabled'] || node['datadog']['system_probe']['network_enabled'] || node['datadog']['system_probe']['service_monitoring_enabled'] || cws_enabled
end
sysprobe_agent_start = sysprobe_enabled && node['datadog']['agent_start'] && node['datadog']['agent_enable'] ? :start : :stop

Expand Down
49 changes: 49 additions & 0 deletions spec/system-probe_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,55 @@
end
end

context 'with service_monitoring_enabled set to true' do
cached(:solo) do
ChefSpec::SoloRunner.new(
platform: 'ubuntu',
version: '16.04'
) do |node|
node.name 'chef-nodename' # expected to be used as the hostname in `datadog.yaml`
node.normal['datadog'] = {
'api_key' => 'somethingnotnil',
'agent_major_version' => 6,
'system_probe' => {
'debug_port' => 123,
'bpf_debug' => true,
'sysprobe_socket' => '/test/ing.sock',
'service_monitoring_enabled' => true,
}
}
end
end

cached(:chef_run) do
solo.converge(described_recipe) do
solo.resource_collection.insert(
Chef::Resource::Service.new('datadog-agent', solo.run_context))
end
end

it 'is created with enabled service_monitoring_enabled' do
expect(chef_run).to create_template('/etc/datadog-agent/system-probe.yaml')
end

it 'contains expected YAML configuration' do
expected_yaml = <<-EOF
service_monitoring_config:
enabled: true
system_probe_config:
bpf_debug: true
debug_port: 123
enable_conntrack: false
enabled: false
sysprobe_socket: "/test/ing.sock"
EOF

expect(chef_run).to(render_file('/etc/datadog-agent/system-probe.yaml').with_content { |content|
expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json)
})
end
end

context 'with network_enabled set to true' do
cached(:solo) do
ChefSpec::SoloRunner.new(
Expand Down
5 changes: 5 additions & 0 deletions templates/default/system_probe.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ if !node['datadog']['system_probe']['network_enabled'].nil?
'enabled': node['datadog']['system_probe']['network_enabled'],
}
end
if !node['datadog']['system_probe']['service_monitoring_enabled'].nil?
system_probe_config['service_monitoring_config'] = {
'enabled': node['datadog']['system_probe']['service_monitoring_enabled'],
}
end
-%>
# Generated by Chef, local modifications will be overwritten

Expand Down

0 comments on commit 8589b47

Please sign in to comment.