2020-05-24 23:13:21 +05:30
---
stage: Monitor
group: APM
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/#designated-technical-writers
---
2017-08-17 22:00:37 +05:30
# Prometheus integration
2020-04-22 19:07:51 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/8935) in GitLab 9.0.
2017-08-17 22:00:37 +05:30
2020-04-22 19:07:51 +05:30
GitLab offers powerful integration with [Prometheus ](https://prometheus.io ) for monitoring key metrics of your apps, directly within GitLab.
2018-03-17 18:26:18 +05:30
Metrics for each environment are retrieved from Prometheus, and then displayed
2017-08-17 22:00:37 +05:30
within the GitLab interface.
2018-03-17 18:26:18 +05:30
![Environment Dashboard ](img/prometheus_dashboard.png )
2017-08-17 22:00:37 +05:30
2018-12-05 23:21:45 +05:30
There are two ways to set up Prometheus integration, depending on where your apps are running:
2019-03-02 22:35:43 +05:30
- For deployments on Kubernetes, GitLab can automatically [deploy and manage Prometheus ](#managed-prometheus-on-kubernetes ).
- For other deployment targets, simply [specify the Prometheus server ](#manual-configuration-of-prometheus ).
2017-08-17 22:00:37 +05:30
2020-07-28 23:09:34 +05:30
Once enabled, GitLab will automatically detect 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
[custom dashboards ](../../../operations/metrics/dashboards/index.md ).
2018-03-27 19:54:05 +05:30
## Enabling Prometheus Integration
### Managed Prometheus on Kubernetes
2019-09-30 21:07:59 +05:30
2020-06-23 00:09:42 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/28916) in GitLab 10.5.
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
GitLab can seamlessly deploy and manage Prometheus on a [connected Kubernetes cluster ](../clusters/index.md ), making monitoring of your apps easy.
2017-08-17 22:00:37 +05:30
2018-03-27 19:54:05 +05:30
#### Requirements
2017-09-10 17:25:29 +05:30
2019-03-02 22:35:43 +05:30
- A [connected Kubernetes cluster ](../clusters/index.md )
2017-08-17 22:00:37 +05:30
2018-03-27 19:54:05 +05:30
#### Getting started
2017-08-17 22:00:37 +05:30
2020-07-28 23:09:34 +05:30
Once you have a connected Kubernetes cluster, deploying a managed Prometheus is as easy as a single click.
2017-08-17 22:00:37 +05:30
2019-02-15 15:39:39 +05:30
1. Go to the **Operations > Kubernetes** page to view your connected clusters
2018-03-17 18:26:18 +05:30
1. Select the cluster you would like to deploy Prometheus to
1. Click the **Install** button to deploy Prometheus to the cluster
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
![Managed Prometheus Deploy ](img/prometheus_deploy.png )
2017-08-17 22:00:37 +05:30
2018-03-27 19:54:05 +05:30
#### About managed Prometheus deployments
2017-08-17 22:00:37 +05:30
2019-09-30 21:07:59 +05:30
Prometheus is deployed into the `gitlab-managed-apps` namespace, using the [official Helm chart ](https://github.com/helm/charts/tree/master/stable/prometheus ). Prometheus is only accessible within the cluster, with GitLab communicating through the [Kubernetes API ](https://kubernetes.io/docs/concepts/overview/kubernetes-api/ ).
2017-08-17 22:00:37 +05:30
2019-09-30 21:07:59 +05:30
The Prometheus server will [automatically detect and monitor ](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#kubernetes_sd_config ) nodes, pods, and endpoints. To configure a resource to be monitored by Prometheus, simply set the following [Kubernetes annotations ](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ ):
2019-02-15 15:39:39 +05:30
2019-03-02 22:35:43 +05:30
- `prometheus.io/scrape` to `true` to enable monitoring of the resource.
- `prometheus.io/port` to define the port of the metrics endpoint.
- `prometheus.io/path` to define the path of the metrics endpoint. Defaults to `/metrics` .
2017-08-17 22:00:37 +05:30
2020-04-22 19:07:51 +05:30
CPU and Memory consumption is monitored, but requires [naming conventions ](prometheus_library/kubernetes.md#specifying-the-environment ) in order to determine the environment. If you are using [Auto DevOps ](../../../topics/autodevops/index.md ), this is handled automatically.
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
The [NGINX Ingress ](../clusters/index.md#installing-applications ) that is deployed by GitLab to clusters, is automatically annotated for monitoring providing key response metrics: latency, throughput, and error rates.
2017-08-17 22:00:37 +05:30
2018-03-27 19:54:05 +05:30
### Manual configuration of Prometheus
2017-08-17 22:00:37 +05:30
2018-03-27 19:54:05 +05:30
#### Requirements
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
Integration with Prometheus requires the following:
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
1. GitLab 9.0 or higher
2019-02-15 15:39:39 +05:30
1. Prometheus must be configured to collect one of the [supported metrics ](prometheus_library/index.md )
2018-03-17 18:26:18 +05:30
1. Each metric must be have a label to indicate the environment
1. GitLab must have network connectivity to the Prometheus server
2017-08-17 22:00:37 +05:30
2018-03-27 19:54:05 +05:30
#### Getting started
2017-08-17 22:00:37 +05:30
2020-05-24 23:13:21 +05:30
Installing and configuring Prometheus to monitor applications is fairly straightforward.
2017-08-17 22:00:37 +05:30
2019-09-30 21:07:59 +05:30
1. [Install Prometheus ](https://prometheus.io/docs/prometheus/latest/installation/ )
2019-02-15 15:39:39 +05:30
1. Set up one of the [supported monitoring targets ](prometheus_library/index.md )
2019-09-30 21:07:59 +05:30
1. Configure the Prometheus server to [collect their metrics ](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config )
2017-08-17 22:00:37 +05:30
2018-03-27 19:54:05 +05:30
#### Configuration in GitLab
2017-08-17 22:00:37 +05:30
The actual configuration of Prometheus integration within GitLab is very simple.
2020-04-08 14:13:33 +05:30
All you will need is the domain name or IP address of the Prometheus server you'd like
2020-07-28 23:09:34 +05:30
to integrate with. If the Prometheus resource is secured with Google's Identity-Aware Proxy (IAP),
additional information like Client ID and Service Account credentials can be passed which
GitLab can use to access the resource. More information about authentication from a
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-10-24 23:57:45 +05:30
**Settings > Integrations** .
2020-04-08 14:13:33 +05:30
1. Click the **Prometheus** service.
2020-07-28 23:09:34 +05:30
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.
2020-04-08 14:13:33 +05:30
1. Click **Save changes** .
2017-08-17 22:00:37 +05:30
2020-07-28 23:09:34 +05:30
![Configure Prometheus Service ](img/prometheus_manual_configuration_v13_2.png )
2017-08-17 22:00:37 +05:30
2020-04-08 14:13:33 +05:30
#### Thanos configuration in GitLab
You can configure [Thanos ](https://thanos.io/ ) as a drop-in replacement for Prometheus
with GitLab. You will need the domain name or IP address of the Thanos server you'd like
to integrate with.
2020-04-22 19:07:51 +05:30
1. Navigate to the [Integrations page ](overview.md#accessing-integrations ).
2020-04-08 14:13:33 +05:30
1. Click the **Prometheus** service.
1. Provide the domain name or IP address of your server, for example `http://thanos.example.com/` or `http://192.0.2.1/` .
1. Click **Save changes** .
2020-05-24 23:13:21 +05:30
### Precedence with multiple Prometheus configurations
Although you can enable both a [manual configuration ](#manual-configuration-of-prometheus )
and [auto configuration ](#managed-prometheus-on-kubernetes ) of Prometheus, only
one of them will be used:
- If you have enabled a
[Prometheus manual configuration ](#manual-configuration-of-prometheus )
and a [managed Prometheus on Kubernetes ](#managed-prometheus-on-kubernetes ),
the manual configuration takes precedence and is used to run queries from
2020-10-24 23:57:45 +05:30
[custom dashboards ](../../../operations/metrics/dashboards/index.md ) and
[custom metrics ](../../../operations/metrics/index.md#adding-custom-metrics ).
2020-05-24 23:13:21 +05:30
- 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
matching [environment scope ](../../../ci/environments/index.md#scoping-environments-with-specs ) is used.
2017-08-17 22:00:37 +05:30
## Determining the performance impact of a merge
2020-04-22 19:07:51 +05:30
> - [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/10408) in GitLab 9.2.
2020-06-23 00:09:42 +05:30
> - GitLab 9.3 added the [numeric comparison](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/27439) of the 30 minute averages.
2017-08-17 22:00:37 +05:30
2018-03-27 19:54:05 +05:30
Developers can view the performance impact of their changes within the merge
2019-12-04 20:38:33 +05:30
request workflow.
NOTE: **Note:**
Requires [Kubernetes ](prometheus_library/kubernetes.md ) metrics.
When a source branch has been deployed to an environment, a sparkline and
numeric comparison of the average memory consumption will appear. On the
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-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
Once merged and the target branch has been redeployed, the metrics will switch
2017-08-17 22:00:37 +05:30
to show the new environments this revision has been deployed to.
Performance data will be available for the duration it is persisted on the
Prometheus server.
![Merge Request with Performance Impact ](img/merge_request_performance.png )