# Monitoring NGINX > 原文:[https://docs.gitlab.com/ee/user/project/integrations/prometheus_library/nginx.html](https://docs.gitlab.com/ee/user/project/integrations/prometheus_library/nginx.html) * [Requirements](#requirements) * [Metrics supported](#metrics-supported) * [Configuring Prometheus to monitor for NGINX metrics](#configuring-prometheus-to-monitor-for-nginx-metrics) * [Specifying the Environment label](#specifying-the-environment-label) # Monitoring NGINX[](#monitoring-nginx "Permalink") 在 GitLab 9.4 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/12621) GitLab 支持自动检测和监视 NGINX. 这是通过利用[NGINX VTS 导出器提供的](https://github.com/hnlq715/nginx-vts-exporter) ,该[导出](https://github.com/hnlq715/nginx-vts-exporter)器将[VTS 统计信息](https://github.com/vozlt/nginx-module-vts)转换为 Prometheus 可读形式. ## Requirements[](#requirements "Permalink") 必须启用[Prometheus 服务](../prometheus.html) . ## Metrics supported[](#metrics-supported "Permalink") 检测到 NGINX 服务器指标,该指标跟踪 NGINX 直接提供的页面和内容. | Name | Query | | --- | --- | | 吞吐量(要求/秒) | `sum(rate(nginx_server_requests{server_zone!="*", server_zone!="_", %{environment_filter}}[2m])) by (code)` | | 延迟(毫秒) | `avg(nginx_server_requestMsec{%{environment_filter}})` | | HTTP 错误率(HTTP 错误/秒) | `sum(rate(nginx_server_requests{code="5xx", %{environment_filter}}[2m]))` | | HTTP 错误(%) | `sum(rate(nginx_server_requests{code=~"5.*", host="*", %{environment_filter}}[2m])) / sum(rate(nginx_server_requests{code="total", host="*", %{environment_filter}}[2m])) * 100` | ## Configuring Prometheus to monitor for NGINX metrics[](#configuring-prometheus-to-monitor-for-nginx-metrics "Permalink") 要开始使用 NGINX 监视,您应该首先为 NGINX 服务器启用[VTS 统计](https://github.com/vozlt/nginx-module-vts)模块. 这将捕获并以 HTML 可读形式显示统计信息. 接下来,您应该安装并配置[NGINX VTS 导出器](https://github.com/hnlq715/nginx-vts-exporter) ,该[导出器](https://github.com/hnlq715/nginx-vts-exporter)将解析这些统计信息并将其转换为 Prometheus 监视端点. 如果您将 NGINX 用作 Kubernetes 入口,GitLab 将在 0.9.0 及更高版本中启用后[自动检测](nginx_ingress.html)指标. ## Specifying the Environment label[](#specifying-the-environment-label "Permalink") 为了隔离并仅显示给定环境的相关指标,GitLab 需要一种方法来检测关联了哪些标签. 为此,GitLab 将[查找`environment`标签](index.html#identifying-environments) .