Datadog Agent 和集成的主厨手册
The Datadog Chef cookbook automates the installation and configuration of the Datadog Agent across supported Linux and Windows platforms. The cookbook is compatible with chef-client >= 12.7, and supports Windows and Linux platforms. For full attribute references, recipes, usage examples, and integration configuration patterns, see the Advanced configurations section.
The Datadog Chef recipes are used to deploy Datadog's components and configuration automatically. The cookbook includes support for:
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 = 16.10.8 or Chef >= 17.0.69)
The following Opscode cookbooks are dependencies:
aptchef_handleryumNote: apt cookbook v7.1+ is needed to install the Agent on Debian 9+.
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.
To install the Datadog Agent with Chef, follow the [in-app flow in Fleet Automation][18] setup guide for Berkshelf or Knife. This setup guide allows you to select observability features, and generates the necessary attributes and commands for your environment.
These setup steps are also listed below:
# Berksfile
cookbook 'datadog', '~> 4.0'
```
```shell
# Knife
knife cookbook site install datadog
```
2. Set the [Datadog-specific attributes](#datadog-attributes) in a role, environment, or another recipe:
```text
node.default['datadog']['api_key'] = ""
node.default['datadog']['application_key'] = ""
```
3. Upload the updated cookbook to your Chef server:
```shell
berks upload
# or
knife cookbook upload datadog
```
4. After uploading, add the cookbook to your node's `run_list` or `role`:
```text
"run_list": [
"recipe[datadog::dd-agent]"
]
```
5. Wait for the next scheduled `chef-client` run or trigger it manually.
### Datadog attributes
The following methods are available for adding your [Datadog API and application keys][4]:
* As node attributes with an `environment` or `role`.
* 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.
## Advanced configurations
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.
### Examples
The following code sets the field `secret_backend_command` in the configuration file `datadog.yaml`:
```ruby
default_attributes(
'datadog' => {
'extra_config' => {
'secret_backend_command' => '/sbin/local-secrets'
}
}
)The secret_backend_command can also be set using:
default['datadog']['extra_config']['secret_backend_command'] = '/sbin/local-secrets'For nested attributes, use object syntax. The following code sets the field logs_config in the configuration file datadog.yaml:
default['datadog']['extra_config']['logs_config'] = { 'use_port_443' => true }Follow the steps below to deploy the Datadog Agent with Chef on AWS OpsWorks:
{"datadog":{"agent_major_version": 7, "api_key": "", "application_key": ""}}install-lifecycle recipe:include_recipe '::dd-agent'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' => '',
'application_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][1] for your cookbook version for all available attributes.
Some attribute names have changed from version 3.x to 4.x of the cookbook. Use this reference table to update your configuration:
| Action | Cookbook 3.x | Cookbook 4.x |
|---|---|---|
| Install Agent 7.x | Not supported | 'agent_major_version' => 7 |
| Install Agent 6.x | 'agent6' => true |
'agent_major_version' => 6 |
| Install Agent 5.x | 'agent6' => false |
'agent_major_version' => 5 |
| Pin agent version | 'agent_version' or 'agent6_version' |
'agent_version' for all versions |
| Change package_action | 'agent_package_action' or 'agent6_package_action' |
'agent_package_action' for all versions |
| Change APT repo URL | 'aptrepo' or 'agent6_aptrepo' |
'aptrepo' for all versions |
| Change APT repo distribution | 'aptrepo_dist' or 'agent6_aptrepo_dist' |
'aptrepo_dist' for all versions |
| Change YUM repo | 'yumrepo' or 'agent6_yumrepo' |
'yumrepo' for all versions |
| Change SUSE repo | 'yumrepo_suse' or 'agent6_yumrepo_suse' |
'yumrepo_suse' for all versions |
Use one of the following methods to upgrade from Agent v6 to v7:
agent_major_version to 7, agent_package_action to install, and pin a specific v7 version as agent_version (recommended).agent_major_version to 7 and agent_package_action to upgrade.The following example upgrades from Agent v6 to v7. The same applies if you are upgrading from Agent v5 to v6.
default_attributes(
'datadog' => {
'agent_major_version' => 7,
'agent_version' => '7.25.1',
'agent_package_action' => 'install',
}
)To downgrade the Agent version, set the 'agent_major_version', 'agent_version', and 'agent_allow_downgrade'.
The following example downgrades to Agent v6. The same applies if you are downgrading to Agent v5.
default_attributes(
'datadog' => {
'agent_major_version' => 6,
'agent_version' => '6.10.0',
'agent_allow_downgrade' => true
}
)To uninstall the Agent, remove the dd-agent recipe and add the remove-dd-agent recipe with no 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 example below uses the staging repository:
default_attributes(
'datadog' => {
'aptrepo' => '[signed-by=/usr/share/keyrings/datadog-archive-keyring.gpg] apt.datad0g.com',
}
}Access the [Datadog Chef recipes on GitHub][7].
The [default recipe][8] is a placeholder.
The [dd-agent recipe][9] installs the Datadog Agent on the target system, sets your [Datadog API key][4], and starts the service to report on local system metrics.
Note: Windows users upgrading the Agent from versions = 5.12.0, set the windows_agent_use_exe attribute to true. For more details, see the [dd-agent wiki][10].
The [dd-handler recipe][11] installs the [chef-handler-datadog][12] gem and invokes the handler at the end of a Chef run to report the details to the news feed.
To install a language-specific library that interacts with DogStatsD:
poise-python cookbook to your custom/wrapper cookbook, and use the resource below. For more details, see the [poise-python repository][14].python_package 'dogstatsd-python' # assumes python and pip are installedTo install a language-specific library for application tracing (APM):
poise-python cookbook to your custom/wrapper cookbook, and use the resource below. For more details, see the [poise-python repository][14].python_package 'ddtrace' # assumes python and pip are installedThere are many [recipes][7] to assist you with deploying Agent integration configuration files and dependencies.
The [system-probe recipe][17] 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 Perform
暂无开放 Issues,或尚未同步最近议题。