> For the complete documentation index, see [llms.txt](https://upsolver.gitbook.io/content/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://upsolver.gitbook.io/content/reference-1/sql-commands/jobs/create-job/monitoring/dynatrace.md).

# Dynatrace

To export monitoring data from your Upsolver account, you must first create a connection that provides the appropriate credentials to access your Dynatrace account.

## Syntax

```sql
CREATE DYNATRACE CONNECTION <connection_identifier>
    { API_ENDPOINT = '<api_endpoint>' | ENVIRONMENT_ID = '<env_id>' }
    API_TOKEN = '<generated_token>'
    [ COMMENT = '<comment>' ];
```

**Jump to**

* [`API_ENDPOINT`](#api_endpoint)
* [`API_TOKEN`](#api_token)
* [`ENVIRONMENT_ID`](#environment_id)
* [`COMMENT`](#comment-editable)

## Connection Options

#### `API_ENDPOINT`

Type: `text`

The API endpoint for your Dynatrace account. See the [Dynatrace documentation](https://docs.dynatrace.com/docs/dynatrace-api#endpoints) for more information. If you include this option, the [`ENVIRONMENT_ID`](#environment_id) is not required (use one or the other). &#x20;

#### `API_TOKEN`

Type: `text`

The API token for your Dynatrace account. When you generate the API token in your Dynatrace account, ensure that it has ingest metrics scope. See the [Dynatrace documentation](https://docs.dynatrace.com/docs/dynatrace-api/basics/dynatrace-api-authentication) for more information.&#x20;

#### `ENVIRONMENT_ID`

Type: `text`

The environment ID for your Dynatrace account. If you include this option, you don't need to include the [`API_ENDPOINT`](#api_endpoint) option (use one or the other).

#### `COMMENT` — editable

Type: `text`

(Optional) A description or comment regarding this connection.

## Examples

### Create a connection

The following example creates a new connection named **my\_dynatrace\_connection** that will be used to send monitoring information to Dynatrace.

```sql
CREATE DYNATRACE CONNECTION my_dynatrace_connection
    API_TOKEN = 'my_api_token'
    ENVIRONMENT_ID = 'environment_id'
    COMMENT = 'Dynatrace connection for Upsolver job metrics';
```

### Create a job

The following script creates a job named **send\_monitoring\_data\_to\_dynatrace** that sends job metrics to the Dynatrace account **my\_dynatrace\_connection** created in the above example:

```sql
CREATE JOB send_monitoring_data_to_dynatrace 
    START_FROM = NOW 
AS INSERT INTO my_dynatrace_connection
    MAP_COLUMNS_BY_NAME
       SELECT job_id AS tags.id, 
              job_name AS tags.job_name, 
              discovered_files_lifetime AS files,
              avg_file_size_today AS avg_file_size,
              avg_rows_scanned_per_execution_today AS avg_rows_scanned,
              cluster_id AS tags.cluster_id,
              cluster_name AS tags.cluster_name,              
              RUN_START_TIME() AS time
       FROM system.monitoring.jobs;
```

The job includes the **cluster\_id** and **cluster\_name** as tags, which is helpful if you have multiple clusters in your organization.&#x20;

{% hint style="info" %}
**Note**&#x20;

Please ensure you include `RUN_START_TIME()` AS time in the `SELECT` statement that reads from the system tables to avoid seeing an error.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://upsolver.gitbook.io/content/reference-1/sql-commands/jobs/create-job/monitoring/dynatrace.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
