datadog_monitor usability and YAML mapping
Usability of this cookbook should be improved:
Every time I need to lookup the available monitor YAML settings on the DD website or the agent python source. Then I need to add it to my chef attributes just to find out that the template does not map those keys yet.
I suggest to retire the entire datadog_monitor resource and provide a new resource that just 1:1 maps an array (or hash) structure into YAML without having a "custom" template for each check.
Bonus for collecting instances so that I can programatically add instances for the same check in a chef run, e.g.
datadog_monitor_instance 'production website' do
monitor 'nginx'
name 'cool.io'
instance {
'nginx_status_url' => "https://cool.io/nginx_status/",
'name' => ['test'],
'ssl_validation' => false
}
end
datadog_monitor_instance 'staging website' do
monitor 'nginx'
name 'staging.cool.io'
instance {
'nginx_status_url' => "https://staging.cool.io/nginx_status/",
'tags' => ['test'],
'ssl_validation' => false
}
end
# AND
datadog_monitor_instances 'production websites' do
monitor 'nginx'
instances [
{
'nginx_status_url' => "https://cool.io/nginx_status/",
'name' => "site1",
'ssl_validation' => false
},
{
'nginx_status_url' => "https://easy.io/nginx_status/",
'name' => "site2",
'ssl_validation' => false
},
{
'nginx_status_url' => "https://vm.io/nginx_status/",
'name' => "site3",
'ssl_validation' => false
}
]
end
...
I've run into this a few times too. At the very least having the option to override the monitor template would be useful.
this is still an unresolved issue.
for example:
- https://github.com/DataDog/chef-datadog/blob/main/templates/default/nginx.yaml.erb
- https://github.com/DataDog/integrations-core/blob/master/nginx/datadog_checks/nginx/data/conf.yaml.example
Hi @rmoriz!
A generic datadog_monitor resource already existsts, with the fields init_config, instances and logs which are just generic maps/arrays. For it to work, you also need to set use_integration_template in it to true. You can see an example in the readme under Integrations without recipes.
The reason the old resources still exist is for backwards compatibility, but as you pointed out they are lacking many of the new fields.
I hope this helps!