# Metrics API

Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%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%2Fcoralogix.com%2Fdocs%2Fuser-guides%2Fdata-query%2Fmetrics-api.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

The Metrics API gives you access to every metric you have sent to Coralogix through a Prometheus-compatible interface. That means two things in practice: you can query metrics programmatically with `curl` or any HTTP client, and you can point a [Grafana Prometheus data source](https://grafana.com/docs/grafana/latest/datasources/prometheus/) straight at it.

## What you need [​](#what-you-need- "Direct link to what-you-need-")

* A [custom API key](https://coralogix.com/docs/user-guides/account-management/api-keys/api-keys.md) with the `DataQuerying` role preset, or the `Query Metrics` permission `metrics.data-api#high:ReadData`. A `Legacy Logs Query API Key` also works.
* The metrics endpoint for your Coralogix [domain](https://coralogix.com/docs/user-guides/account-management/account-settings/coralogix-domain.md). Use the domain selector at the top of this page to resolve it:
  <!-- -->
  https\://api./metrics

Every request carries the key in an `Authorization` header:

```
Authorization: Bearer <API-Key>
```

## Query metrics programmatically [​](#query-metrics-programmatically- "Direct link to query-metrics-programmatically-")

An instant query evaluates an expression at a 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>'
```

Substitute the endpoint for your domain and your own API key.

## Use it as a Grafana data source [​](#use-it-as-a-grafana-data-source- "Direct link to use-it-as-a-grafana-data-source-")

1

<!-- -->

.

Add the data source

In Grafana, select **Home**, then **Connections**, then **Add new connection**. Search for **Prometheus**, then select **Add new data source**.

2

<!-- -->

.

Configure the connection

Set **Prometheus server URL** to the metrics endpoint for your Coralogix domain.

3

<!-- -->

.

Configure authentication

Under **HTTP headers**, add a header named `Authorization` with the value `Bearer <API-Key>`.

4

<!-- -->

.

Set the Prometheus version

Under **Advanced settings**, then **Performance**, set **Prometheus type** to `Prometheus` and **Prometheus version** to `2.24.x`.

5

<!-- -->

.

Save and test

Select **Save & test**. A successful query to the Prometheus API confirms the data source works.

Grafana's own [Prometheus data source documentation](https://grafana.com/docs/grafana/latest/datasources/prometheus/) covers the remaining options.

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

Available for both GET and POST. See the [Prometheus HTTP API reference](https://prometheus.io/docs/prometheus/latest/querying/api) for their parameters.

| Endpoint                            | Purpose                       |
| ----------------------------------- | ----------------------------- |
| `/api/v1/query`                     | Instant query                 |
| `/api/v1/query_range`               | Range query                   |
| `/api/v1/label/<label_name>/values` | Query label values            |
| `/api/v1/labels`                    | Get label names               |
| `/api/v1/series`                    | Find series by label matchers |

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

These Prometheus endpoints are not available on the Coralogix Metrics API.

| Endpoint                   | Purpose                                    |
| -------------------------- | ------------------------------------------ |
| `/api/v1/alerts`           | List active alerts                         |
| `/api/v1/query_exemplars`  | Query exemplars for a series over time     |
| `/api/v1/rules`            | List alerting and recording rules          |
| `/api/v1/targets/metadata` | Return metadata about metrics from targets |

## Related resources[​](#related-resources "Direct link to Related resources")

[API keys](https://coralogix.com/docs/user-guides/account-management/api-keys/api-keys.md)[Coralogix domain](https://coralogix.com/docs/user-guides/account-management/account-settings/coralogix-domain.md)[Prometheus HTTP API](https://prometheus.io/docs/prometheus/latest/querying/api/)
