2017-03-15 04:04:00 +00:00
# Prometheus integration
2017-03-16 18:12:54 +00:00
> [Introduced][ce-8935] in GitLab 9.0.
2017-03-15 04:04:00 +00:00
2018-03-19 00:22:49 +00:00
GitLab offers powerful integration with [Prometheus] for monitoring key metrics of your apps, directly within GitLab.
2018-02-20 06:48:06 +00:00
Metrics for each environment are retrieved from Prometheus, and then displayed
2017-03-15 09:37:07 +00:00
within the GitLab interface.
2018-02-20 06:48:06 +00:00
![Environment Dashboard ](img/prometheus_dashboard.png )
2017-03-15 04:04:00 +00:00
2018-09-19 16:03:00 +00:00
There are two ways to set up Prometheus integration, depending on where your apps are running:
2018-11-13 06:07:16 +00:00
- 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-03-15 04:04:00 +00:00
2018-03-19 00:22:49 +00:00
Once enabled, GitLab will automatically detect metrics from known services in the [metric library ](#monitoring-ci-cd-environments ).
## Enabling Prometheus Integration
### Managed Prometheus on Kubernetes
2018-02-20 20:14:22 +00:00
> **Note**: [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/28916) in GitLab 10.5
2017-03-15 04:04:00 +00:00
2018-02-20 07:08:57 +00:00
GitLab can seamlessly deploy and manage Prometheus on a [connected Kubernetes cluster ](../clusters/index.md ), making monitoring of your apps easy.
2017-03-15 04:04:00 +00:00
2018-03-19 00:22:49 +00:00
#### Requirements
2017-03-15 04:04:00 +00:00
2018-11-13 06:07:16 +00:00
- A [connected Kubernetes cluster ](../clusters/index.md )
- Helm Tiller [installed by GitLab ](../clusters/index.md#installing-applications )
2017-03-15 04:04:00 +00:00
2018-03-19 00:22:49 +00:00
#### Getting started
2017-03-15 04:04:00 +00:00
2018-02-20 06:48:06 +00:00
Once you have a connected Kubernetes cluster with Helm installed, deploying a managed Prometheus is as easy as a single click.
2017-03-15 04:04:00 +00:00
2019-01-01 04:37:27 +00:00
1. Go to the **Operations > Kubernetes** page to view your connected clusters
2018-02-20 06:48:06 +00:00
1. Select the cluster you would like to deploy Prometheus to
1. Click the **Install** button to deploy Prometheus to the cluster
2017-03-15 04:04:00 +00:00
2018-02-20 06:48:06 +00:00
![Managed Prometheus Deploy ](img/prometheus_deploy.png )
2017-03-15 04:04:00 +00:00
2018-03-19 00:22:49 +00:00
#### About managed Prometheus deployments
2017-03-15 04:04:00 +00:00
2018-02-20 06:48:06 +00:00
Prometheus is deployed into the `gitlab-managed-apps` namespace, using the [official Helm chart ](https://github.com/kubernetes/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-03-15 04:04:00 +00:00
2018-02-20 07:08:57 +00:00
The Prometheus server will [automatically detect and monitor ](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#%3Ckubernetes_sd_config%3E ) 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/ ):
2018-12-12 06:08:57 +00:00
2018-11-13 06:07:16 +00:00
- `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-03-15 04:04:00 +00:00
2018-02-20 07:08:57 +00:00
CPU and Memory consumption is monitored, but requires [naming conventions ](prometheus_library/kubernetes.html#specifying-the-environment ) in order to determine the environment. If you are using [Auto DevOps ](../../../topics/autodevops/ ), this is handled automatically.
2017-03-15 04:04:00 +00:00
2018-02-20 06:56:40 +00:00
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-03-15 04:04:00 +00:00
2018-03-19 00:22:49 +00:00
### Manual configuration of Prometheus
2017-03-15 04:04:00 +00:00
2018-03-19 00:22:49 +00:00
#### Requirements
2017-03-15 04:04:00 +00:00
2018-02-20 06:48:06 +00:00
Integration with Prometheus requires the following:
2017-03-15 04:04:00 +00:00
2018-02-20 06:48:06 +00:00
1. GitLab 9.0 or higher
2018-11-20 14:01:13 +00:00
1. Prometheus must be configured to collect one of the [supported metrics ](prometheus_library/index.md )
2018-02-20 06:48:06 +00: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 09:37:07 +00:00
2018-03-19 00:22:49 +00:00
#### Getting started
2017-03-15 09:37:07 +00:00
2018-02-20 06:48:06 +00:00
Installing and configuring Prometheus to monitor applications is fairly straight forward.
2017-03-15 09:37:07 +00:00
2018-02-20 06:48:06 +00:00
1. [Install Prometheus ](https://prometheus.io/docs/introduction/install/ )
2018-11-20 14:01:13 +00:00
1. Set up one of the [supported monitoring targets ](prometheus_library/index.md )
2018-02-20 06:48:06 +00:00
1. Configure the Prometheus server to [collect their metrics ](https://prometheus.io/docs/operating/configuration/#scrape_config )
2017-03-15 04:04:00 +00:00
2018-03-19 00:22:49 +00:00
#### Configuration in GitLab
2017-03-15 04:04:00 +00:00
2017-03-15 09:37:07 +00:00
The actual configuration of Prometheus integration within GitLab is very simple.
All you will need is the DNS or IP address of the Prometheus server you'd like
to integrate with.
2017-03-15 04:04:00 +00:00
2017-03-15 09:37:07 +00:00
1. Navigate to the [Integrations page ](project_services.md#accessing-the-project-services )
1. Click the **Prometheus** service
1. Provide the base URL of the your server, for example `http://prometheus.example.com/` .
The **Test Settings** button can be used to confirm connectivity from GitLab
to the Prometheus server.
2017-03-15 04:04:00 +00:00
2017-03-15 09:37:07 +00:00
![Configure Prometheus Service ](img/prometheus_service_configuration.png )
2017-03-15 04:04:00 +00:00
2017-03-15 17:02:44 +00:00
## Monitoring CI/CD Environments
2017-03-16 18:12:54 +00:00
Once configured, GitLab will attempt to retrieve performance metrics for any
2017-05-21 17:49:23 +00:00
environment which has had a successful deployment.
2017-03-15 17:02:44 +00:00
2019-02-12 12:45:20 +00:00
GitLab will automatically scan the Prometheus server for metrics from known servers like Kubernetes and NGINX, and attempt to identify individual environment. The supported metrics and scan process is detailed in our [Prometheus Metrics Library documentation ](prometheus_library/index.md ).
2017-08-14 16:23:32 +00:00
2018-03-19 00:22:49 +00:00
You can view the performance dashboard for an environment by [clicking on the monitoring button ](../../../ci/environments.md#monitoring-environments ).
2017-03-15 17:02:44 +00:00
2017-05-21 17:49:23 +00:00
## Determining the performance impact of a merge
2017-05-09 04:15:34 +00:00
2017-05-19 07:02:46 +00:00
> [Introduced][ce-10408] in GitLab 9.2.
2017-06-19 11:19:36 +00:00
> GitLab 9.3 added the [numeric comparison](https://gitlab.com/gitlab-org/gitlab-ce/issues/27439) of the 30 minute averages.
2017-07-17 02:09:56 +00:00
> Requires [Kubernetes](prometheus_library/kubernetes.md) metrics
2017-05-09 04:15:34 +00:00
2018-03-19 00:22:49 +00:00
Developers can view the performance impact of their changes within the merge
2017-06-19 11:19:36 +00:00
request workflow. 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
2017-05-21 17:49:23 +00:00
indicates when the current changes were deployed, with up to 30 minutes of
2017-06-19 11:19:36 +00:00
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
2017-05-21 17:49:23 +00:00
each commit has been deployed.
2017-05-09 04:15:34 +00:00
2017-06-19 11:19:36 +00:00
Once merged and the target branch has been redeployed, the metrics will switch
2017-05-21 17:49:23 +00:00
to show the new environments this revision has been deployed to.
2017-05-19 07:02:46 +00:00
2017-05-21 17:49:23 +00:00
Performance data will be available for the duration it is persisted on the
Prometheus server.
2017-05-19 07:02:46 +00:00
![Merge Request with Performance Impact ](img/merge_request_performance.png )
2017-05-09 04:15:34 +00:00
2017-03-15 04:04:00 +00:00
## Troubleshooting
2018-03-19 00:22:49 +00:00
If the "No data found" screen continues to appear, it could be due to:
2017-03-16 18:12:54 +00:00
2017-03-15 17:02:44 +00:00
- No successful deployments have occurred to this environment.
2017-03-16 18:12:54 +00:00
- Prometheus does not have performance data for this environment, or the metrics
are not labeled correctly. To test this, connect to the Prometheus server and
2019-03-05 12:55:30 +00:00
[run a query ](prometheus_library/kubernetes.html#metrics-supported ), replacing `$CI_ENVIRONMENT_SLUG`
2017-03-16 18:12:54 +00:00
with the name of your environment.
2017-03-15 17:02:44 +00:00
2017-03-15 09:37:07 +00:00
[autodeploy]: ../../../ci/autodeploy/index.md
2017-03-15 04:04:00 +00:00
[kubernetes]: https://kubernetes.io
2017-05-21 17:49:23 +00:00
[kube]: ./kubernetes.md
2017-03-15 04:04:00 +00:00
[prometheus-k8s-sd]: https://prometheus.io/docs/operating/configuration/#< kubernetes_sd_config >
2017-03-15 09:37:07 +00:00
[prometheus]: https://prometheus.io
[gitlab-prometheus-k8s-monitor]: ../../../administration/monitoring/prometheus/index.md#configuring-prometheus-to-monitor-kubernetes
2017-03-15 04:04:00 +00:00
[prometheus-docker-image]: https://hub.docker.com/r/prom/prometheus/
[prometheus-yml]:samples/prometheus.yml
[gitlab.com-ip-range]: https://gitlab.com/gitlab-com/infrastructure/issues/434
2019-01-30 10:20:50 +00:00
[ci-environment-slug]: ../../../ci/variables/#predefined-environment-variables
2017-03-15 09:37:07 +00:00
[ce-8935]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8935
2017-05-09 04:15:34 +00:00
[ce-10408]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10408
2017-03-15 09:37:07 +00:00
[promgldocs]: ../../../administration/monitoring/prometheus/index.md