# Moving from Datadog

Tailcove takes Datadog's HTTP log intake format at `https://ingest.tailcove.dev/api/v2/logs`. Anything that ships
logs to Datadog over HTTP (the Datadog Agent, Vector's `datadog_logs` sink, Fluent Bit's `datadog` output) can ship
to Tailcove by changing where it sends and which key it uses. The key is your Tailcove source's **ingest token**.

## Send to both first

The Agent can send every log to a second destination while Datadog keeps getting them. In `datadog.yaml`:

```yaml
logs_enabled: true
logs_config:
  force_use_http: true
  additional_endpoints:
    - api_key: "YOUR_INGEST_TOKEN"
      Host: "ingest.tailcove.dev"
      Port: 443
      is_reliable: true
```

Restart the Agent. Where the file lives and how you restart depend on the system:

```bash@Linux
# Config: /etc/datadog-agent/datadog.yaml
sudo systemctl restart datadog-agent
```

```bash@macOS
# Config: ~/.datadog-agent/datadog.yaml
launchctl stop com.datadoghq.agent
launchctl start com.datadoghq.agent
```

```powershell@Windows
# Config: C:\ProgramData\Datadog\datadog.yaml. Run PowerShell as Administrator.
& "$env:ProgramFiles\Datadog\Datadog Agent\bin\agent.exe" restart-service
```

In a container, the Agent reads the same settings from environment variables instead (`DD_LOGS_CONFIG_...`), so change
them in your compose file or Helm values and recreate the container.

Lines show up in the source's Live tail within a few seconds.

## Then switch over

When you're ready to drop Datadog for logs, point the Agent's main log destination at Tailcove:

```yaml
logs_enabled: true
logs_config:
  force_use_http: true
  logs_dd_url: "ingest.tailcove.dev:443"
  compression_kind: gzip
```

and use the ingest token as the logs API key (`DD_LOGS_CONFIG_API_KEY`, or `api_key` if this Agent sends nothing
else to Datadog).

Newer Agents can compress logs with zstd. Tailcove reads gzip, and refuses a zstd body with a `422` that says so;
`compression_kind: gzip` fixes it.

### Vector

```toml
[sinks.tailcove]
type = "datadog_logs"
inputs = ["app_logs"]
endpoint = "https://ingest.tailcove.dev"
default_api_key = "YOUR_INGEST_TOKEN"
compression = "gzip"
```

### Fluent Bit

```ini
[OUTPUT]
    Name        datadog
    Match       *
    Host        ingest.tailcove.dev
    TLS         on
    compress    gzip
    apikey      YOUR_INGEST_TOKEN
    dd_service  checkout
    dd_source   nodejs
```

## What arrives

| Datadog field            | In Tailcove                                                   |
| ------------------------ | ------------------------------------------------------------- |
| `message`                | the message                                                   |
| `status`                 | the level (`warn` is `warning`, `ok` is `info`)               |
| `hostname`               | the host                                                      |
| `timestamp`              | the line's time                                               |
| `service`, `ddsource`    | fields of the same name                                       |
| `ddtags` (`env:prod,...`) | `tags`, and each tag as its own field (`env:prod`)           |
| any other attribute      | a field of the same name                                      |

When the message is itself a JSON object (a JSON log file tailed by the Agent), Tailcove reads it the way Datadog
would: its own `message`, `level` and time win, and its other keys become fields.

So most searches carry over as they are: `service:checkout env:prod` works in both. Two differences: Datadog's
`status:error` is `level:error` here, and Tailcove's fields are top-level, so a nested attribute like
`@http.status_code` needs logging at the top level (`status_code`) to be searchable.

## Bring your log monitors

Open a source's **Alerts** tab and choose **Import from Datadog**. Paste a monitor's JSON (Export in the monitor's
menu) or the whole answer of `GET /api/v1/monitor`. Each log monitor is shown next to the alert it becomes, and you
import the ones you tick.

A monitor like

```
logs("service:checkout status:error").index("*").rollup("count").last("5m") > 20
```

becomes an alert on `service:checkout level:error` that fires at 21 lines in 5 minutes. A `< 1` monitor becomes a
"no lines" alert. Some monitors can't come over as they are, and the import says why instead of guessing: metric or
APM monitors, a rollup other than count, a `.by()` group, a window longer than a day, or a query term with no
Tailcove meaning. Imported alerts email your team's members; add Slack, PagerDuty or a webhook on each afterwards.
