1
0
mirror of https://github.com/nginxinc/nginx-prometheus-exporter.git synced 2025-08-09 16:02:43 +03:00

Add metrics from NGINX Plus API version 8 (#290)

Adds metrics for the ssl data for each HTTP upstream, server zone, and stream upstream, server zone.

Closes #284
This commit is contained in:
Luca Comellini
2022-08-23 09:52:54 -07:00
committed by GitHub
parent 0b137d8846
commit bc9d31c9a8
2 changed files with 106 additions and 59 deletions

View File

@@ -155,6 +155,9 @@ Name | Type | Description | Labels
`nginxplus_server_zone_discarded` | Counter | Requests completed without sending a response | `server_zone` | `nginxplus_server_zone_discarded` | Counter | Requests completed without sending a response | `server_zone` |
`nginxplus_server_zone_received` | Counter | Bytes received from clients | `server_zone` | `nginxplus_server_zone_received` | Counter | Bytes received from clients | `server_zone` |
`nginxplus_server_zone_sent` | Counter | Bytes sent to clients | `server_zone` | `nginxplus_server_zone_sent` | Counter | Bytes sent to clients | `server_zone` |
`nginxplus_server_ssl_handshakes` | Counter | Successful SSL handshakes | `server_zone` |
`nginxplus_server_ssl_handshakes_failed` | Counter | Failed SSL handshakes | `server_zone` |
`nginxplus_server_ssl_session_reuses` | Counter | Session reuses during SSL handshake | `server_zone` |
#### [Stream Server Zones](https://nginx.org/en/docs/http/ngx_http_api_module.html#def_nginx_stream_server_zone) #### [Stream Server Zones](https://nginx.org/en/docs/http/ngx_http_api_module.html#def_nginx_stream_server_zone)
Name | Type | Description | Labels Name | Type | Description | Labels
@@ -165,6 +168,9 @@ Name | Type | Description | Labels
`nginxplus_stream_server_zone_discarded` | Counter | Connections completed without creating a session | `server_zone` | `nginxplus_stream_server_zone_discarded` | Counter | Connections completed without creating a session | `server_zone` |
`nginxplus_stream_server_zone_received` | Counter | Bytes received from clients | `server_zone` | `nginxplus_stream_server_zone_received` | Counter | Bytes received from clients | `server_zone` |
`nginxplus_stream_server_zone_sent` | Counter | Bytes sent to clients | `server_zone` | `nginxplus_stream_server_zone_sent` | Counter | Bytes sent to clients | `server_zone` |
`nginxplus_stream_server_ssl_handshakes` | Counter | Successful SSL handshakes | `server_zone` |
`nginxplus_stream_server_ssl_handshakes_failed` | Counter | Failed SSL handshakes | `server_zone` |
`nginxplus_stream_server_ssl_session_reuses` | Counter | Session reuses during SSL handshake | `server_zone` |
#### [HTTP Upstreams](https://nginx.org/en/docs/http/ngx_http_api_module.html#def_nginx_http_upstream) #### [HTTP Upstreams](https://nginx.org/en/docs/http/ngx_http_api_module.html#def_nginx_http_upstream)
@@ -187,6 +193,9 @@ Name | Type | Description | Labels
`nginxplus_upstream_server_health_checks_checks` | Counter | Total health check requests | `server`, `upstream` | `nginxplus_upstream_server_health_checks_checks` | Counter | Total health check requests | `server`, `upstream` |
`nginxplus_upstream_server_health_checks_fails` | Counter | Failed health checks | `server`, `upstream` | `nginxplus_upstream_server_health_checks_fails` | Counter | Failed health checks | `server`, `upstream` |
`nginxplus_upstream_server_health_checks_unhealthy` | Counter | How many times the server became unhealthy (state 'unhealthy') | `server`, `upstream` | `nginxplus_upstream_server_health_checks_unhealthy` | Counter | How many times the server became unhealthy (state 'unhealthy') | `server`, `upstream` |
`nginxplus_upstream_server_ssl_handshakes` | Counter | Successful SSL handshakes | `server`, `upstream` |
`nginxplus_upstream_server_ssl_handshakes_failed` | Counter | Failed SSL handshakes | `server`, `upstream` |
`nginxplus_upstream_server_ssl_session_reuses` | Counter | Session reuses during SSL handshake | `server`, `upstream` |
`nginxplus_upstream_keepalives` | Gauge | Idle keepalive connections | `upstream` | `nginxplus_upstream_keepalives` | Gauge | Idle keepalive connections | `upstream` |
`nginxplus_upstream_zombies` | Gauge | Servers removed from the group but still processing active client requests | `upstream` | `nginxplus_upstream_zombies` | Gauge | Servers removed from the group but still processing active client requests | `upstream` |
@@ -210,6 +219,9 @@ Name | Type | Description | Labels
`nginxplus_stream_upstream_server_health_checks_checks` | Counter | Total health check requests | `server`, `upstream` | `nginxplus_stream_upstream_server_health_checks_checks` | Counter | Total health check requests | `server`, `upstream` |
`nginxplus_stream_upstream_server_health_checks_fails` | Counter | Failed health checks | `server`, `upstream` | `nginxplus_stream_upstream_server_health_checks_fails` | Counter | Failed health checks | `server`, `upstream` |
`nginxplus_stream_upstream_server_health_checks_unhealthy` | Counter | How many times the server became unhealthy (state 'unhealthy') | `server`, `upstream` | `nginxplus_stream_upstream_server_health_checks_unhealthy` | Counter | How many times the server became unhealthy (state 'unhealthy') | `server`, `upstream` |
`nginxplus_stream_upstream_server_ssl_handshakes` | Counter | Successful SSL handshakes | `server`, `upstream` |
`nginxplus_stream_upstream_server_ssl_handshakes_failed` | Counter | Failed SSL handshakes | `server`, `upstream` |
`nginxplus_stream_upstream_server_ssl_session_reuses` | Counter | Session reuses during SSL handshake | `server`, `upstream` |
`nginxplus_stream_upstream_zombies` | Gauge | Servers removed from the group but still processing active client connections | `upstream`| `nginxplus_stream_upstream_zombies` | Gauge | Servers removed from the group but still processing active client connections | `upstream`|
#### [Stream Zone Sync](https://nginx.org/en/docs/http/ngx_http_api_module.html#def_nginx_stream_zone_sync) #### [Stream Zone Sync](https://nginx.org/en/docs/http/ngx_http_api_module.html#def_nginx_stream_zone_sync)

View File

@@ -296,6 +296,9 @@ func NewNginxPlusCollector(nginxClient *plusclient.NginxClient, namespace string
"codes_503": newServerZoneMetric(namespace, "responses_codes", "Total responses sent to clients", variableLabelNames.ServerZoneVariableLabelNames, MergeLabels(constLabels, prometheus.Labels{"code": "503"})), "codes_503": newServerZoneMetric(namespace, "responses_codes", "Total responses sent to clients", variableLabelNames.ServerZoneVariableLabelNames, MergeLabels(constLabels, prometheus.Labels{"code": "503"})),
"codes_504": newServerZoneMetric(namespace, "responses_codes", "Total responses sent to clients", variableLabelNames.ServerZoneVariableLabelNames, MergeLabels(constLabels, prometheus.Labels{"code": "504"})), "codes_504": newServerZoneMetric(namespace, "responses_codes", "Total responses sent to clients", variableLabelNames.ServerZoneVariableLabelNames, MergeLabels(constLabels, prometheus.Labels{"code": "504"})),
"codes_507": newServerZoneMetric(namespace, "responses_codes", "Total responses sent to clients", variableLabelNames.ServerZoneVariableLabelNames, MergeLabels(constLabels, prometheus.Labels{"code": "507"})), "codes_507": newServerZoneMetric(namespace, "responses_codes", "Total responses sent to clients", variableLabelNames.ServerZoneVariableLabelNames, MergeLabels(constLabels, prometheus.Labels{"code": "507"})),
"ssl_handshakes": newServerZoneMetric(namespace, "ssl_handshakes", "Successful SSL handshakes", variableLabelNames.ServerZoneVariableLabelNames, constLabels),
"ssl_handshakes_failed": newServerZoneMetric(namespace, "ssl_handshakes_failed", "Failed SSL handshakes", variableLabelNames.ServerZoneVariableLabelNames, constLabels),
"ssl_session_reuses": newServerZoneMetric(namespace, "ssl_session_reuses", "Session reuses during SSL handshake", variableLabelNames.ServerZoneVariableLabelNames, constLabels),
}, },
streamServerZoneMetrics: map[string]*prometheus.Desc{ streamServerZoneMetrics: map[string]*prometheus.Desc{
"processing": newStreamServerZoneMetric(namespace, "processing", "Client connections that are currently being processed", variableLabelNames.StreamServerZoneVariableLabelNames, constLabels), "processing": newStreamServerZoneMetric(namespace, "processing", "Client connections that are currently being processed", variableLabelNames.StreamServerZoneVariableLabelNames, constLabels),
@@ -306,6 +309,9 @@ func NewNginxPlusCollector(nginxClient *plusclient.NginxClient, namespace string
"discarded": newStreamServerZoneMetric(namespace, "discarded", "Connections completed without creating a session", variableLabelNames.StreamServerZoneVariableLabelNames, constLabels), "discarded": newStreamServerZoneMetric(namespace, "discarded", "Connections completed without creating a session", variableLabelNames.StreamServerZoneVariableLabelNames, constLabels),
"received": newStreamServerZoneMetric(namespace, "received", "Bytes received from clients", variableLabelNames.StreamServerZoneVariableLabelNames, constLabels), "received": newStreamServerZoneMetric(namespace, "received", "Bytes received from clients", variableLabelNames.StreamServerZoneVariableLabelNames, constLabels),
"sent": newStreamServerZoneMetric(namespace, "sent", "Bytes sent to clients", variableLabelNames.StreamServerZoneVariableLabelNames, constLabels), "sent": newStreamServerZoneMetric(namespace, "sent", "Bytes sent to clients", variableLabelNames.StreamServerZoneVariableLabelNames, constLabels),
"ssl_handshakes": newStreamServerZoneMetric(namespace, "ssl_handshakes", "Successful SSL handshakes", variableLabelNames.StreamServerZoneVariableLabelNames, constLabels),
"ssl_handshakes_failed": newStreamServerZoneMetric(namespace, "ssl_handshakes_failed", "Failed SSL handshakes", variableLabelNames.StreamServerZoneVariableLabelNames, constLabels),
"ssl_session_reuses": newStreamServerZoneMetric(namespace, "ssl_session_reuses", "Session reuses during SSL handshake", variableLabelNames.StreamServerZoneVariableLabelNames, constLabels),
}, },
upstreamMetrics: map[string]*prometheus.Desc{ upstreamMetrics: map[string]*prometheus.Desc{
"keepalives": newUpstreamMetric(namespace, "keepalives", "Idle keepalive connections", constLabels), "keepalives": newUpstreamMetric(namespace, "keepalives", "Idle keepalive connections", constLabels),
@@ -373,6 +379,9 @@ func NewNginxPlusCollector(nginxClient *plusclient.NginxClient, namespace string
"codes_503": newUpstreamServerMetric(namespace, "responses_codes", "Total responses sent to clients", upstreamServerVariableLabelNames, MergeLabels(constLabels, prometheus.Labels{"code": "503"})), "codes_503": newUpstreamServerMetric(namespace, "responses_codes", "Total responses sent to clients", upstreamServerVariableLabelNames, MergeLabels(constLabels, prometheus.Labels{"code": "503"})),
"codes_504": newUpstreamServerMetric(namespace, "responses_codes", "Total responses sent to clients", upstreamServerVariableLabelNames, MergeLabels(constLabels, prometheus.Labels{"code": "504"})), "codes_504": newUpstreamServerMetric(namespace, "responses_codes", "Total responses sent to clients", upstreamServerVariableLabelNames, MergeLabels(constLabels, prometheus.Labels{"code": "504"})),
"codes_507": newUpstreamServerMetric(namespace, "responses_codes", "Total responses sent to clients", upstreamServerVariableLabelNames, MergeLabels(constLabels, prometheus.Labels{"code": "507"})), "codes_507": newUpstreamServerMetric(namespace, "responses_codes", "Total responses sent to clients", upstreamServerVariableLabelNames, MergeLabels(constLabels, prometheus.Labels{"code": "507"})),
"ssl_handshakes": newUpstreamServerMetric(namespace, "ssl_handshakes", "Successful SSL handshakes", upstreamServerVariableLabelNames, constLabels),
"ssl_handshakes_failed": newUpstreamServerMetric(namespace, "ssl_handshakes_failed", "Failed SSL handshakes", upstreamServerVariableLabelNames, constLabels),
"ssl_session_reuses": newUpstreamServerMetric(namespace, "ssl_session_reuses", "Session reuses during SSL handshake", upstreamServerVariableLabelNames, constLabels),
}, },
streamUpstreamServerMetrics: map[string]*prometheus.Desc{ streamUpstreamServerMetrics: map[string]*prometheus.Desc{
"state": newStreamUpstreamServerMetric(namespace, "state", "Current state", streamUpstreamServerVariableLabelNames, constLabels), "state": newStreamUpstreamServerMetric(namespace, "state", "Current state", streamUpstreamServerVariableLabelNames, constLabels),
@@ -389,6 +398,9 @@ func NewNginxPlusCollector(nginxClient *plusclient.NginxClient, namespace string
"health_checks_checks": newStreamUpstreamServerMetric(namespace, "health_checks_checks", "Total health check requests", streamUpstreamServerVariableLabelNames, constLabels), "health_checks_checks": newStreamUpstreamServerMetric(namespace, "health_checks_checks", "Total health check requests", streamUpstreamServerVariableLabelNames, constLabels),
"health_checks_fails": newStreamUpstreamServerMetric(namespace, "health_checks_fails", "Failed health checks", streamUpstreamServerVariableLabelNames, constLabels), "health_checks_fails": newStreamUpstreamServerMetric(namespace, "health_checks_fails", "Failed health checks", streamUpstreamServerVariableLabelNames, constLabels),
"health_checks_unhealthy": newStreamUpstreamServerMetric(namespace, "health_checks_unhealthy", "How many times the server became unhealthy (state 'unhealthy')", streamUpstreamServerVariableLabelNames, constLabels), "health_checks_unhealthy": newStreamUpstreamServerMetric(namespace, "health_checks_unhealthy", "How many times the server became unhealthy (state 'unhealthy')", streamUpstreamServerVariableLabelNames, constLabels),
"ssl_handshakes": newStreamUpstreamServerMetric(namespace, "ssl_handshakes", "Successful SSL handshakes", streamUpstreamServerVariableLabelNames, constLabels),
"ssl_handshakes_failed": newStreamUpstreamServerMetric(namespace, "ssl_handshakes_failed", "Failed SSL handshakes", streamUpstreamServerVariableLabelNames, constLabels),
"ssl_session_reuses": newStreamUpstreamServerMetric(namespace, "ssl_session_reuses", "Session reuses during SSL handshake", streamUpstreamServerVariableLabelNames, constLabels),
}, },
streamZoneSyncMetrics: map[string]*prometheus.Desc{ streamZoneSyncMetrics: map[string]*prometheus.Desc{
"bytes_in": newStreamZoneSyncMetric(namespace, "bytes_in", "Bytes received by this node", constLabels), "bytes_in": newStreamZoneSyncMetric(namespace, "bytes_in", "Bytes received by this node", constLabels),
@@ -679,7 +691,12 @@ func (c *NginxPlusCollector) Collect(ch chan<- prometheus.Metric) {
prometheus.CounterValue, float64(zone.Responses.Codes.HTTPGatewayTimeOut), labelValues...) prometheus.CounterValue, float64(zone.Responses.Codes.HTTPGatewayTimeOut), labelValues...)
ch <- prometheus.MustNewConstMetric(c.serverZoneMetrics["codes_507"], ch <- prometheus.MustNewConstMetric(c.serverZoneMetrics["codes_507"],
prometheus.CounterValue, float64(zone.Responses.Codes.HTTPInsufficientStorage), labelValues...) prometheus.CounterValue, float64(zone.Responses.Codes.HTTPInsufficientStorage), labelValues...)
ch <- prometheus.MustNewConstMetric(c.serverZoneMetrics["ssl_handshakes"],
prometheus.CounterValue, float64(zone.SSL.Handshakes), labelValues...)
ch <- prometheus.MustNewConstMetric(c.serverZoneMetrics["ssl_handshakes_failed"],
prometheus.CounterValue, float64(zone.SSL.HandshakesFailed), labelValues...)
ch <- prometheus.MustNewConstMetric(c.serverZoneMetrics["ssl_session_reuses"],
prometheus.CounterValue, float64(zone.SSL.SessionReuses), labelValues...)
} }
for name, zone := range stats.StreamServerZones { for name, zone := range stats.StreamServerZones {
@@ -711,6 +728,12 @@ func (c *NginxPlusCollector) Collect(ch chan<- prometheus.Metric) {
prometheus.CounterValue, float64(zone.Received), labelValues...) prometheus.CounterValue, float64(zone.Received), labelValues...)
ch <- prometheus.MustNewConstMetric(c.streamServerZoneMetrics["sent"], ch <- prometheus.MustNewConstMetric(c.streamServerZoneMetrics["sent"],
prometheus.CounterValue, float64(zone.Sent), labelValues...) prometheus.CounterValue, float64(zone.Sent), labelValues...)
ch <- prometheus.MustNewConstMetric(c.streamServerZoneMetrics["ssl_handshakes"],
prometheus.CounterValue, float64(zone.SSL.Handshakes), labelValues...)
ch <- prometheus.MustNewConstMetric(c.streamServerZoneMetrics["ssl_handshakes_failed"],
prometheus.CounterValue, float64(zone.SSL.HandshakesFailed), labelValues...)
ch <- prometheus.MustNewConstMetric(c.streamServerZoneMetrics["ssl_session_reuses"],
prometheus.CounterValue, float64(zone.SSL.SessionReuses), labelValues...)
} }
for name, upstream := range stats.Upstreams { for name, upstream := range stats.Upstreams {
@@ -859,6 +882,12 @@ func (c *NginxPlusCollector) Collect(ch chan<- prometheus.Metric) {
prometheus.CounterValue, float64(peer.Responses.Codes.HTTPGatewayTimeOut), labelValues...) prometheus.CounterValue, float64(peer.Responses.Codes.HTTPGatewayTimeOut), labelValues...)
ch <- prometheus.MustNewConstMetric(c.upstreamServerMetrics["codes_507"], ch <- prometheus.MustNewConstMetric(c.upstreamServerMetrics["codes_507"],
prometheus.CounterValue, float64(peer.Responses.Codes.HTTPInsufficientStorage), labelValues...) prometheus.CounterValue, float64(peer.Responses.Codes.HTTPInsufficientStorage), labelValues...)
ch <- prometheus.MustNewConstMetric(c.upstreamServerMetrics["ssl_handshakes"],
prometheus.CounterValue, float64(peer.SSL.Handshakes), labelValues...)
ch <- prometheus.MustNewConstMetric(c.upstreamServerMetrics["ssl_handshakes_failed"],
prometheus.CounterValue, float64(peer.SSL.HandshakesFailed), labelValues...)
ch <- prometheus.MustNewConstMetric(c.upstreamServerMetrics["ssl_session_reuses"],
prometheus.CounterValue, float64(peer.SSL.SessionReuses), labelValues...)
} }
ch <- prometheus.MustNewConstMetric(c.upstreamMetrics["keepalives"], ch <- prometheus.MustNewConstMetric(c.upstreamMetrics["keepalives"],
prometheus.GaugeValue, float64(upstream.Keepalives), name) prometheus.GaugeValue, float64(upstream.Keepalives), name)
@@ -923,6 +952,12 @@ func (c *NginxPlusCollector) Collect(ch chan<- prometheus.Metric) {
ch <- prometheus.MustNewConstMetric(c.streamUpstreamServerMetrics["health_checks_unhealthy"], ch <- prometheus.MustNewConstMetric(c.streamUpstreamServerMetrics["health_checks_unhealthy"],
prometheus.CounterValue, float64(peer.HealthChecks.Unhealthy), labelValues...) prometheus.CounterValue, float64(peer.HealthChecks.Unhealthy), labelValues...)
} }
ch <- prometheus.MustNewConstMetric(c.streamUpstreamServerMetrics["ssl_handshakes"],
prometheus.CounterValue, float64(peer.SSL.Handshakes), labelValues...)
ch <- prometheus.MustNewConstMetric(c.streamUpstreamServerMetrics["ssl_handshakes_failed"],
prometheus.CounterValue, float64(peer.SSL.HandshakesFailed), labelValues...)
ch <- prometheus.MustNewConstMetric(c.streamUpstreamServerMetrics["ssl_session_reuses"],
prometheus.CounterValue, float64(peer.SSL.SessionReuses), labelValues...)
} }
ch <- prometheus.MustNewConstMetric(c.streamUpstreamMetrics["zombies"], ch <- prometheus.MustNewConstMetric(c.streamUpstreamMetrics["zombies"],
prometheus.GaugeValue, float64(upstream.Zombies), name) prometheus.GaugeValue, float64(upstream.Zombies), name)