# Datadog Agent for Host Platforms

## Install Datadog Agent

Run the following command on the host instance. It starts collecting and reporting metrics on CPU, memory, network, and uptime for the host instance.

Replace the placeholder `<dns>` with the correct endpoint name.

### Basic Installation

```console
DD_UPGRADE=true \
DD_API_KEY=kloudfuse \
DD_URL="https://<KFUSE-DNS>/ingester" \
bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script_agent7.sh)"
```

## Collect Metrics

By enabling checks, such as OpenMetrics check, you can direct Datadog to collect additional metrics.

Copy the following example into your `conf.yaml` file in the `openmetrics.d` directory.

### Collect OpenMetrics

```console
cp /etc/datadog-agent/conf.d/openmetrics.d/conf.yaml.example \
/etc/datadog-agent/conf.d/openmetrics.d/conf.yaml
```

For more examples, see Datadog documentation on [OpenMetrics](https://docs.datadoghq.com/integrations/openmetrics/).

## Collect Logs

Edit your `/etc/datadog-agent/datadog.yaml` file to collect logs.

### Collect logs

```yaml
additional_endpoints:
  "https://<KFUSE-DNS>/ingester":
  - apikey1
logs_enabled: true
# collect_ec2_tags: true
# collect_gce_tags: false

metadata_providers:
  - name: host
    interval: 300

use_v2_api:
  series: true

enable_payloads:
  events: false
  series: false
  service_checks: false
  sketches: false
process_config:
  expvar_port: 0
  cmd_port: 0

logs_config:
  logs_dd_url: <KFUSE-DNS>:443
  logs_no_ssl: false
  force_use_http: true
  use_compression: true
  use_v2_api: false
```

|     |     |
| --- | --- |
|  | Starting with v6.19+/v7.19+, Datadog uses HTTPS transport; see Datadog documentation on [https://docs.datadoghq.com/agent/logs/log_transport/?tab=https](https://docs.datadoghq.com/agent/logs/log_transport/?tab=https) . |

### Add Source Files

To add source files for collection, see Datadog documentation of [Custom log collection](https://docs.datadoghq.com/agent/logs/?tab=tailfiles#custom-log-collection).

You must specify the `start_position` setting in the custom `conf.yaml` file if you are tailing custom files, to ensure that you receive all the data and not just the “live” data.

### Get Kloudfuse and Datadog Logs

For **Dual Shipping**, use the following configuration:

### Dual Shipping Logs for Datadog and Kloudfuse

```yaml
logs_enabled: true

logs_config:
  logs_dd_url: <DATADOG_DNS>:443
  logs_no_ssl: false
  force_use_http: true
  use_compression: true
  use_v2_api: false
  additional_endpoints:
    - api_key: apikey1
      Host: "<KFUSE-DNS>"
      Port: 443
      use_compression: true
      use_http: true
      use_v2_api: false
```

## Collect Events

Edit your `/etc/datadog-agent/datadog.yaml` file to collect events.

Be sure to enable the `collect_events` option. If this option is missing or set to false, you need to enable it.

### Collect events

```yaml
collect_events: true
```

## Collect Traces

To collect traces from containerized applications, configure the Datadog Agent to interact with OpenTracing or OpenTelemetry instrumented applications.

1. Open the `datadog.yaml` file and set the `apm_config` to `true`:

```yaml
apm_config:
     enabled: true
```

2. For each container, instrument your applications with Datadog’s APM (Application Performance Monitoring).

Simply add the Datadog APM libraries to your application — `dd-trace` for Python, `ddtrace` for Java, and so on.

3. Enable the Datadog APM agent by passing environment variables:

```text
   -e DD_AGENT_HOST=<DATADOG_AGENT_HOST>
   -e DD_TRACE_ENABLED=true
   -e DD_ENV=<YOUR_ENV_NAME>  # e.g., "production"
   -e DD_SERVICE=<YOUR_SERVICE_NAME>  # e.g., "web-app"
   -e DD_VERSION=<YOUR_SERVICE_VERSION>
```
