-
Notifications
You must be signed in to change notification settings - Fork 340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add stream metrics support #16
Conversation
Closes: #1 * Add streamUpstream metrics * Add streamUpstreamServer metrics * Add streamServerZone metrics
* Help descriptor must be the same for all metrics, so Session descriptions must be the same regardless of label * Reused upstreamState for streamUpstreamStates * newStreamUpstreamServer no longer takes label arguments as it is not required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my suggestions
collector/nginx_plus.go
Outdated
"sessions_2xx": newStreamServerZoneMetric(namespace, "sessions", "Total sessions completed", prometheus.Labels{"code": "2xx"}), | ||
"sessions_4xx": newStreamServerZoneMetric(namespace, "sessions", "Total sessions completed", prometheus.Labels{"code": "4xx"}), | ||
"sessions_5xx": newStreamServerZoneMetric(namespace, "sessions", "Total sessions completed", prometheus.Labels{"code": "5xx"}), | ||
"sessions_total": newStreamServerZoneMetric(namespace, "sessions", "Total sessions completed", prometheus.Labels{"code": "total"}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not required. the total number can be obtained in Prometheus by aggregating 2xx,4xx,5xx
Also, see responses metrics for http zones
collector/nginx_plus.go
Outdated
"state": newStreamUpstreamServerMetric(namespace, "state", "Current state"), | ||
"active": newStreamUpstreamServerMetric(namespace, "active", "Active connections"), | ||
"sent": newStreamUpstreamServerMetric(namespace, "sent", "Bytes sent to this server"), | ||
"received": newStreamUpstreamServerMetric(namespace, "received", "Bytes received to this server"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> Bytes received from this server.
collector/nginx_plus.go
Outdated
"unavail": newStreamUpstreamServerMetric(namespace, "unavail", "How many times the server became unavailable for client connections (state 'unavail') due to the number of unsuccessful attempts reaching the max_fails threshold"), | ||
"connections": newStreamUpstreamServerMetric(namespace, "connections", "Total number of client connections forwarded to this server"), | ||
"connect_time": newStreamUpstreamServerMetric(namespace, "connect_time", "Average time to connect to the upstream server"), | ||
"first_byte_time": newStreamUpstreamServerMetric(namespace, "first_byte_time", "The average time to receive the first byte of data"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> Average time to receive the first byte of data
collector/nginx_plus.go
Outdated
"connections": newStreamUpstreamServerMetric(namespace, "connections", "Total number of client connections forwarded to this server"), | ||
"connect_time": newStreamUpstreamServerMetric(namespace, "connect_time", "Average time to connect to the upstream server"), | ||
"first_byte_time": newStreamUpstreamServerMetric(namespace, "first_byte_time", "The average time to receive the first byte of data"), | ||
"response_time": newStreamUpstreamServerMetric(namespace, "response_time", "Average time to get the full response from the server"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> Average time to receive the last byte of data
collector/nginx_plus.go
Outdated
"health_checks_checks": newStreamUpstreamServerMetric(namespace, "health_checks_checks", "Total health check requests"), | ||
"health_checks_fails": newStreamUpstreamServerMetric(namespace, "health_checks_fails", "Failed health checks"), | ||
"health_checks_unhealthy": newStreamUpstreamServerMetric(namespace, "health_checks_unhealthy", "How many times the server became unhealthy (state 'unhealthy')"), | ||
"downtime": newStreamUpstreamServerMetric(namespace, "downtime", "Total time the server was in the 'unavail', 'checking', and 'unhealthy' states"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove downtime metric
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ch <- prometheus.MustNewConstMetric(c.streamUpstreamServerMetrics["downtime"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
collector/nginx_plus.go
Outdated
ch <- prometheus.MustNewConstMetric(c.streamUpstreamServerMetrics["active"], | ||
prometheus.GaugeValue, float64(peer.Active), name, peer.Server) | ||
ch <- prometheus.MustNewConstMetric(c.streamUpstreamServerMetrics["connections"], | ||
prometheus.GaugeValue, float64(peer.Connections), name, peer.Server) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Counter
README.md
Outdated
* [HTTP Upsteams](http://nginx.org/en/docs/http/ngx_http_api_module.html#def_nginx_http_upstream). Note: for the `state` metric, the string values are converted to float64 using the following rule: `"up"` -> `1.0`, `"draining"` -> `2.0`, `"down"` -> `3.0`, `"unavail"` –> `4.0`, `"checking"` –> `5.0`, `"unhealthy"` -> `6.0`. | ||
* [Stream Upsteams](http://nginx.org/en/docs/http/ngx_http_api_module.html#def_nginx_stream_upstream). Note: for the `state` metric, the string values are converted to float64 using the following rule: `"up"` -> `1.0`, `"down"` -> `3.0`, `"unavail"` –> `4.0`, `"checking"` –> `5.0`, `"unhealthy"` -> `6.0`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upsteams -> Upstreams
please fix for http as well
Closes: #1 * Add streamUpstream metrics * Add streamUpstreamServer metrics * Add streamServerZone metrics * Metric descriptor must be the same for every metric with the same metricName, so Metric descriptions must be the same regardless of label * Add stream metrics documentation to readme * Fix readme typo Upsteams->Upstreams
Proposed changes
Closes: #1
Checklist
Before creating a PR, run through this checklist and mark each as complete.