Skip to content

Commit 69c9c83

Browse files
Joshua Lambertrymai
Joshua Lambert
authored andcommitted
Improve Prometheus docs, include nginx ingress
1 parent 7963e2b commit 69c9c83

File tree

6 files changed

+69
-15
lines changed

6 files changed

+69
-15
lines changed

config/prometheus/additional_metrics.yml

+34-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
- group: Response metrics (NGINX Ingress)
2+
priority: 10
3+
metrics:
4+
- title: "Throughput"
5+
y_label: "Requests / Sec"
6+
required_metrics:
7+
- nginx_upstream_requests_total
8+
weight: 1
9+
queries:
10+
- query_range: 'sum(rate(nginx_upstream_requests_total{upstream=~"%{kube_namespace}-%{ci_environment_slug}-.*"}[2m]))'
11+
label: Total
12+
unit: req / sec
13+
- title: "Latency"
14+
y_label: "Latency (ms)"
15+
required_metrics:
16+
- nginx_upstream_response_msecs_avg
17+
weight: 1
18+
queries:
19+
- query_range: 'avg(nginx_upstream_response_msecs_avg{upstream=~"%{kube_namespace}-%{ci_environment_slug}-.*"})'
20+
label: Average
21+
unit: ms
22+
- title: "HTTP Error Rate"
23+
y_label: "HTTP 500 Errors / Sec"
24+
required_metrics:
25+
- nginx_upstream_responses_total
26+
weight: 1
27+
queries:
28+
- query_range: 'sum(rate(nginx_upstream_responses_total{status_code="5xx", upstream=~"%{kube_namespace}-%{ci_environment_slug}-.*"}[2m]))'
29+
label: HTTP Errors
30+
unit: "errors / sec"
131
- group: Response metrics (HA Proxy)
232
priority: 10
333
metrics:
@@ -68,18 +98,18 @@
6898
- nginx_upstream_response_msecs_avg
6999
weight: 1
70100
queries:
71-
- query_range: 'avg(nginx_upstream_response_msecs_avg{%{environment_filter}}) * 1000'
101+
- query_range: 'avg(nginx_upstream_response_msecs_avg{%{environment_filter}})'
72102
label: Upstream
73103
unit: ms
74104
- title: "HTTP Error Rate"
75-
y_label: "Error Rate (%)"
105+
y_label: "HTTP 500 Errors / Sec"
76106
required_metrics:
77107
- nginx_responses_total
78108
weight: 1
79109
queries:
80-
- query_range: 'sum(rate(nginx_responses_total{status_code="5xx", %{environment_filter}}[2m])) / sum(rate(nginx_requests_total{server_zone!="*", server_zone!="_", %{environment_filter}}[2m]))'
110+
- query_range: 'sum(rate(nginx_responses_total{status_code="5xx", %{environment_filter}}[2m]))'
81111
label: HTTP Errors
82-
unit: "%"
112+
unit: "errors / sec"
83113
- group: System metrics (Kubernetes)
84114
priority: 5
85115
metrics:

doc/ci/environments.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -607,10 +607,9 @@ exist, you should see something like:
607607
- With GitLab 9.2, all deployments to an environment are shown directly on the
608608
monitoring dashboard
609609

