debian-mirror-gitlab/doc/user/project/integrations/prometheus.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

131 lines
6.5 KiB
Markdown
Raw Normal View History

2020-05-24 23:13:21 +05:30
---
stage: Monitor
2022-04-04 11:22:00 +05:30
group: Respond
2022-11-25 23:54:43 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
2020-05-24 23:13:21 +05:30
---
2021-03-11 19:13:27 +05:30
# Prometheus integration **(FREE)**
2017-08-17 22:00:37 +05:30
2021-03-11 19:13:27 +05:30
GitLab offers powerful integration with [Prometheus](https://prometheus.io) for
monitoring key metrics of your apps, directly in GitLab.
2018-03-17 18:26:18 +05:30
Metrics for each environment are retrieved from Prometheus, and then displayed
2021-03-11 19:13:27 +05:30
in the GitLab interface.
2017-08-17 22:00:37 +05:30
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
2021-09-04 01:27:46 +05:30
- For deployments on Kubernetes, GitLab can be [integrated with an in-cluster Prometheus](#prometheus-cluster-integration)
2021-03-11 19:13:27 +05:30
- For other deployment targets, [specify the Prometheus server](#manual-configuration-of-prometheus).
2017-08-17 22:00:37 +05:30
2021-03-11 19:13:27 +05:30
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-28 23:09:34 +05:30
[custom dashboards](../../../operations/metrics/dashboards/index.md).
2018-03-27 19:54:05 +05:30
## Enabling Prometheus Integration
2021-09-04 01:27:46 +05:30
### Prometheus cluster integration
2019-09-30 21:07:59 +05:30
2021-09-04 01:27:46 +05:30
> - [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-08-17 22:00:37 +05:30
2021-09-04 01:27:46 +05:30
GitLab can query an in-cluster Prometheus for your metrics.
See [Prometheus cluster integration](../../clusters/integrations.md#prometheus-cluster-integration) for details.
2021-01-29 00:20:46 +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
2022-03-02 08:16:31 +05:30
- Prometheus must be configured to collect one of the [supported metrics](prometheus_library/index.md)
- Each metric must have a label to indicate the environment
- 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)
2021-03-11 19:13:27 +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
2021-03-11 19:13:27 +05:30
The actual configuration of Prometheus integration in GitLab
2021-02-22 17:27:13 +05:30
requires 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),
2021-03-11 19:13:27 +05:30
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-28 23:09:34 +05:30
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).
2022-10-11 01:57:18 +05:30
1. On the top bar, select **Main menu > Projects** and find your project.
2022-06-21 17:19:12 +05:30
1. On the left sidebar, select **Settings > Integrations**.
1. Select **Prometheus**.
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.
2021-02-11 23:33:58 +05:30
The JSON key `token_credential_uri` is discarded to prevent
2021-11-18 22:05:49 +05:30
[Server-side Request Forgery (SSRF)](https://www.hackerone.com/application-security/how-server-side-request-forgery-ssrf).
2022-06-21 17:19:12 +05:30
1. Select **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
2021-03-11 19:13:27 +05:30
with GitLab. Use the domain name or IP address of the Thanos server you'd like
2020-04-08 14:13:33 +05:30
to integrate with.
2022-10-11 01:57:18 +05:30
1. On the top bar, select **Main menu > Projects** and find your project.
2022-06-21 17:19:12 +05:30
1. On the left sidebar, select **Settings > Integrations**.
1. Select **Prometheus**.
2021-03-11 19:13:27 +05:30
1. Provide the domain name or IP address of your server, for example
`http://thanos.example.com/` or `http://192.0.2.1/`.
2022-06-21 17:19:12 +05:30
1. Select **Save changes**.
2020-04-08 14:13:33 +05:30
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)
2021-09-04 01:27:46 +05:30
and [cluster integration](#prometheus-cluster-integration) of Prometheus, you
2021-02-22 17:27:13 +05:30
can use only one:
2020-05-24 23:13:21 +05:30
- If you have enabled a
[Prometheus manual configuration](#manual-configuration-of-prometheus)
2021-09-04 01:27:46 +05:30
and a [Prometheus cluster integration](#prometheus-cluster-integration),
2020-05-24 23:13:21 +05:30
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
2021-10-27 15:23:28 +05:30
matching [environment scope](../../../ci/environments/index.md#scope-environments-with-specs) is used.
2020-05-24 23:13:21 +05:30
2017-08-17 22:00:37 +05:30
## Determining the performance impact of a merge
2021-03-11 19:13:27 +05:30
Developers can view the performance impact of their changes in the merge
2021-01-03 14:25:43 +05:30
request workflow. This feature requires [Kubernetes](prometheus_library/kubernetes.md) metrics.
2019-12-04 20:38:33 +05:30
When a source branch has been deployed to an environment, a sparkline and
2021-02-22 17:27:13 +05:30
numeric comparison of the average memory consumption displays. On the
2019-12-04 20:38:33 +05:30
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
2021-02-22 17:27:13 +05:30
Once merged and the target branch has been redeployed, the metrics switches
2017-08-17 22:00:37 +05:30
to show the new environments this revision has been deployed to.
2021-02-22 17:27:13 +05:30
Performance data is available for the duration it is persisted on the
2017-08-17 22:00:37 +05:30
Prometheus server.
![Merge Request with Performance Impact](img/merge_request_performance.png)