debian-mirror-gitlab/doc/user/project/integrations/prometheus_library/nginx_ingress.md

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

50 lines
3.4 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
---
2022-03-02 08:16:31 +05:30
# Monitoring NGINX Ingress Controller (DEPRECATED) **(FREE)**
2018-03-17 18:26:18 +05:30
2022-03-02 08:16:31 +05:30
> [Deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/346541) in GitLab 14.7.
WARNING:
This feature is in its end-of-life process. It is [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/346541)
2022-06-21 17:19:12 +05:30
in GitLab 14.7, and is planned for removal in GitLab 16.0.
2017-09-10 17:25:29 +05:30
2021-01-03 14:25:43 +05:30
GitLab has support for automatically detecting and monitoring the Kubernetes NGINX Ingress controller. This is provided by leveraging the built-in Prometheus metrics included with Kubernetes NGINX Ingress controller [version 0.16.0](https://github.com/kubernetes/ingress-nginx/blob/master/Changelog.md#0160) onward.
2021-02-22 17:27:13 +05:30
NOTE:
2020-07-28 23:09:34 +05:30
NGINX Ingress versions prior to 0.16.0 offer an included [VTS Prometheus metrics exporter](nginx_ingress_vts.md), which exports metrics different than the built-in metrics.
2019-02-15 15:39:39 +05:30
2018-03-17 18:26:18 +05:30
## Requirements
2018-10-15 14:42:47 +05:30
[Prometheus integration](../prometheus.md) must be active.
2017-09-10 17:25:29 +05:30
## Metrics supported
| Name | Query |
| ---- | ----- |
2019-09-30 21:07:59 +05:30
| Throughput (req/sec) | `sum(label_replace(rate(nginx_ingress_controller_requests{namespace="%{kube_namespace}",ingress=~".*%{ci_environment_slug}.*"}[2m]), "status_code", "${1}xx", "status", "(.)..")) by (status_code)` |
| Latency (ms) | `sum(rate(nginx_ingress_controller_ingress_upstream_latency_seconds_sum{namespace="%{kube_namespace}",ingress=~".*%{ci_environment_slug}.*"}[2m])) / sum(rate(nginx_ingress_controller_ingress_upstream_latency_seconds_count{namespace="%{kube_namespace}",ingress=~".*%{ci_environment_slug}.*"}[2m])) * 1000` |
| HTTP Error Rate (%) | `sum(rate(nginx_ingress_controller_requests{status=~"5.*",namespace="%{kube_namespace}",ingress=~".*%{ci_environment_slug}.*"}[2m])) / sum(rate(nginx_ingress_controller_requests{namespace="%{kube_namespace}",ingress=~".*%{ci_environment_slug}.*"}[2m])) * 100` |
2017-09-10 17:25:29 +05:30
2019-12-21 20:55:43 +05:30
## Configuring NGINX Ingress monitoring
2018-03-17 18:26:18 +05:30
2021-02-22 17:27:13 +05:30
Version 0.9.0 and above of [NGINX Ingress](https://github.com/kubernetes/ingress-nginx) have built-in support for exporting Prometheus metrics. To enable, a ConfigMap setting must be passed: `enable-vts-status: "true"`. Once enabled, a Prometheus metrics endpoint starts running on port 10254.
2018-03-17 18:26:18 +05:30
2019-12-21 20:55:43 +05:30
Next, the Ingress needs to be annotated for Prometheus monitoring. Two new annotations need to be added:
2017-09-10 17:25:29 +05:30
2019-03-02 22:35:43 +05:30
- `prometheus.io/scrape: "true"`
- `prometheus.io/port: "10254"`
2017-09-10 17:25:29 +05:30
2023-01-13 00:05:48 +05:30
Managing these settings depends on how NGINX Ingress has been deployed. If you have deployed via the [official Helm chart](https://github.com/kubernetes/ingress-nginx/tree/master/charts/ingress-nginx), metrics can be enabled with `controller.stats.enabled` along with the required annotations. Alternatively it is possible to edit the NGINX Ingress YAML directly in the [Kubernetes dashboard](https://github.com/kubernetes/dashboard).
2017-09-10 17:25:29 +05:30
## Specifying the Environment label
2021-11-18 22:05:49 +05:30
To isolate and display only relevant metrics for a given environment, GitLab needs a method to
detect which labels are associated. To do this, GitLab searches for metrics with appropriate labels.
In this case, the `ingress` label must include the value `<CI_ENVIRONMENT_SLUG>`.
2017-09-10 17:25:29 +05:30
2021-02-22 17:27:13 +05:30
If you have used [Auto Deploy](../../../../topics/autodevops/stages.md#auto-deploy) to deploy your app, this format is used automatically and metrics are detected with no action on your part.