> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Dynatrace

> Client-mode REST API connector for a curated Dynatrace Environment API v2 slice: metrics line-protocol ingest, events ingest, problems list, and logs ingest from MQTT

Technical Preview

## Overview

A client-mode connector for a **curated observability / ITSM** slice of the [Dynatrace Environment API v2](https://docs.dynatrace.com/docs/dynatrace-api):

| Catalog connector event | Entity / path | Notes |
| - | - | - |
| POST metrics/ingest | `POST /api/v2/metrics/ingest` | Line protocol (`text/plain`); scope `metrics.ingest`; expect **202** |
| POST events/ingest | `POST /api/v2/events/ingest` | JSON event body; scope `events.ingest`; expect **201** |
| GET problems | `GET /api/v2/problems` | List problems; scope `problems.read`; auth smoke → **200** |
| POST logs/ingest | `POST /api/v2/logs/ingest` | JSON array preferred; scope `logs.ingest`; expect **204** |

Default `BASE_ADDRESS` is `https://YOUR_ENVIRONMENT_ID.live.dynatrace.com`. Topics use `itsm/dynatrace/<object>/<verb>`.

> [!NOTE]
>
> Replace `YOUR_ENVIRONMENT_ID` with your Dynatrace environment id. ActiveGate deployments use `https://{activegate}:9999/e/{environment-id}` as BASE instead.

> [!NOTE]
>
> Prefer Hub secrets for the access token (`DYNATRACE_API_TOKEN`) and environment id. This template has not been verified against a live Dynatrace environment. Status remains blocked until an authenticated live smoke succeeds.

## Basic Syntax

```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
# Coreflux REST_API template — Dynatrace (Metrics/Events/Logs + Problems)
# Auth: Authorization: Api-Token {value.json.api_token}
# BASE_ADDRESS: https://YOUR_ENVIRONMENT_ID.live.dynatrace.com

DEFINE ROUTE DynatraceRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://YOUR_ENVIRONMENT_ID.live.dynatrace.com"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT Ingestmetrics
        WITH SOURCE_TOPIC "itsm/dynatrace/metric/ingest"
        WITH DESTINATION_TOPIC "itsm/dynatrace/metric/ingest/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/api/v2/metrics/ingest"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "text/plain; charset=utf-8"
            ADD "Authorization" "Api-Token {value.json.api_token}"
        WITH BODY "{payload}"
    ADD EVENT Ingestevent
        WITH SOURCE_TOPIC "itsm/dynatrace/event/ingest"
        WITH DESTINATION_TOPIC "itsm/dynatrace/event/ingest/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/api/v2/events/ingest"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "Api-Token {value.json.api_token}"
        WITH BODY "{payload}"
    ADD EVENT Listproblems
        WITH SOURCE_TOPIC "itsm/dynatrace/problem/list"
        WITH DESTINATION_TOPIC "itsm/dynatrace/problem/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/v2/problems?pageSize={value.json.page_size}&from={value.json.from}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Api-Token {value.json.api_token}"
    ADD EVENT Ingestlogs
        WITH SOURCE_TOPIC "itsm/dynatrace/log/ingest"
        WITH DESTINATION_TOPIC "itsm/dynatrace/log/ingest/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/api/v2/logs/ingest"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json; charset=utf-8"
            ADD "Authorization" "Api-Token {value.json.api_token}"
        WITH BODY "{payload}"
```

## Authentication

| Mode | Header | Notes |
| - | - | - |
| Classic access token | `Authorization: Api-Token {value.json.api_token}` | Default in this template |
| Platform token / OAuth | `Authorization: Bearer {value.json.api_token}` | Change the realm string |

Scopes for the curated ops: `metrics.ingest`, `events.ingest`, `problems.read`, `logs.ingest` (or platform `openpipeline:*` / storage equivalents). Store the token in Hub secrets (`DYNATRACE_API_TOKEN`) and resolve via `GET SECRET` — never commit credentials.

## MQTT examples

**Metrics** (line protocol body):

```text theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
coreflux.plant.vibration_rms,line=a,source=coreflux 12.4
```

Publish with `api_token` so the connector can set `Authorization`. Expect **HTTP 202**.

**Events:**

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "eventType": "CUSTOM_INFO",
  "title": "Coreflux plant alarm",
  "entitySelector": "type(CUSTOM_DEVICE),entityName.equals(line-a)",
  "properties": {"vibration_rms": "12.4"}
}
```

Expect **HTTP 201**.

**Problems list:**

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "api_token": "YOUR_API_TOKEN",
  "page_size": "1",
  "from": "now-2h"
}
```

Expect **HTTP 200**.

**Logs** (JSON array):

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
[
  {
    "content": "vibration_rms=12.4 threshold=8.0",
    "status": "WARN",
    "service.name": "coreflux-broker"
  }
]
```

Expect **HTTP 204**.

## Sources

* [Metrics ingest](https://docs.dynatrace.com/docs/dynatrace-api/environment-api/metric-v2/post-ingest-metrics)
* [Events ingest](https://docs.dynatrace.com/docs/dynatrace-api/environment-api/events-v2/post-event)
* [Problems list](https://docs.dynatrace.com/docs/dynatrace-api/environment-api/problems-v2/problems/get-problems-list)
* [Logs ingest](https://docs.dynatrace.com/docs/dynatrace-api/environment-api/log-monitoring-v2/post-ingest-logs)
* [Tokens and authentication](https://docs.dynatrace.com/docs/dynatrace-api/basics/dynatrace-api-authentication)

## Package

Broker template folder: `src/CorefluxCentral/Routes/Templates/RestApiConnectors/dynatrace/`

Deployable file: `DynatraceRestApi.lot` (no `ADD METADATA`). Hub icon/status: `hub-metadata.lot`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.