-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[WIP] Add metrics endpoint to watchdog #688
Conversation
Uses Prometheus client library. This commit is WIP and will need to be altered to provide RED metrics in the format expected by K8s HPAv2 / Weave Cloud / Prometheus operator. Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
@stefanprodan can you link back to the RED metrics format with the histogram/counter expected by the tooling? |
These are the Prometheus metrics names and format that the tooling expects: HPA v2 counter := prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: "http",
Name: "requests_total",
Help: "The total number of HTTP requests.",
},
[]string{"status"},
) RED histogram := prometheus.NewHistogramVec(prometheus.HistogramOpts{
Subsystem: "http",
Name: "request_duration_seconds",
Help: "Seconds spent serving HTTP requests.",
Buckets: prometheus.DefBuckets,
}, []string{"method", "path", "status"}) A full example of a HTTP server instrumentation can be found here https://github.com/stefanprodan/k8s-podinfo/blob/master/pkg/server/instrument.go |
} | ||
|
||
promHTTP := prometheus.Handler() | ||
http.Handle("/_/metrics", promHTTP) |
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.
The recommend way of exposing the metrics
endpoint is with github.com/prometheus/client_golang/prometheus/promhttp
. The handler should be http.Handle("/_/metrics", promhttp.Handler())
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.
This was put out for discussion and you didn't raise an issue with it.
We agreed to use a private namespace for the routes of /_/
so that it could not clash with the function in the container. Same for the health endpoint.
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.
I think there was a reason I moved back to this version of the handler. How to the metrics get registered and associated with the first method/approach?
@alexellis and @stefanprodan is this something we still want to do? |
Yes |
Derek close: replaced by #1151 |
Signed-off-by: Alex Ellis (VMware) alexellis2@gmail.com
Description
Uses Prometheus client library. This commit is WIP and will need
to be altered to provide RED metrics in the format expected by
K8s HPAv2 / Weave Cloud / Prometheus operator.
By collecting metrics at the watchdog level we can enable Kubernetes HPAv2 to work on requests/per/second.
Motivation and Context
#583 #532
How Has This Been Tested?
WIP - shows that the metrics are showing up.
Types of changes
Checklist:
git commit -s