610-
If you have enabled Prometheus for collecting metrics, you can monitor the performance behavior of your app
611-
through the environments.
610+
If you have enabled [Prometheus for monitoring system and response metrics](https://docs.gitlab.com/ee/user/project/integrations/prometheus.html), you can monitor the performance behavior of your app running in each environment.
612611

613-
Once configured, GitLab will attempt to retrieve performance metrics for any
612+
Once configured, GitLab will attempt to retrieve [supported performance metrics](https://docs.gitlab.com/ee/user/project/integrations/prometheus_library/metrics.html) for any
614613
environment which has had a successful deployment. If monitoring data was
615614
successfully retrieved, a Monitoring button will appear on the environment's
616615
detail page.

doc/user/project/integrations/prometheus.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Installing and configuring Prometheus to monitor applications is fairly straight
4040
### Configuring Omnibus GitLab Prometheus to monitor Kubernetes deployments
4141

4242
With Omnibus GitLab running inside of Kubernetes, you can leverage the bundled
43-
version of Prometheus to collect the supported metrics. Once enabled, Prometheus will automatically begin monitoring Kubernetes Nodes and any [annotated Pods](https://prometheus.io/docs/operating/configuration/#<kubernetes_sd_config>).
43+
version of Prometheus to collect the supported metrics. Once enabled, Prometheus will automatically begin monitoring Kubernetes Nodes and any [annotated Pods](https://prometheus.io/docs/operating/configuration/#<kubernetes_sd_config>).
4444

4545
1. Read how to configure the bundled Prometheus server in the
4646
[Administration guide][gitlab-prometheus-k8s-monitor].
@@ -133,6 +133,8 @@ to integrate with.
133133
Once configured, GitLab will attempt to retrieve performance metrics for any
134134
environment which has had a successful deployment.
135135

136+
GitLab will automatically scan the Prometheus server for known metrics and attempt to identify the metrics for a particular environment. The supported metrics and scan process is detailed in our [Prometheus Metric Library documentation](prometheus_library/metrics.html).
137+
136138
[Learn more about monitoring environments.](../../../ci/environments.md#monitoring-environments)
137139

138140
## Determining the performance impact of a merge
@@ -174,7 +176,7 @@ If the "Attempting to load performance data" screen continues to appear, it coul
174176
[prometheus-docker-image]: https://hub.docker.com/r/prom/prometheus/
175177
[prometheus-yml]:samples/prometheus.yml
176178
[gitlab.com-ip-range]: https://gitlab.com/gitlab-com/infrastructure/issues/434
177-
[ci-environment-slug]: https://docs.gitlab.com/ce/ci/variables/#predefined-variables-environment-variables
179+
[ci-environment-slug]: ../../../ci/variables/#predefined-variables-environment-variables
178180
[ce-8935]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8935
179181
[ce-10408]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10408
180182
[promgldocs]: ../../../administration/monitoring/prometheus/index.md

doc/user/project/integrations/prometheus_library/metrics.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
GitLab offers automatic detection of select [Prometheus exporters](https://prometheus.io/docs/instrumenting/exporters/). Currently supported exporters are:
55
* [Kubernetes](kubernetes.md)
66
* [NGINX](nginx.md)
7+
* [NGINX Ingress Controller](nginx_ingress.md)
78
* [HAProxy](haproxy.md)
89
* [Amazon Cloud Watch](cloudwatch.md)
910

@@ -14,10 +15,7 @@ We have tried to surface the most important metrics for each exporter, and will
1415
GitLab retrieves performance data from the configured Prometheus server, and attempts to identifying the presence of known metrics. Once identified, GitLab then needs to be able to map the data to a particular environment.
1516

1617
In order to isolate and only display relevant metrics for a given environment, GitLab needs a method to detect which labels are associated. To do that,
17-
GitLab will look for the required metrics which have a label that
18-
matches the [$CI_ENVIRONMENT_SLUG][ci-environment-slug].
19-
20-
For example if you are deploying to an environment named `production`, there must be a label for the metric with the value of `production`.
18+
GitLab uses the defined queries and fills in the environment specific variables. Typically this involves looking for the [$CI_ENVIRONMENT_SLUG](https://docs.gitlab.com/ee/ci/variables/#predefined-variables-environment-variables), but may also include other information such as the project's Kubernetes namespace. Each search query is defined in the [exporter specific documentation](#prometheus-metrics-library).
2119

2220
## Adding to the library
2321

doc/user/project/integrations/prometheus_library/nginx.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ GitLab has support for automatically detecting and monitoring NGINX. This is pro
88
| Name | Query |
99
| ---- | ----- |
1010
| Throughput (req/sec) | sum(rate(nginx_requests_total{server_zone!="*", server_zone!="_", %{environment_filter}}[2m])) |
11-
| Latency (ms) | avg(nginx_upstream_response_msecs_avg{%{environment_filter}}) * 1000 |
12-
| HTTP Error Rate (%) | sum(rate(haproxy_frontend_http_responses_total{code="5xx",%{environment_filter}}[2m])) / sum(rate(haproxy_frontend_http_responses_total{%{environment_filter}}[2m])) |
11+
| Latency (ms) | avg(nginx_upstream_response_msecs_avg{%{environment_filter}}) |
12+
| HTTP Error Rate (HTTP Errors / sec) | rate(nginx_responses_total{status_code="5xx", %{environment_filter}}[2m])) |
1313

1414
## Configuring Prometheus to monitor for NGINX metrics
1515

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Monitoring NGINX Ingress Controller
2+
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/13438) in GitLab 9.5
3+
4+
GitLab has support for automatically detecting and monitoring the Kubernetes NGINX ingress controller. This is provided by leveraging the built in Prometheus metrics included in [version 0.9.0](https://github.com/kubernetes/ingress/blob/master/controllers/nginx/Changelog.md#09-beta1) of the ingress.
5+
6+
## Metrics supported
7+
8+
| Name | Query |
9+
| ---- | ----- |
10+
| Throughput (req/sec) | sum(rate(nginx_upstream_requests_total{upstream=~"%{kube_namespace}-%{ci_environment_slug}-.*"}[2m])) |
11+
| Latency (ms) | avg(nginx_upstream_response_msecs_avg{upstream=~"%{kube_namespace}-%{ci_environment_slug}-.*"}) |
12+
| HTTP Error Rate (HTTP Errors / sec) | sum(rate(nginx_upstream_responses_total{status_code="5xx", upstream=~"%{kube_namespace}-%{ci_environment_slug}-.*"}[2m])) |
13+
14+
## Configuring Prometheus to monitor for NGINX ingress metrics
15+
16+
The easiest way to get started is to use at least version 0.9.0 of [NGINX ingress](https://github.com/kubernetes/ingress/tree/master/controllers/nginx). If you are using NGINX as your Kubernetes ingress, there is [direct support](https://github.com/kubernetes/ingress/pull/423) for enabling Prometheus monitoring in the 0.9.0 release.
17+
18+
If you have deployed with the [gitlab-omnibus](https://docs.gitlab.com/ee/install/kubernetes/gitlab_omnibus.md) Helm chart, these metrics will be automatically enabled and annotated for Prometheus monitoring.
19+
20+
## Specifying the Environment label
21+
22+
In order to isolate and only display relevant metrics for a given environment
23+
however, GitLab needs a method to detect which labels are associated. To do this, GitLab will search metrics with appropriate labels. In this case, the `upstream` label must be of the form `<Kubernetes Namespace>-<CI_ENVIRONMENT_SLUG>-*`.
24+
25+
If you have used [Auto Deploy](https://docs.gitlab.com/ee/ci/autodeploy/index.html) to deploy your app, this format will be used automatically and metrics will be detected with no action on your part.

0 commit comments

Comments
 (0)