Skip to content
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

Merged
merged 5 commits into from
Oct 15, 2018
Merged

Add stream metrics support #16

merged 5 commits into from
Oct 15, 2018

Conversation

Dean-Coakley
Copy link
Contributor

Proposed changes

Closes: #1

  • Add Stream upstream metrics
  • Add Stream Server Zone metrics
  • Add Stream Server metrics
  • Update documentation to include stream documentation

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING guide
  • I have proven my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have ensured the README is up to date
  • I have rebased my branch onto master
  • I will ensure my PR is targeting the master branch and pulling from my branch on my own fork

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
@Dean-Coakley Dean-Coakley added the enhancement Pull requests for new features/feature enhancements label Oct 9, 2018
@Dean-Coakley Dean-Coakley self-assigned this Oct 9, 2018
Copy link
Contributor

@pleshakov pleshakov left a 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

"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"}),
Copy link
Contributor

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

"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"),
Copy link
Contributor

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.

"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"),
Copy link
Contributor

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

"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"),
Copy link
Contributor

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

"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"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove downtime metric

Copy link
Contributor Author

@Dean-Coakley Dean-Coakley Oct 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pleshakov

ch <- prometheus.MustNewConstMetric(c.streamUpstreamServerMetrics["downtime"],
here too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

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)
Copy link
Contributor

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`.
Copy link
Contributor

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

@Dean-Coakley Dean-Coakley merged commit a365950 into master Oct 15, 2018
@Dean-Coakley Dean-Coakley deleted the add-stream-metrics branch October 15, 2018 07:00
isserrano pushed a commit that referenced this pull request Oct 16, 2018
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Pull requests for new features/feature enhancements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants