-
Notifications
You must be signed in to change notification settings - Fork 721
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 query metric http api #1957
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1957 +/- ##
=========================================
Coverage ? 77.89%
=========================================
Files ? 171
Lines ? 16894
Branches ? 0
=========================================
Hits ? 13159
Misses ? 2717
Partials ? 1018
Continue to review full report at Codecov.
|
470501d
to
584bf2a
Compare
## the metric storage is the cluster metric storage. This is use for query metric data. | ||
## Currently we use prometheus as metric storage, we may use PD/TiKV as metric storage later. | ||
## For usability, recommended to temporarily set it to the prometheus address, eg: http://127.0.0.1:9090 | ||
metric-storage = "" |
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.
It sounds like a kind of storage, but actually it is an address.
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.
Ye, I already talk with @lonng , @siddontang, they prefer this. :)
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.
how about metric-storage-url
?
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 usage of metric-storage
will not only indicate the url address
.
Hi @crazycs520 , you need to update API docs too. See https://github.com/pingcap/pd/blob/master/docs/development.md#changing-apis |
@@ -144,6 +144,9 @@ func createRouter(prefix string, svr *server.Server) *mux.Router { | |||
rootRouter.Handle("/api/v1/health", newHealthHandler(svr, rd)).Methods("GET") | |||
rootRouter.Handle("/api/v1/diagnose", newDiagnoseHandler(svr, rd)).Methods("GET") | |||
rootRouter.HandleFunc("/api/v1/ping", func(w http.ResponseWriter, r *http.Request) {}).Methods("GET") | |||
// metric query use to query metric data, the protocol is compatible with prometheus. | |||
rootRouter.Handle("/api/v1/metric/query", newQueryMetric(svr)).Methods("GET", "POST") |
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.
need to update the API documentation in api.raml
.
## the metric storage is the cluster metric storage. This is use for query metric data. | ||
## Currently we use prometheus as metric storage, we may use PD/TiKV as metric storage later. | ||
## For usability, recommended to temporarily set it to the prometheus address, eg: http://127.0.0.1:9090 | ||
metric-storage = "" |
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.
how about metric-storage-url
?
@@ -144,6 +144,9 @@ func createRouter(prefix string, svr *server.Server) *mux.Router { | |||
rootRouter.Handle("/api/v1/health", newHealthHandler(svr, rd)).Methods("GET") | |||
rootRouter.Handle("/api/v1/diagnose", newDiagnoseHandler(svr, rd)).Methods("GET") | |||
rootRouter.HandleFunc("/api/v1/ping", func(w http.ResponseWriter, r *http.Request) {}).Methods("GET") | |||
// metric query use to query metric data, the protocol is compatible with prometheus. | |||
rootRouter.Handle("/api/v1/metric/query", newQueryMetric(svr)).Methods("GET", "POST") | |||
rootRouter.Handle("/api/v1/metric/query_range", newQueryMetric(svr)).Methods("GET", "POST") |
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.
It seem to be more restful to use query-range
or range
?
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.
@lhy1024 query_range
is compatible with Prometheus api. https://prometheus.io/docs/prometheus/latest/querying/api/
Co-Authored-By: lhy1024 <admin@liudos.us>
…into metric-redirection
What problem does this PR solve?
/pd/api/v1/metric/query
.metric-query-address
config item to indicate the metric query address.This is for pingcap/tidb#13567 project.
What is changed and how it works?
Currently, PD does not support query metric by itself, so just redirect the metric query to
metric-query-address
. After PD support storage metric data, PD can handle the query request by itself.metric-query-address
should be dynamic adjustment. Because the user can choose which metric data should be read. So I add this config item inpd-server
for dynamic adjustment.Check List
Tests
Code changes
Side effects
Related changes