GitLab Prometheus

Notes:

  • 普罗米修斯and the various exporters listed in this page are bundled in the Omnibus GitLab package. Check each exporter's documentation for the timeline they got added. For installations from source you will have to install them yourself. Over subsequent releases additional GitLab metrics will be captured.
  • 普罗米修斯services are on by default with GitLab 9.0.
  • 普罗米修斯and its exporters do not authenticate users, and will be available to anyone who can access them.

普罗米修斯is a powerful time-series monitoring service, providing a flexible platform for monitoring GitLab and other software products. GitLab provides out of the box monitoring with Prometheus, providing easy access to high quality time-series monitoring of GitLab services.

Overview

普罗米修斯的作品periodically connecting to data sources and collecting their performance metrics via thevarious exporters.To view and work with the monitoring data, you can eitherconnect directly to Prometheusor utilize a dashboard tool likeGrafana

Configuring Prometheus

Note:For installations from source you'll have to install and configure it yourself.

普罗米修斯and it's exporters are on by default, starting with GitLab 9.0. Prometheus will run as thegitlab-prometheususer and listen onhttp://localhost:9090.将自动设置为每个出口国a monitoring target for Prometheus, unless individually disabled.

To disable Prometheus and all of its exporters, as well as any added in the future:

  1. 编辑/etc/gitlab/gitlab.rb
  2. Add or find and uncomment the following line, making sure it's set tofalse:

    prometheus_monitoring['enable']=false
  3. Save the file andreconfigure GitLabfor the changes to take effect

Changing the port Prometheus listens on

Note:The following change was added inGitLab Omnibus 8.17.Although possible, it's not recommended to change the default address and port Prometheus listens on as this might affect or conflict with other services running on the GitLab server. Proceed at your own risk.

To change the address/port that Prometheus listens on:

  1. 编辑/etc/gitlab/gitlab.rb
  2. Add or find and uncomment the following line:

    prometheus['listen_address']='localhost:9090'

    Replacelocalhost:9090with the address/port you want Prometheus to listen on. If you would like to allow access to Prometheus to hosts other thanlocalhost, leave out the host, or use0.0.0.0to allow public access:

    prometheus['listen_address']=':9090'# orprometheus['listen_address']='0.0.0.0:9090'
  3. Save the file andreconfigure GitLabfor the changes to take effect

Viewing performance metrics

You can visithttp://localhost:9090for the dashboard that Prometheus offers by default.

Note:If SSL has been enabled on your GitLab instance, you may not be able to access Prometheus on the same browser as GitLab due toHSTS.We plan toprovide access via GitLab, but in the interim there are some workarounds: using a separate browser for Prometheus, resetting HSTS, or havingNginx proxy it

The performance data collected by Prometheus can be viewed directly in the Prometheus console or through a compatible dashboard tool. The Prometheus interface provides aflexible query languageto work with the collected data where you can visualize their output. For a more fully featured dashboard, Grafana can be used and hasofficial support for Prometheus

Sample Prometheus queries:

  • % Memory used:(1 - ((node_memory_MemFree + node_memory_Cached) / node_memory_MemTotal)) * 100
  • % CPU load:1 - rate(node_cpu{mode="idle"}[5m])
  • Data transmitted:irate(node_network_transmit_bytes[5m])
  • Data received:irate(node_network_receive_bytes[5m])

Configuring Prometheus to monitor Kubernetes

Introduced in GitLab 9.0. Pod monitoring introduced in GitLab 9.4.

If your GitLab server is running within Kubernetes, Prometheus will collect metrics from the Nodes and带注释的豆荚in the cluster, including performance data on each container. This is particularly helpful if your CI/CD environments run in the same cluster, as you can use the [Prometheus project integration][] to monitor them.

To disable the monitoring of Kubernetes:

  1. 编辑/etc/gitlab/gitlab.rb
  2. Add or find and uncomment the following line and set it tofalse:

    prometheus['monitor_kubernetes']=false
  3. Save the file andreconfigure GitLabfor the changes to take effect

GitLab Prometheus metrics

Introduced as an experimental feature in GitLab 9.3.

GitLab monitors its own internal service metrics, and makes them available at the/-/metricsendpoint. Unlike other exporters, this endpoint requires authentication as it is available on the same URL and port as user traffic.

➔ Read more about the GitLab Metrics.

普罗米修斯exporters

There are a number of libraries and servers which help in exporting existing metrics from third-party systems as Prometheus metrics. This is useful for cases where it is not feasible to instrument a given system with Prometheus metrics directly (for example, HAProxy or Linux system stats). You can read more in the普罗米修斯exporters and integrations upstream documentation

While you can use any exporter you like with your GitLab installation, the following ones documented here are bundled in the Omnibus GitLab packages making it easy to configure and use.

Node exporter

The node exporter allows you to measure various machine resources such as memory, disk and CPU utilization.

➔ Read more about the node exporter.

Redis exporter

The Redis exporter allows you to measure various Redis metrics.

➔ Read more about the Redis exporter.

Postgres exporter

The Postgres exporter allows you to measure various PostgreSQL metrics.

➔ Read more about the Postgres exporter.

GitLab monitor exporter

The GitLab monitor exporter allows you to measure various GitLab metrics, pulled from Redis and the database.

➔ Read more about the GitLab monitor exporter.

Baidu
map