# Datadog Agent for Windows

## Install Datadog Agent

Run the following command in PowerShell with administrator privileges on the Windows host instance. It starts collecting and reporting metrics on CPU, memory, network, and uptime for the host instance.

Replace the placeholder `<KFUSE-DNS>` with the correct endpoint name.

Basic Installation

```powershell
$env:DD_UPGRADE="true"
$env:DD_API_KEY="kloudfuse"
$env:DD_URL="https://<KFUSE-DNS>/ingester"
Start-BitsTransfer -Source "https://s3.amazonaws.com/ddagent-windows-stable/datadog-agent-7-latest.amd64.msi" -Destination "$env:TEMP\datadog-agent-7-latest.amd64.msi"
Start-Process msiexec.exe -Wait -ArgumentList "/qn /i $env:TEMP\datadog-agent-7-latest.amd64.msi APIKEY=$env:DD_API_KEY DD_URL=$env:DD_URL"
```

## 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

```powershell
Copy-Item "C:\ProgramData\Datadog\conf.d\openmetrics.d\conf.yaml.example" `
          "C:\ProgramData\Datadog\conf.d\openmetrics.d\conf.yaml"
```

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

## Collect Logs

Edit your `C:\ProgramData\Datadog\datadog.yaml` file to collect logs.

Collect logs

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

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.

### Restart Datadog Agent Service

After making configuration changes, restart the Datadog Agent service:

```powershell
Restart-Service -Name datadogagent
```

### 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 `C:\ProgramData\Datadog\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.

Use this configuration to enable the collection of Windows events and system events (such as service status changes or system changes).

Collect events

```yaml
collect_events: true
```

After making configuration changes, restart the Datadog Agent service:

```powershell
Restart-Service -Name datadogagent
```

## Collect Traces

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

1. Open the `C:\ProgramData\Datadog\datadog.yaml` file and set the `apm_config` to `true`:

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

2. Restart the Datadog Agent service to apply the changes:

```powershell
Restart-Service -Name datadogagent
```

3. For each application, 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.

4. Enable the Datadog APM agent by setting environment variables for your application:

```powershell
$env:DD_AGENT_HOST="localhost"
$env:DD_TRACE_ENABLED="true"
$env:DD_ENV="<YOUR_ENV_NAME>"  # e.g., "production"
$env:DD_SERVICE="<YOUR_SERVICE_NAME>"  # e.g., "web-app"
$env:DD_VERSION="<YOUR_SERVICE_VERSION>"
```
