# Metrics API

Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fuser-guides%2Fdata-query%2Fmetrics-api.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fuser-guides%2Fdata-query%2Fmetrics-api.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

## Overview[​](#overview "Direct link to Overview")

Coralogix provides a **Metrics API**,. granting you access to all metrics you’ve sent to Coralogix. This API supports two primary use cases: querying metrics data programmatically and acting as a PromQL-compatible query data source (e.g., as a [Grafana Prometheus data source](https://grafana.com/docs/grafana/latest/datasources/prometheus/)).

## Authentication[​](#authentication "Direct link to Authentication")

Each HTTP request must include an `Authorization` header with a value `Bearer <API-Key>`. Configure a [customized API key](https://docs-docusaurus.kinsta.page/user-guides/account-management/api-keys/api-keys/.md) with the `DataQuerying` role preset or `Query Metrics` permission: `metrics.data-api#high:ReadData`. For more details, refer [here](https://docs-docusaurus.kinsta.page/user-guides/account-management/api-keys/api-keys/.md).

Alternatively, you may use the `Legacy Logs Query API Key`.

## Querying metrics data programmatically[​](#querying-metrics-data-programmatically "Direct link to Querying metrics data programmatically")

### Prometheus-compatible API request[​](#prometheus-compatible-api-request "Direct link to Prometheus-compatible API request")

Include the following in your API request:

| Header | Authorization: `Bearer <API-Key>`                                                                                                                                                                                                                                         |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| URL    | Select the <!-- -->https\://api./metrics<!-- --> Metrics endpoint that corresponds to your Coralogix [domain](https://docs-docusaurus.kinsta.page/user-guides/account-management/account-settings/coralogix-domain/.md) using the domain selector at the top of the page. |
|        |                                                                                                                                                                                                                                                                           |

### Examples[​](#examples "Direct link to Examples")

Ensure you update your Coralogix [domain](https://docs-docusaurus.kinsta.page/user-guides/account-management/account-settings/coralogix-domain/.md) and API key in the following examples.

**Instant Metric Query**

Evaluates an instant metric at a defined single point in time.

```
curl --location --request GET 'https://api.eu2.coralogix.com/metrics/api/v1/query?query=vector(1)' --header 'Authorization: Bearer <API-Key>'
```

## PromQL-compatible query data source[​](#promql-compatible-query-data-source "Direct link to PromQL-compatible query data source")

### Grafana Prometheus data source[​](#grafana-prometheus-data-source "Direct link to Grafana Prometheus data source")

Configure a Prometheus data source in Grafana:

**STEP 1**. Navigate to **Home** > **Connection** > **Add new connection**. Enter **Prometheus data source**.

**STEP 2**. Click **Add new data source**.

**STEP 3**. Input the following fields:

**Connection**

* Prometheus server URL: Choose the
  <!-- -->
  https\://api./metrics
  <!-- -->
  endpoint that corresponds to your Coralogix [domain](https://docs-docusaurus.kinsta.page/user-guides/account-management/account-settings/coralogix-domain/.md) using the domain selector at the top of the page.

**Authentication**

* **HTTP headers**:

  <!-- -->

  * Header: `Authorization`

  * Value: `Bearer <API-Key>` (as mentioned in the **Authentication** section above)

**Advanced Settings**

* **Performance**

  * Prometheus type: `Prometheus`

  * Prometheus version: `2.24.x`

**STEP 4**. Click **Save & test**. You should receive a message confirming a successful query to the Prometheus API.

Find out more [here](https://grafana.com/docs/grafana/latest/datasources/prometheus/).

## API support[​](#api-support "Direct link to API support")

### Supported APIs[​](#supported-apis "Direct link to Supported APIs")

The following are examples of **supported** APIs for HTTP methods GET and POST.

| API                                      | Description                      |
| ---------------------------------------- | -------------------------------- |
| `/api/v1/query`                          | Instant query                    |
| `/api/v1/query_range`                    | Range query                      |
| `GET /api/v1/label/<label_name>/values`  | Querying label values            |
| `GET /api/v1/labels POST /api/v1/labels` | Getting label names              |
| `GET /api/v1/series POST /api/v1/series` | Finding series by label matchers |

Details on how to use supported APIs can be found [here](https://prometheus.io/docs/prometheus/latest/querying/api).

### Unsupported APIs[​](#unsupported-apis "Direct link to Unsupported APIs")

The following are examples of **unsupported** APIs for HTTP methods GET and POST.

| API                            | Description                                     |
| ------------------------------ | ----------------------------------------------- |
| `GET /api/v1/alerts`           | Returns a list of all active alerts             |
| `/api/v1/query_exemplars`      | Query exemplars for a specific series over time |
| `GET /api/v1/rules`            | Returns a list of alerting and recording rules  |
| `GET /api/v1/targets/metadata` | Returns metadata about metrics from targets     |

## Additional resources[​](#additional-resources "Direct link to Additional resources")

|                        |                                                                              |
| ---------------------- | ---------------------------------------------------------------------------- |
| External Documentation | [Prometheus API](https://prometheus.io/docs/prometheus/latest/querying/api/) |
