1
0
mirror of https://github.com/nginxinc/nginx-prometheus-exporter.git synced 2025-08-05 06:41:09 +03:00

add metric for max_conns of upstream servers (#201)

This commit is contained in:
Steven Hessing
2021-09-23 11:02:55 -07:00
committed by GitHub
parent dfebae82d9
commit bf1c2c9bf9
2 changed files with 9 additions and 1 deletions

View File

@@ -173,6 +173,7 @@ Name | Type | Description | Labels
----|----|----|----|
`nginxplus_upstream_server_state` | Gauge | Current state | `server`, `upstream` |
`nginxplus_upstream_server_active` | Gauge | Active connections | `server`, `upstream` |
`nginxplus_upstream_server_limit` | Gauge | Limit for connections which corresponds to the max_conns parameter of the upstream server. Zero value means there is no limit | `server`, `upstream` |
`nginxplus_upstream_server_requests` | Counter | Total client requests | `server`, `upstream` |
`nginxplus_upstream_server_responses` | Counter | Total responses sent to clients | `code` (the response status code. The values are: `1xx`, `2xx`, `3xx`, `4xx` and `5xx`), `server`, `upstream` |
`nginxplus_upstream_server_sent` | Counter | Bytes sent to this server | `server`, `upstream` |
@@ -195,8 +196,9 @@ Name | Type | Description | Labels
----|----|----|----|
`nginxplus_stream_upstream_server_state` | Gauge | Current state | `server`, `upstream` |
`nginxplus_stream_upstream_server_active` | Gauge | Active connections | `server` , `upstream` |
`nginxplus_stream_upstream_server_limit` | Gauge | Limit for connections which corresponds to the max_conns parameter of the upstream server. Zero value means there is no limit | `server` , `upstream` |
`nginxplus_stream_upstream_server_connections` | Counter | Total number of client connections forwarded to this server | `server`, `upstream` |
`nginxplus_stream_upstream_server_connect_time` | Gauge | Average time to connect to the upstream server | `server`, `upstream`
`nginxplus_stream_upstream_server_connect_time` | Gauge | Average time to connect to the upstream server | `server`, `upstream`
`nginxplus_stream_upstream_server_first_byte_time` | Gauge | Average time to receive the first byte of data | `server`, `upstream` |
`nginxplus_stream_upstream_server_response_time` | Gauge | Average time to receive the last byte of data | `server`, `upstream` |
`nginxplus_stream_upstream_server_sent` | Counter | Bytes sent to this server | `server`, `upstream` |

View File

@@ -273,6 +273,7 @@ func NewNginxPlusCollector(nginxClient *plusclient.NginxClient, namespace string
upstreamServerMetrics: map[string]*prometheus.Desc{
"state": newUpstreamServerMetric(namespace, "state", "Current state", upstreamServerVariableLabelNames, constLabels),
"active": newUpstreamServerMetric(namespace, "active", "Active connections", upstreamServerVariableLabelNames, constLabels),
"limit": newUpstreamServerMetric(namespace, "limit", "Limit for connections which corresponds to the max_conns parameter of the upstream server. Zero value means there is no limit", upstreamServerVariableLabelNames, constLabels),
"requests": newUpstreamServerMetric(namespace, "requests", "Total client requests", upstreamServerVariableLabelNames, constLabels),
"responses_1xx": newUpstreamServerMetric(namespace, "responses", "Total responses sent to clients", upstreamServerVariableLabelNames, MergeLabels(constLabels, prometheus.Labels{"code": "1xx"})),
"responses_2xx": newUpstreamServerMetric(namespace, "responses", "Total responses sent to clients", upstreamServerVariableLabelNames, MergeLabels(constLabels, prometheus.Labels{"code": "2xx"})),
@@ -292,6 +293,7 @@ func NewNginxPlusCollector(nginxClient *plusclient.NginxClient, namespace string
streamUpstreamServerMetrics: map[string]*prometheus.Desc{
"state": newStreamUpstreamServerMetric(namespace, "state", "Current state", streamUpstreamServerVariableLabelNames, constLabels),
"active": newStreamUpstreamServerMetric(namespace, "active", "Active connections", streamUpstreamServerVariableLabelNames, constLabels),
"limit": newStreamUpstreamServerMetric(namespace, "limit", "Limit for connections which corresponds to the max_conns parameter of the upstream server. Zero value means there is no limit", streamUpstreamServerVariableLabelNames, constLabels),
"sent": newStreamUpstreamServerMetric(namespace, "sent", "Bytes sent to this server", streamUpstreamServerVariableLabelNames, constLabels),
"received": newStreamUpstreamServerMetric(namespace, "received", "Bytes received from this server", streamUpstreamServerVariableLabelNames, constLabels),
"fails": newStreamUpstreamServerMetric(namespace, "fails", "Number of unsuccessful attempts to communicate with the server", streamUpstreamServerVariableLabelNames, constLabels),
@@ -511,6 +513,8 @@ func (c *NginxPlusCollector) Collect(ch chan<- prometheus.Metric) {
prometheus.GaugeValue, upstreamServerStates[peer.State], labelValues...)
ch <- prometheus.MustNewConstMetric(c.upstreamServerMetrics["active"],
prometheus.GaugeValue, float64(peer.Active), labelValues...)
ch <- prometheus.MustNewConstMetric(c.upstreamServerMetrics["limit"],
prometheus.GaugeValue, float64(peer.MaxConns), labelValues...)
ch <- prometheus.MustNewConstMetric(c.upstreamServerMetrics["requests"],
prometheus.CounterValue, float64(peer.Requests), labelValues...)
ch <- prometheus.MustNewConstMetric(c.upstreamServerMetrics["responses_1xx"],
@@ -582,6 +586,8 @@ func (c *NginxPlusCollector) Collect(ch chan<- prometheus.Metric) {
prometheus.GaugeValue, upstreamServerStates[peer.State], labelValues...)
ch <- prometheus.MustNewConstMetric(c.streamUpstreamServerMetrics["active"],
prometheus.GaugeValue, float64(peer.Active), labelValues...)
ch <- prometheus.MustNewConstMetric(c.streamUpstreamServerMetrics["limit"],
prometheus.GaugeValue, float64(peer.MaxConns), labelValues...)
ch <- prometheus.MustNewConstMetric(c.streamUpstreamServerMetrics["connections"],
prometheus.CounterValue, float64(peer.Connections), labelValues...)
ch <- prometheus.MustNewConstMetric(c.streamUpstreamServerMetrics["connect_time"],