# Dynatrace

{% hint style="info" %}
Cortex connects to many third-party vendors whose system interfaces frequently change. As a result, integration behavior or configuration steps may shift without notice. If you encounter unexpected issues, check with your system administrator or refer to the vendor's documentation for the most current information. Additionally, integration sync times vary and are subject to scheduling overrides and timing variance.
{% endhint %}

### Overview

[Dynatrace](https://www.dynatrace.com/) is a monitoring and observability platform. Integrate Dynatrace with Cortex to get insights into application performance, service discovery, SLOs, and dependencies.

## How to configure Dynatrace with Cortex

### Prerequisite

Before getting started, generate an [access token in Dynatrace](https://www.dynatrace.com/support/help/dynatrace-api/basics/dynatrace-api-authentication) with the scopes `Read entities` and `Read SLO`.

### Configure the integration in Cortex

1. In Cortex, navigate to the [Dynatrace settings page](https://app.getcortexapp.com/admin/integrations/dynatrace).
   * Click **Integrations** from the main nav. Search for and select Dynatrace.
2. Click **Add configuration**.
3. Configure the Dynatrace integration form:
   * **Domain**: Enter your [Dynatrace domain](https://www.dynatrace.com/support/help/dynatrace-api/environment-api/entity-v2/get-entities-list) necessary to access your environment, depending on whether you use managed, SaaS, or the Environment ActiveGate version.
   * \**API token*: Enter the access token you generated in Dynatrace.
4. Click **Save**.

If you’ve set everything up correctly, you’ll see the option to **Remove Integration** in settings.

You can also use the **Test configuration** button to confirm that the configuration was successful. If your configuration is valid, you’ll see a banner that says “Configuration is valid. If you see issues, please see documentation or reach out to Cortex support.”

## How to connect Cortex entities to Dynatrace

### Import entities from Dynatrace

See the [Create services documentation](https://docs.cortex.io/entities/adding-entities/add-services#creating-services) for instructions on importing entities.

### Editing the entity Entity descriptor

**Entity ID**

Entities with a type of `"SERVICE"` will be discovered and surfaced. When using the Dynatrace portal, service IDs can be found in the URL of a selected service under the id query param. For example, `https://.live.dynatrace.com/#newservices/serviceOverview;id=`

```yaml
x-cortex-apm:
  dynatrace:
    entityIds:
      - mock-service-id-1
      - mock-service-id-2
```

**Entity name**

You can also match entities based on matching [display names](https://www.dynatrace.com/support/help/dynatrace-api/environment-api/entity-v2/get-entities-list#response-body-objects) with a regular expression, like:

```yaml
x-cortex-apm:
  dynatrace:
    entityNameMatchers:
      - "foo.*"
```

#### Linking SLOs in Cortex

Dynatrace supports service-level objective (SLO) monitoring. You can link these SLOs to your Dynatrace entity in Cortex:

1. In Dynatrace, navigate to the Service-Level Objectives app.
   * On the left sidebar of Dynatrace, click **Search**, then type in `slo` to find the app.
2. On the SLOs page, see the list of SLOs. On the right side of an SLO, click **^** to expand the Details.\
   ![The details button is on the right side of an SLO](https://826863033-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJW7pYRxS4dHS3Hv6wxve%2Fuploads%2Fgit-blob-14081a01962137a4cf25ee2426c1c763f59b0579%2Fdynatrace-details.jpg?alt=media)
3. In your browser's URL bar, locate the ID in the URL. Copy the ID and store it in a secure location, as you will need this value in the next steps.
   * The ID is displayed in the URL following `sloexp=`. For example, `https://.apps.dynatrace.com/ui/.../sloexp=&slovis=` ![The SLO ID is in the URL](https://826863033-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJW7pYRxS4dHS3Hv6wxve%2Fuploads%2Fgit-blob-840b8961f6d11325018ba32f1e7d26da3cb3fdc7%2Fdynatrace-slo-id.jpg?alt=media)
   * On the SLOs page, expand the details for each SLO to display the SLO ID in the URL.
4. Open your Cortex home page, then navigate to the service you are configuring.
5. In the upper right corner of the service page, click **Switch to YAML**.
6. Paste in the following text, making sure to replace `slo-id-1` and `slo-id-2` with the SLO IDs you obtained from the Dynatrace URL in the previous steps:

```yaml
x-cortex-slos:
  dynatrace:
    - id: slo-id-1
    - id: slo-id-2
```

7. At the bottom of the page, click **Save**.

After saving, navigate back to your service details page to view the SLO status in the service's Overview tab.

For information on working with SLOs in Dynatrace, see [Dynatrace's documentation](https://docs.dynatrace.com/docs/platform-modules/automations/service-level-objectives/configure-and-monitor-slo).

#### Dependencies

Cortex automatically syncs [dependencies](https://docs.cortex.io/ingesting-data-into-cortex/entities/adding-entities/dependencies) from Dynatrace using attributes inherent to each entity.

#### Discovery audit

Cortex will pull recent changes from your Dynatrace instance into the [discovered entities list](https://docs.cortex.io/ingesting-data-into-cortex/entities/discovery-audit). Here, you can find new entities in Dynatrace that have not been imported into the catalog - these will have the tag **New APM resource** - as well as entities in the catalog that no longer exist in Dynatrace - these will have the tag **APM resource not detected**.

## Using the Dynatrace integration

#### Entity pages

With the Dynatrace integration, you'll see SLOs on an entity's home page. High-level information about SLOs appears in the **Overview** tab.

Click **Monitoring** in the entity's sidebar to see more detailed data: the SLO name, its target, the current value for that entity, and the period of time the SLO is being calculated for. For example, if the time listed is "7 days ago," then the SLO is looking at the time range starting 7 days ago to now.

#### Relationship graphs

[Dependencies](#dependencies) detected from Dynatrace will appear in [Relationship graphs](https://app.getcortexapp.com/admin/graph).

### Scorecards and CQL

With the Dynatrace integration, you can create Scorecard rules and write CQL queries based on Dynatrace SLOs.

See more examples in the [CQL Explorer](https://app.getcortexapp.com/admin/cql-explorer) in Cortex.

<details>

<summary>SLOs</summary>

SLOs associated with a given entity via ID or tags. You can use these data to check whether an entity has SLOs associated with it and if those SLOs are passing.

* History
* ID
* Name
* Operation
* Remaining budget
* SLI value
  * Datum
  * Timeseries
* SLO target
* Source
* Thresholds
  * Name
  * Threshold

**Definition:** `slos()`

**Examples**

For a Scorecard focused on operational maturity, this expression can be used to make sure an entity has associated SLOs in Dynatrace:

```
slos().length > 0
```

This rule checks that there is at least one SLO is set up. While this rule makes sense in a Scorecard's first level, a rule checking the status of the SLO would make sense in a higher level:

```
slos().all((slo) => slo.passing)
```

Entities will pass this rule if all SLOs associated with it have "passing" status.

</details>

### View integration logs <a href="#still-need-help" id="still-need-help"></a>

## Background sync

Cortex conducts a background sync of Dynatrace entities at 7 a.m. UTC and a dependency sync every day at 12 a.m. UTC. You can [manually sync dependencies](https://docs.cortex.io/entities/adding-entities/dependencies#sync-dependencies) via the Relationship Graph.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cortex.io/ingesting-data-into-cortex/integrations/dynatrace.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
