chef-datadog icon indicating copy to clipboard operation
chef-datadog copied to clipboard

Add support for Preso and SystemD integration

Open jshrack-ssi opened this issue 5 years ago • 5 comments

Please add cookbook recipe/template support for both Presto and SystemD integrations.

jshrack-ssi avatar Mar 08 '20 15:03 jshrack-ssi

+1 for systemd

stianfro avatar Sep 21 '20 09:09 stianfro

I know it's not ideal, but note that you can use datadog_monitor to set up integrations that don't have a recipe yet.

See: https://github.com/DataDog/chef-datadog#datadog_monitor

albertvaka avatar Sep 21 '20 10:09 albertvaka

I know it's not ideal, but note that you can use datadog_monitor to set up integrations that don't have a recipe yet.

See: https://github.com/DataDog/chef-datadog#datadog_monitor

Using datadog_monitor for systemd just results in an error because there is no template for it:

Chef::Exceptions::FileNotFound
------------------------------
Cookbook 'datadog' (4.5.0) does not contain a file at any of these locations:
templates/host-kitchen-centos-8.2.2004/systemd.yaml.erb
templates/centos-8.2.2004/systemd.yaml.erb
templates/centos/systemd.yaml.erb
templates/default/systemd.yaml.erb
templates/systemd.yaml.erb

Using the resource like this:

datadog_monitor 'systemd' do
  instances [{
    'unit_names' => [
      'sshd',
    ],
  }]
end

So you would have to create your own template for it to work I guess.

stianfro avatar Sep 22 '20 12:09 stianfro

Hi @stianfro

If you pass the following to datadog_monitor:

use_integration_template          true

Then it will use a default template that essentially puts whatever you specify as instances, logs and init_config in the output yaml.

Let me know if it works for you :)

albertvaka avatar Sep 22 '20 13:09 albertvaka

@albertvaka just what I was looking for, it works great! :)

Here's what I ended up with for anyone interested:

ruby_block 'list systemd services' do
  block do
    Chef::Resource::RubyBlock.include Chef::Mixin::ShellOut
    command = 'systemctl list-units --type service --no-pager --no-legend | awk -F" " \'{ print $1}\''
    node.run_state['unit_names'] = shell_out(command).stdout.split(/\n+/)
  end
  not_if platform_family?('windows')
end

datadog_monitor 'systemd' do
  instances [ node.run_state ]
  use_integration_template true
  not_if platform_family?('windows')
  notifies :restart, 'service[datadog-agent]' if node['datadog']['agent_start']
end

stianfro avatar Sep 22 '20 16:09 stianfro