2020-05-07 17:09:26 -04:00
---
stage: Monitor
2021-03-18 11:09:04 -04:00
group: Monitor
2020-11-26 01:09:20 -05:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-05-07 17:09:26 -04:00
---
2021-01-28 01:08:59 -05:00
# Prometheus integration **(FREE)**
2017-03-15 00:04:00 -04:00
2020-04-06 08:10:44 -04:00
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/8935) in GitLab 9.0.
2017-03-15 00:04:00 -04:00
2021-02-01 19:09:14 -05:00
GitLab offers powerful integration with [Prometheus ](https://prometheus.io ) for
monitoring key metrics of your apps, directly in GitLab.
2018-02-20 01:48:06 -05:00
Metrics for each environment are retrieved from Prometheus, and then displayed
2021-02-01 19:09:14 -05:00
in the GitLab interface.
2017-03-15 05:37:07 -04:00
2018-02-20 01:48:06 -05:00
![Environment Dashboard ](img/prometheus_dashboard.png )
2017-03-15 00:04:00 -04:00
2018-09-19 12:03:00 -04:00
There are two ways to set up Prometheus integration, depending on where your apps are running:
2018-11-13 01:07:16 -05:00
2021-06-10 17:10:02 -04:00
- For deployments on Kubernetes, GitLab can be [integrated with an in-cluster Prometheus ](#prometheus-cluster-integration )
2021-02-01 19:09:14 -05:00
- For other deployment targets, [specify the Prometheus server ](#manual-configuration-of-prometheus ).
2017-03-15 00:04:00 -04:00
2021-02-01 19:09:14 -05:00
Once enabled, GitLab detects metrics from known services in the
[metric library ](prometheus_library/index.md ). You can also
[add your own metrics ](../../../operations/metrics/index.md#adding-custom-metrics ) and create
2020-07-16 14:09:35 -04:00
[custom dashboards ](../../../operations/metrics/dashboards/index.md ).
2018-03-18 20:22:49 -04:00
## Enabling Prometheus Integration
2021-06-10 17:10:02 -04:00
### Prometheus cluster integration
2019-07-08 19:14:29 -04:00
2021-06-10 17:10:02 -04:00
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55244) in GitLab 13.11.
> - [Replaced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/62725) the Prometheus cluster applications in GitLab 14.0.
2017-03-15 00:04:00 -04:00
2021-06-10 17:10:02 -04:00
GitLab can query an in-cluster Prometheus for your metrics.
See [Prometheus cluster integration ](../../clusters/integrations.md#prometheus-cluster-integration ) for details.
2020-10-22 17:10:39 -04:00
2018-03-18 20:22:49 -04:00
### Manual configuration of Prometheus
2017-03-15 00:04:00 -04:00
2018-03-18 20:22:49 -04:00
#### Requirements
2017-03-15 00:04:00 -04:00
2018-02-20 01:48:06 -05:00
Integration with Prometheus requires the following:
2017-03-15 00:04:00 -04:00
2018-02-20 01:48:06 -05:00
1. GitLab 9.0 or higher
2018-11-20 09:01:13 -05:00
1. Prometheus must be configured to collect one of the [supported metrics ](prometheus_library/index.md )
2018-02-20 01:48:06 -05:00
1. Each metric must be have a label to indicate the environment
1. GitLab must have network connectivity to the Prometheus server
2017-03-15 05:37:07 -04:00
2018-03-18 20:22:49 -04:00
#### Getting started
2017-03-15 05:37:07 -04:00
2020-04-30 11:09:46 -04:00
Installing and configuring Prometheus to monitor applications is fairly straightforward.
2017-03-15 05:37:07 -04:00
2019-07-08 19:14:29 -04:00
1. [Install Prometheus ](https://prometheus.io/docs/prometheus/latest/installation/ )
2018-11-20 09:01:13 -05:00
1. Set up one of the [supported monitoring targets ](prometheus_library/index.md )
2021-02-01 19:09:14 -05:00
1. Configure the Prometheus server to
[collect their metrics ](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config )
2017-03-15 00:04:00 -04:00
2018-03-18 20:22:49 -04:00
#### Configuration in GitLab
2017-03-15 00:04:00 -04:00
2021-02-01 19:09:14 -05:00
The actual configuration of Prometheus integration in GitLab
2020-11-18 10:09:08 -05:00
requires the domain name or IP address of the Prometheus server you'd like
2020-07-15 14:09:09 -04:00
to integrate with. If the Prometheus resource is secured with Google's Identity-Aware Proxy (IAP),
2021-02-01 19:09:14 -05:00
you can pass information like Client ID and Service Account credentials.
GitLab can use these to access the resource. More information about authentication from a
2020-07-15 14:09:09 -04:00
service account can be found at Google's documentation for
[Authenticating from a service account ](https://cloud.google.com/iap/docs/authentication-howto#authenticating_from_a_service_account ).
1. Navigate to the [Integrations page ](overview.md#accessing-integrations ) at
2020-07-28 23:09:51 -04:00
**Settings > Integrations** .
2020-03-03 07:08:08 -05:00
1. Click the **Prometheus** service.
2020-07-15 14:09:09 -04:00
1. For **API URL** , provide the domain name or IP address of your server, such as
`http://prometheus.example.com/` or `http://192.0.2.1/` .
1. (Optional) In **Google IAP Audience Client ID** , provide the Client ID of the
Prometheus OAuth Client secured with Google IAP.
1. (Optional) In **Google IAP Service Account JSON** , provide the contents of the
Service Account credentials file that is authorized to access the Prometheus resource.
2021-02-11 10:09:11 -05:00
The JSON key `token_credential_uri` is discarded to prevent
2021-10-18 02:12:21 -04:00
[Server-side Request Forgery (SSRF) ](https://www.hackerone.com/application-security/how-server-side-request-forgery-ssrf ).
2020-03-03 07:08:08 -05:00
1. Click **Save changes** .
2017-03-15 00:04:00 -04:00
2020-07-15 14:09:09 -04:00
![Configure Prometheus Service ](img/prometheus_manual_configuration_v13_2.png )
2017-03-15 00:04:00 -04:00
2020-03-03 07:08:08 -05:00
#### Thanos configuration in GitLab
You can configure [Thanos ](https://thanos.io/ ) as a drop-in replacement for Prometheus
2021-02-01 19:09:14 -05:00
with GitLab. Use the domain name or IP address of the Thanos server you'd like
2020-03-03 07:08:08 -05:00
to integrate with.
2020-03-30 17:08:01 -04:00
1. Navigate to the [Integrations page ](overview.md#accessing-integrations ).
2020-03-03 07:08:08 -05:00
1. Click the **Prometheus** service.
2021-02-01 19:09:14 -05:00
1. Provide the domain name or IP address of your server, for example
`http://thanos.example.com/` or `http://192.0.2.1/` .
2020-03-03 07:08:08 -05:00
1. Click **Save changes** .
2020-04-22 17:10:00 -04:00
### Precedence with multiple Prometheus configurations
Although you can enable both a [manual configuration ](#manual-configuration-of-prometheus )
2021-06-10 17:10:02 -04:00
and [cluster integration ](#prometheus-cluster-integration ) of Prometheus, you
2020-11-18 10:09:08 -05:00
can use only one:
2020-04-22 17:10:00 -04:00
- If you have enabled a
[Prometheus manual configuration ](#manual-configuration-of-prometheus )
2021-06-10 17:10:02 -04:00
and a [Prometheus cluster integration ](#prometheus-cluster-integration ),
2020-04-22 17:10:00 -04:00
the manual configuration takes precedence and is used to run queries from
2020-07-20 14:09:27 -04:00
[custom dashboards ](../../../operations/metrics/dashboards/index.md ) and
[custom metrics ](../../../operations/metrics/index.md#adding-custom-metrics ).
2020-04-22 17:10:00 -04:00
- If you have managed Prometheus applications installed on Kubernetes clusters
at **different** levels (project, group, instance), the order of precedence is described in
[Cluster precedence ](../../instance/clusters/index.md#cluster-precedence ).
- If you have managed Prometheus applications installed on multiple Kubernetes
clusters at the **same** level, the Prometheus application of a cluster with a
2021-08-11 05:10:00 -04:00
matching [environment scope ](../../../ci/environments/index.md#scope-environments-with-specs ) is used.
2020-04-22 17:10:00 -04:00
2017-05-21 13:49:23 -04:00
## Determining the performance impact of a merge
2017-05-09 00:15:34 -04:00
2020-04-06 08:10:44 -04:00
> - [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/10408) in GitLab 9.2.
2020-05-21 23:08:28 -04:00
> - GitLab 9.3 added the [numeric comparison](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/27439) of the 30 minute averages.
2017-05-09 00:15:34 -04:00
2021-02-01 19:09:14 -05:00
Developers can view the performance impact of their changes in the merge
2020-10-13 20:08:48 -04:00
request workflow. This feature requires [Kubernetes ](prometheus_library/kubernetes.md ) metrics.
2019-08-28 01:57:25 -04:00
When a source branch has been deployed to an environment, a sparkline and
2020-11-18 10:09:08 -05:00
numeric comparison of the average memory consumption displays. On the
2019-08-28 01:57:25 -04:00
sparkline, a dot indicates when the current changes were deployed, with up to 30 minutes of
performance data displayed before and after. The comparison shows the difference
between the 30 minute average before and after the deployment. This information
is updated after each commit has been deployed.
2017-05-09 00:15:34 -04:00
2020-11-18 10:09:08 -05:00
Once merged and the target branch has been redeployed, the metrics switches
2017-05-21 13:49:23 -04:00
to show the new environments this revision has been deployed to.
2017-05-19 03:02:46 -04:00
2020-11-18 10:09:08 -05:00
Performance data is available for the duration it is persisted on the
2017-05-21 13:49:23 -04:00
Prometheus server.
2017-05-19 03:02:46 -04:00
![Merge Request with Performance Impact ](img/merge_request_performance.png )