# CREATE METRICS INTEGRATION

## Syntax <a href="#synopsis" id="synopsis"></a>

```sql
CREATE METRICS INTEGRATION 
    metrics_integration_name 
WITH (metrics_integration_parameter = value [, ... ]);
```

### Description

Metrics integrations make it possible for organizations to configure an integration that enables scraping of query metrics.

### Arguments

#### **metrics\_integration\_name**

Specifies the name of the new metrics integration. If the name is case-sensitive, you must wrap it in double quotes; otherwise, the system uses the lower case name.

#### **token.expires\_in\_days**

Number of days that this token is valid for. Default: 90 days.

## Examples

#### Create a metrics integration

The following creates a new metrics integration with name `my-integration` and is valid for `AWS us-east-1`:

```sh
demodb.public/demostore# CREATE METRICS INTEGRATION "my-integration";
+---------------------+----------------+----------+------------------------------------------+-------------------+------------------------+
|  Type               |  Name          |  Command |  Summary                                 |  Token            |  Uri                   |
+=====================+================+==========+==========================================+===================+========================+
| metrics integration | my-integration | CREATE   | metrics integration my-integration was   | <my access token> | https://uri/to/metrics |
|                     |                |          | successfully created                     |                   |                        |
+---------------------+----------------+----------+------------------------------------------+-------------------+------------------------+
```

The command will output a URI and token you can add as a metric endpoint in Prometheus in Grafana. See [#guide-to-add-metrics-integration-to-prometheus](#guide-to-add-metrics-integration-to-prometheus "mention") for more information.\
\
If you have an active query you can test the URI and token with the following curl command. Use the URI from CREATE METRICS INTEGRATION output:

```
curl https://api-atyo2.deltastream.io/metrics -H "Accept: text/plain" -H "Authorization: Bearer [my access token]"
```

If there's a query running the output of the above curl should look like:

```
# TYPE deltastream_query_consumerRecordsLagMax untyped
deltastream_query_consumerRecordsLagMax{organization_id="<org-UUID>",query_id="<query-UUID>",relation="KafkaSource:pageviews_all"} 0 1715802519327
# TYPE deltastream_query_numBytesInPerSecond untyped
deltastream_query_numBytesInPerSecond{organization_id="<org-UUID>",query_id="<query-UUID>",relation="KafkaSource:pageviews_all"} 90 1715802519327
deltastream_query_numBytesInPerSecond{organization_id="<org-UUID>",query_id="<query-UUID>",relation="KafkaSink:pageviews_all_metrics"} 0 1715802519327
# TYPE deltastream_query_numBytesOutPerSecond untyped
deltastream_query_numBytesOutPerSecond{organization_id="<org-UUID>",query_id="<query-UUID>",relation="KafkaSource:pageviews_all"} 0 1715802519327
deltastream_query_numBytesOutPerSecond{organization_id="<org-UUID>",query_id="<query-UUID>",relation="KafkaSink:pageviews_all_metrics"} 202 1715802519327
# TYPE deltastream_query_numRecordsInPerSecond untyped
deltastream_query_numRecordsInPerSecond{organization_id="<org-UUID>",query_id="<query-UUID>",relation="KafkaSource:pageviews_all"} 1 1715802519327
deltastream_query_numRecordsInPerSecond{organization_id="<org-UUID>",query_id="<query-UUID>",relation="KafkaSink:pageviews_all_metrics"} 1 1715802519327
# TYPE deltastream_query_numRecordsOutPerSecond untyped
deltastream_query_numRecordsOutPerSecond{organization_id="<org-UUID>",query_id="<query-UUID>",relation="KafkaSource:pageviews_all"} 1 1715802519327
deltastream_query_numRecordsOutPerSecond{organization_id="<org-UUID>",query_id="<query-UUID>",relation="KafkaSink:pageviews_all_metrics"} 1 1715802519327
```

## Guide to Add Metrics Integration to Prometheus

{% content-ref url="/pages/xxnZJdIKGhADraEu7r6g" %}
[Prometheus Integration](/reference/metrics/prometheus-integration.md)
{% endcontent-ref %}


---

# 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.deltastream.io/reference/sql-syntax/ddl/create-metrics-integration.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.
