The Datadog Chef recipes are used to deploy Datadog’s components and configuration automatically. The cookbook includes support for:
Datadog Agent v7.x (default)
Datadog Agent v6.x
Datadog Agent v5.x
Note: This page may discuss features that are not available for your selected version. Check the README of the
git tag or gem version for your version’s documentation.
The Datadog Chef cookbook is compatible with chef-client >= 12.7. If you need support for Chef < 12.7, use a release 2.x of the cookbook. See the CHANGELOG for more info.
Chef 13 users: With Chef 13 and chef_handler 1.x, you may have trouble using the dd-handler recipe. The known workaround is to update your dependency to chef_handler >= 2.1.
As node attributes by declaring the keys in another cookbook at a higher precedence level.
In the node run_state by setting node.run_state['datadog']['api_key'] in another cookbook preceding Datadog’s recipes in the run_list. This approach does not store the credential in clear text on the Chef Server.
Note: When using the run state to store your API and application keys, set them at compile time before datadog::dd-handler in the run list.
To add additional elements to the Agent configuration file (typically datadog.yaml) that are not directly available as attributes of the cookbook, use the node['datadog']['extra_config'] attribute. This is a hash attribute, which is marshaled into the configuration file accordingly.
Enable Agent integrations by including the recipe and configuration details in your role’s run-list and attributes.
Note: You can use the datadog_monitor resource for enabling Agent integrations without a recipe.
Associate your recipes with the desired roles, for example role:chef-client should contain datadog::dd-handler and role:base should start the Agent with datadog::dd-agent. Below is an example role with the dd-handler, dd-agent, and mongo recipes:
name'example'description'Example role using DataDog'default_attributes('datadog'=>{'agent_major_version'=>7,'api_key'=>'<YOUR_DD_API_KEY>','application_key'=>'<YOUR_DD_APP_KEY>','mongo'=>{'instances'=>[{'host'=>'localhost','port'=>'27017'}]}})run_list%w(
recipe[datadog::dd-agent]
recipe[datadog::dd-handler]
recipe[datadog::mongo]
)
Note: data_bags are not used in this recipe because it is unlikely to have multiple API keys with only one application key.
By default, the current major version of this cookbook installs Agent v7. The following attributes are available to control the Agent version installed:
Parameter
Description
agent_major_version
Pin the major version of the Agent to 5, 6, or 7 (default).
agent_version
Pin a specific Agent version (recommended).
agent_package_action
(Linux only) Defaults to 'install' (recommended), 'upgrade' to get automatic Agent updates (not recommended, use the default and change the pinned agent_version to upgrade).
agent_flavor
(Linux only) Defaults to 'datadog-agent' to install the datadog-agent, can be set to 'datadog-iot-agent' to install the IOT agent.
See the sample attributes/default.rb for your cookbook version for all available attributes.
To use an Agent from a custom repository, you can set the aptrepo option.
By default, this option is equal to [signed-by=/usr/share/keyrings/datadog-archive-keyring.gpg] apt.datadoghq.com. If a custom value is set, another signed-by keyring can also be set [signed-by=custom-repo-keyring-path] custom-repo.
The dd-agent recipe installs the Datadog Agent on the target system, sets your Datadog API key, and starts the service to report on local system metrics.
Note: Windows users upgrading the Agent from versions <= 5.10.1 to >= 5.12.0, set the windows_agent_use_exe attribute to true. For more details, see the dd-agent wiki.
Python: Add a dependency on the poise-python cookbook to your custom/wrapper cookbook, and use the resource below. For more details, see the poise-python repository.
python_package'dogstatsd-python'# assumes python and pip are installed
Python: Add a dependency on the poise-python cookbook to your custom/wrapper cookbook, and use the resource below. For more details, see the poise-python repository.
python_package'ddtrace'# assumes python and pip are installed
The system-probe recipe is automatically included by default. It writes the system-probe.yaml file. This behavior can be disabled by setting node['datadog']['system_probe']['manage_config'] to false.
To enable Network Performance Monitoring (NPM) in system-probe.yaml, set node['datadog']['system_probe']['network_enabled'] to true.
To enable Universal Service Monitoring (USM) 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.
The name of the Agent integration to configure and enable.
instances
The fields used to fill values under the instances section in the integration configuration file.
init_config
The fields used to fill values under the the init_config section in the integration configuration file.
logs
The fields used to fill values under the the logs section in the integration configuration file.
use_integration_template
Set to true (recommended) to use the default template, which writes the values of instances, init_config, and logs in the YAML under their respective keys. This defaults to false for backward compatibility, but may default to true in a future major version of the cookbook.
config_name
The filename used when creating an integrations configuration file. Overriding this property allows the creation of multiple configuration files for a single integration. This defaults to conf, which creates a configuration file named conf.yaml.
This example enables the ElasticSearch integration by using the datadog_monitor resource. It provides the instance configuration (in this case: the URL to connect to ElasticSearch) and sets the use_integration_template flag to use the default configuration template. Also, it notifies the service[datadog-agent] resource to restart the Agent.
Note: The Agent installation must be above this recipe in the run list.
datadog_integration'name'doversionString# version to install for :install actionactionSymbol# defaults to :installthird_party[true,false]# defaults to :falseend
To get the available versions of the integrations, see the integration-specific CHANGELOG.md in the integrations-core repository.
Note: For Chef Windows users, the chef-client must have read access to the datadog.yaml file when the datadog-agent binary available on the node is used by this resource.
Then attach a console to the container or use the VS Code remote-container feature to develop inside the container.
To run kitchen-docker tests from within the container:
# Note: Also set KITCHEN_DOCKER_HOSTNAME=host.docker.internal if on MacOS or Windows
# Run this under a login shell (otherwise `bundle` won't be found)
KITCHEN_LOCAL_YAML=kitchen.docker.ymlbundleexecrakecircle