# Import metrics from Prometheus

## Create a Prometheus metric data source

#### In ilert

1. Go to **Incident comms** --> **Metric data sources** and click on **Create metric data source.**

   <figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2FsDXTVZ8jYXOJqJJlZsSY%2FScreenshot%202022-12-19%20at%2016.14.41.png?alt=media&#x26;token=a27cdf97-6e04-48c1-84ae-c4dc4e9c927a" alt=""><figcaption></figcaption></figure>
2. Give the metrics data source a name (e.g. Prometheus).
3. Select **Prometheus** in **Type** dropdown list.
4. Type in your Prometheus URL. For ex.: <https://prometheus.example.org>.
5. Choose your **Authentication** method.

{% hint style="info" %}
**Warning:** We recommend that you secure your Prometheus instance by using an authentication method.
{% endhint %}

**Basic auth:**

1. Enter your login credentials for Prometheus, e.g. username and password and click on **Create metric data source**.

**Custom header:**

1. Enter a custom header name, for ex. "Cookie", if you wish to authenticate via cookie header.
2. Paste your custom header value for the header name. In case of "Cookie" enter the cookie's value here and click on **Create metric data source**.

<figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2F83ZQajYF3bFNGCWRZzPz%2FScreenshot%202022-12-19%20at%2015.53.25.png?alt=media&#x26;token=d16a1f25-3a86-417e-adec-b931731a4c77" alt=""><figcaption></figcaption></figure>

## Create a metric

#### In Prometheus

1. Go to **Graph** --> Type in a **query** --> Test your result with **Execute.**

   <figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2FF2w8w6icJc5jEgeKMJ5l%2FScreenshot%202022-12-19%20at%2015.03.25.png?alt=media&#x26;token=adc2ed99-6bda-459e-bbbd-62bf15da311d" alt=""><figcaption></figcaption></figure>
2. Select a query from which you want to import the data into ilert. Copy the query, you will need it later.

**In ilert**

1. Go to **Status pages** (or **Incident comms**) --> **Metrics** and click on **Create metric.**

   <figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2FzB8Vo43zcvc4u3aqKPrI%2FScreenshot%202022-12-19%20at%2016.20.23.png?alt=media&#x26;token=fd452cfc-aa51-48a7-b918-e9c7daf095ad" alt=""><figcaption></figcaption></figure>

2. Select the Prometheus metrics data source that you have created above and click on **Next.**

   <figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2FBNXtHx9e9evwO6GZGGoY%2FScreenshot%202022-12-19%20at%2016.08.40.png?alt=media&#x26;token=7479d947-5a01-4603-a220-5bda237ff9e9" alt=""><figcaption></figcaption></figure>

3. On the next screen, enter a metric name, a display unit and paste the metric query from step 2 "In Prometheus" above. Click **Save** to preview your metric data.

   <figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2FZYUJfUdjdXxbFEbFMD6a%2FScreenshot%202022-12-20%20at%2014.07.43.png?alt=media&#x26;token=2be9791c-dd2d-4a85-bd6e-b367e745cd86" alt=""><figcaption></figcaption></figure>

4. Preview your metric. You can make changes to your query and reload the data from Prometheus. Note that once you have created your metric, you will no longer be able to change the metric query.&#x20;

<figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2FeLJmsMdnjOlsYBbWkb2a%2FScreenshot%202022-12-20%20at%2013.51.06.png?alt=media&#x26;token=e2bf44d7-2fd2-46c5-a7b3-97dab7ddbae2" alt=""><figcaption></figcaption></figure>
