# Better Stack Datadog Agent metrics & logs forwarding

## Start monitoring in 2 minutes

### 1. Install Datadog Agent

Set up Datadog Agent using the official install script to send metrics:

```sh
[label Datadog Installation script]
DD_URL="https://$INGESTING_HOST_DATADOG" \
DD_API_KEY="$SOURCE_TOKEN" \
DD_HOSTNAME="$(hostname)" \
DD_INSTRUMENTATION_TELEMETRY_ENABLED="false" \
bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script_agent7.sh)"
```

### 2. (Optional) Enable log forwarding

To enable log forwarding to Better Stack, update the following values in  `/etc/datadog-agent/datadog.yaml` config:

[code-tabs]
```yaml
[label YAML config for log forwarding]
api_key: "$SOURCE_TOKEN"

logs_enabled: true
logs_config:
  logs_dd_url: "$INGESTING_HOST_DATADOG:443"
  force_use_http: true
```
[/code-tabs]

[info]
#### Can't find your datadog.yaml configuration?
Run `datadog-agent status header | grep 'Config Path'` to get the config path.
[/info]

#### Custom log collection

By default, installed Datadog Agent doesn't collect any logs. You can start collecting logs from a log file by creating a custom configuration, for example to collect Apache logs:

```yaml
[label /etc/datadog-agent/conf.d/apache.d/conf.yaml]
logs:
  - type: file
    path: /var/log/apache2/access.log
    source: apache
    service: apache
  - type: file
    path: /var/log/apache2/error.log
    source: apache
    service: apache
```

You can find example configurations for commonly used services in `/etc/datadog-agent/conf.d/`.

Read more about [Log collection configuration](https://docs.datadoghq.com/agent/logs/?tab=tailfiles) in the official docs.

### 3. Restart Datadog Agent

Restart the Datadog Agent to apply the new configuration:

[code-tabs]
```bash
[label Ubuntu, Debian]
sudo service datadog-agent restart
```
```bash
[label CentOS, Red Hat]
sudo systemctl restart datadog-agent
```
[/code-tabs]

### 4. Verify metrics and logs forwarding

- **Metrics**: Check your metrics in the [Datadog Agent dashboard](https://telemetry.betterstack.com/team/0/dashboards/platform/datadog_agent ";_blank").
- **Logs**: If you enabled logs, check your logs in [Better Stack → Live tail](https://telemetry.betterstack.com/team/0/tail ";_blank").

## Adjust existing Datadog Agent

Adjust Datadog Agent to send metrics and logs.

### Update configuration

Update the following values in your existing `/etc/datadog-agent/datadog.yaml` config:

[code-tabs]
```yaml
[label Send logs and metrics to Better Stack]
# Metrics configuration
dd_url: "https://$INGESTING_HOST_DATADOG"
api_key: "$SOURCE_TOKEN"

# Logs configuration
logs_enabled: true
logs_config:
  logs_dd_url: "$INGESTING_HOST_DATADOG:443"
  force_use_http: true

# Disable unsupported optional telemetry settings
apm_config:
  enabled: false
process_config:
  process_collection:
    enabled: false
  container_collection:
    enabled: false
network_path:
  connections_monitoring:
    enabled: false
```
[/code-tabs]

[info]
#### Can't find your datadog.yaml configuration?
Run `datadog-agent status header | grep 'Config Path'` to get the config path.
[/info]

### Restart Datadog Agent

Restart the Datadog Agent to apply the new configuration:

[code-tabs]
```bash
[label Ubuntu, Debian]
sudo service datadog-agent restart
```
```bash
[label CentOS, Red Hat]
sudo systemctl restart datadog-agent
```
[/code-tabs]

---

### Need help?

Please let us know at hello@betterstack.com.  
We're happy to help! 🙏
