index.md 7,8 КБ
Newer Older
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
1
2
# GitLab Prometheus

Brett Walker's avatar
Brett Walker включено в состав коммита
3
4
5
6
7
8
9
10
> **Notes:**
> - Prometheus 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.
> - Prometheus services are on by default with GitLab 9.0.
> - Prometheus and its exporters do not authenticate users, and will be available
>  to anyone who can access them.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
11
12
13
14
15
16
17
18
19

[Prometheus] 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

Prometheus works by periodically connecting to data sources and collecting their
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
20
21
22
23
performance metrics via the [various exporters](#prometheus-exporters). To view
and work with the monitoring data, you can either
[connect directly to Prometheus](#viewing-performance-metrics) or utilize a
dashboard tool like [Grafana].
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
24
25
26
27

## Configuring Prometheus

>**Note:**
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
28
For installations from source you'll have to install and configure it yourself.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
29

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
30
31
Prometheus and it's exporters are on by default, starting with GitLab 9.0.
Prometheus will run as the `gitlab-prometheus` user and listen on
Ben Bodenmiller's avatar
Ben Bodenmiller включено в состав коммита
32
33
`http://localhost:9090`. By default Prometheus is only accessible from the GitLab server itself.
Each exporter will be automatically set up as a
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
34
monitoring target for Prometheus, unless individually disabled.
35
36

To disable Prometheus and all of its exporters, as well as any added in the future:
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
37
38

1. Edit `/etc/gitlab/gitlab.rb`
Joshua Lambert's avatar
Joshua Lambert включено в состав коммита
39
1. Add or find and uncomment the following line, making sure it's set to `false`:
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
40
41

    ```ruby
Joshua Lambert's avatar
Joshua Lambert включено в состав коммита
42
    prometheus_monitoring['enable'] = false
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
43
44
45
46
47
    ```

1. Save the file and [reconfigure GitLab][reconfigure] for the changes to
   take effect

Ben Bodenmiller's avatar
Ben Bodenmiller включено в состав коммита
48
## Changing the port and address Prometheus listens on
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
49
50
51

>**Note:**
The following change was added in [GitLab Omnibus 8.17][1261]. Although possible,
Ben Bodenmiller's avatar
Ben Bodenmiller включено в состав коммита
52
it's not recommended to change the port Prometheus listens
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
53
54
55
on as this might affect or conflict with other services running on the GitLab
server. Proceed at your own risk.

Ben Bodenmiller's avatar
Ben Bodenmiller включено в состав коммита
56
57
In order to access Prometheus from outside the GitLab server you will need to 
set a FQDN or IP in `prometheus['listen_address']`.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
58
59
60
To change the address/port that Prometheus listens on:

1. Edit `/etc/gitlab/gitlab.rb`
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
61
1. Add or find and uncomment the following line:
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
62
63
64
65
66
67

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

    Replace `localhost:9090` with the address/port you want Prometheus to
Nathan Jones's avatar
Nathan Jones включено в состав коммита
68
69
70
71
72
73
74
75
    listen on. If you would like to allow access to Prometheus to hosts other
    than `localhost`, leave out the host, or use `0.0.0.0` to allow public access:

    ```ruby
    prometheus['listen_address'] = ':9090'
    # or
    prometheus['listen_address'] = '0.0.0.0:9090'
    ```
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
76
77
78
79

1. Save the file and [reconfigure GitLab][reconfigure] for the changes to
   take effect

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
80
## Viewing performance metrics
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
81

82
You can visit `http://localhost:9090` for the dashboard that Prometheus offers by default.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
83
84
85

>**Note:**
If SSL has been enabled on your GitLab instance, you may not be able to access
Ben Bodenmiller's avatar
Ben Bodenmiller включено в состав коммита
86
Prometheus on the same browser as GitLab if using the same FQDN due to [HSTS][hsts]. We plan to
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
87
[provide access via GitLab][multi-user-prometheus], but in the interim there are
Ben Bodenmiller's avatar
Ben Bodenmiller включено в состав коммита
88
some workarounds: using a separate FQDN, using server IP, using a separate browser for Prometheus, resetting HSTS, or
Joshua Lambert's avatar
Joshua Lambert включено в состав коммита
89
having [Nginx proxy it][nginx-custom-config].
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
90
91
92
93
94
95
96
97

The performance data collected by Prometheus can be viewed directly in the
Prometheus console or through a compatible dashboard tool.
The Prometheus interface provides a [flexible query language][prom-query] to work
with the collected data where you can visualize their output.
For a more fully featured dashboard, Grafana can be used and has
[official support for Prometheus][prom-grafana].

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
98
99
Sample Prometheus queries:

Ben Kochie's avatar
Ben Kochie включено в состав коммита
100
101
102
103
- **% Memory available:** `((node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) or ((node_memory_MemFree_bytes + node_memory_Buffers_bytes + node_memory_Cached_bytes) / node_memory_MemTotal_bytes)) * 100`
- **% CPU utilization:** `1 - avg without (mode,cpu) (rate(node_cpu_seconds_total{mode="idle"}[5m]))`
- **Data transmitted:** `rate(node_network_transmit_bytes_total{device!="lo"}[5m])`
- **Data received:** `rate(node_network_receive_bytes_total{device!="lo"}[5m])`
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
104

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
105
106
## Configuring Prometheus to monitor Kubernetes

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
107
> Introduced in GitLab 9.0.
Joshua Lambert's avatar
Joshua Lambert включено в состав коммита
108
> Pod monitoring introduced in GitLab 9.4.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
109

Brett Walker's avatar
Brett Walker включено в состав коммита
110
If your GitLab server is running within Kubernetes, Prometheus will collect metrics from the Nodes and [annotated Pods](https://prometheus.io/docs/operating/configuration/#kubernetes_sd_config) 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.
Joshua Lambert's avatar
Joshua Lambert включено в состав коммита
111

Joshua Lambert's avatar
Joshua Lambert включено в состав коммита
112
To disable the monitoring of Kubernetes:
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
113
114

1. Edit `/etc/gitlab/gitlab.rb`
Joshua Lambert's avatar
Joshua Lambert включено в состав коммита
115
1. Add or find and uncomment the following line and set it to `false`:
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
116
117

    ```ruby
Joshua Lambert's avatar
Joshua Lambert включено в состав коммита
118
    prometheus['monitor_kubernetes'] = false
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
119
120
121
122
123
    ```

1. Save the file and [reconfigure GitLab][reconfigure] for the changes to
   take effect

Joshua Lambert's avatar
Joshua Lambert включено в состав коммита
124
125
## GitLab Prometheus metrics

Joshua Lambert's avatar
Joshua Lambert включено в состав коммита
126
> Introduced in GitLab 9.3.
Joshua Lambert's avatar
Joshua Lambert включено в состав коммита
127
128
129
130
131

GitLab monitors its own internal service metrics, and makes them available at the `/-/metrics` endpoint. 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.](gitlab_metrics.md)

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
132
133
134
135
136
137
## Prometheus 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
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
138
[Prometheus exporters and integrations upstream documentation][prom-exporters].
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
139
140
141
142
143
144
145

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

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
146
The node exporter allows you to measure various machine resources such as
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
147
148
memory, disk and CPU utilization.

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
149
[➔ Read more about the node exporter.](node_exporter.md)
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
150

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
151
152
153
154
155
156
### Redis exporter

The Redis exporter allows you to measure various Redis metrics.

[➔ Read more about the Redis exporter.](redis_exporter.md)

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
157
158
159
160
161
162
### Postgres exporter

The Postgres exporter allows you to measure various PostgreSQL metrics.

[➔ Read more about the Postgres exporter.](postgres_exporter.md)

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
163
164
### GitLab monitor exporter

Joshua Lambert's avatar
Joshua Lambert включено в состав коммита
165
The GitLab monitor exporter allows you to measure various GitLab metrics, pulled from Redis and the database.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
166
167
168

[➔ Read more about the GitLab monitor exporter.](gitlab_monitor_exporter.md)

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
169
[grafana]: https://grafana.net
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
170
171
[hsts]: https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security
[multi-user-prometheus]: https://gitlab.com/gitlab-org/multi-user-prometheus
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
172
[nginx-custom-config]: https://docs.gitlab.com/omnibus/settings/nginx.html#inserting-custom-nginx-settings-into-the-gitlab-server-block
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
173
[prometheus]: https://prometheus.io
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
174
[prom-exporters]: https://prometheus.io/docs/instrumenting/exporters/
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
175
176
177
178
[prom-query]: https://prometheus.io/docs/querying/basics
[prom-grafana]: https://prometheus.io/docs/visualization/grafana/
[scrape-config]: https://prometheus.io/docs/operating/configuration/#%3Cscrape_config%3E
[reconfigure]: ../../restart_gitlab.md#omnibus-gitlab-reconfigure
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
179
[1261]: https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests/1261
Joshua Lambert's avatar
Joshua Lambert включено в состав коммита
180
[prometheus integration]: ../../../user/project/integrations/prometheus.md
Joshua Lambert's avatar
Joshua Lambert включено в состав коммита
181
[prometheus-cadvisor-metrics]: https://github.com/google/cadvisor/blob/master/docs/storage/prometheus.md