Commit Graph

71 Commits

Author SHA1 Message Date
Tomáš Dohnálek 40e54a75a6 Refactor apiClientImpl.DoGetFallback
Make apiClientImpl.DoGetFallback more idiomatic and efficient:
 * Save result of args.Encode() operation as it might be used 2 times in
   the function and due to looping and sorting it might be heavy.
 * Follow line-of-sight practise and therefore simplify the code.

Signed-off-by: Tomáš Dohnálek <dohnto@gmail.com>
2022-04-07 09:18:32 +02:00
Łukasz Mierzwa dc1559e8ef
Update /api/v1/status/tsdb to include headStats (#925)
Current structs for v1 HTTP API assume that there is chunkCount and timeSeriesCount on /api/v1/status/runtimeinfo, which seems to be gone for at least a few releases. /api/v1/status/tsdb now holds an extra headStats block with chunkCount, numSeries and a few other fields.
Update API models and tests to reflect this change.

Signed-off-by: Łukasz Mierzwa <l.mierzwa@gmail.com>
2022-01-05 10:09:29 +01:00
Ben Ye 440c09d3ec support wal replay status api
Signed-off-by: Ben Ye <ben.ye@bytedance.com>
2021-12-04 22:19:58 -08:00
yeya24 7a147c1bdf add exemplars API support
Signed-off-by: yeya24 <yb532204897@gmail.com>
2021-04-24 00:32:14 -04:00
Björn Rabenstein 4a22844c5d
Merge pull request #856 from yeya24/targets-field
Add missing fields to targets API
2021-04-12 22:30:20 +02:00
yeya24 45efe82b46 add missing fields to targets API
Signed-off-by: yeya24 <yb532204897@gmail.com>
2021-04-11 12:05:08 -04:00
Goutham Veeramachaneni 629f64ab3f
Add newer fields to Rules API
Signed-off-by: Goutham Veeramachaneni <gouthamve@gmail.com>
2021-04-11 12:17:26 +02:00
Björn Rabenstein 3cd398565b
Merge pull request #843 from prometheus/beorn7/release
Update dependencies
2021-03-13 18:46:33 +01:00
Kien Nguyen 4c24ae8b13 Add buildinfo method
Co-authored-by: Lili Cosic <cosiclili@gmail.com>
Signed-off-by: Kien Nguyen <kiennt2609@gmail.com>
2021-03-12 08:36:23 +07:00
beorn7 a60c63e313 Update dependencies
Signed-off-by: beorn7 <beorn@grafana.com>
2021-03-11 20:22:47 +01:00
yeya24 595a1d580c update comment
Signed-off-by: yeya24 <yb532204897@gmail.com>
2021-02-03 19:44:12 -05:00
yeya24 75d7516f2a support matchers in labels API
Signed-off-by: yeya24 <yb532204897@gmail.com>
2020-12-29 13:49:42 -05:00
Bartlomiej Plotka 39b478e90c
Added example api code showing how to add auth tokens and user agents to prom client. (#817)
* Added example api code showing how to add auth tokens and user agents to prom client.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Ran go mod tidy.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
2020-11-20 19:58:16 +00:00
beorn7 64b4a9cf9d API client: Enable fallback on status code 501, too
When discussing #801, I remembered #794. While dealing with the
latter, I read the HTTP RFC, stumbling upon the following:

    When a request method is received
    that is unrecognized or not implemented by an origin server, the
    origin server SHOULD respond with the 501 (Not Implemented) status
    code.  When a request method is received that is known by an origin
    server but not allowed for the target resource, the origin server
    SHOULD respond with the 405 (Method Not Allowed) status code.

Concluding from that, it is possible that a server desiring a fallback
to GET will send a status code of 501. It is even preferred if that
server does not offer any resource to be used with the POST method.

Therefore, I think we should fallback to GET on a 501, too.

Signed-off-by: beorn7 <beorn@grafana.com>
2020-09-10 13:14:07 +02:00
johncming 32a545bf61 Replace with the standard library constant.
Signed-off-by: johncming <johncming@yahoo.com>
2020-08-22 19:36:13 +08:00
Maximilian Gaß b0cdec211b
Use time.Time for timestamps in Runtimeinfo (#777)
Signed-off-by: Maximilian Gaß <m.gass@babiel.com>
2020-06-24 16:55:36 +01:00
Hima Varsha 6cd29bd38a
Add support for tsdb endpoint (#773)
Signed-off-by: Hima Varsha <hdureddy@apple.com>
2020-06-24 12:35:25 +01:00
yeya24 94ae5774fd fix time parameter propagation in labels API
Signed-off-by: yeya24 <yb532204897@gmail.com>
2020-06-19 18:57:25 -04:00
Augustin Husson 3defbd9c7c add start/end parameter for LabelValues
Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
2020-06-11 16:05:23 +02:00
Augustin Husson 6ce5f2ca8a add start/end parameter for LabelNames
Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
2020-06-11 13:02:32 +02:00
Lili Cosic 6c43f2ebc2 api/prometheus/v1/api_test.go: Add test case for runtimeinfo endpoint
Signed-off-by: Lili Cosic <cosiclili@gmail.com>
2020-05-18 20:12:53 +02:00
Lili Cosic c9e3c020a9 api/prometheus/v1/api.go: Add support for /runtimeinfo endpoint
Signed-off-by: Lili Cosic <cosiclili@gmail.com>
2020-05-18 20:12:53 +02:00
huanggze 8f87c69651
Improve API error handling
Signed-off-by: huanggze <loganhuang@yunify.com>
2020-04-02 16:02:06 +08:00
gotjosh 2463b8e78d Address review feedback
Signed-off-by: gotjosh <josue@grafana.com>
2020-02-28 09:49:39 +00:00
gotjosh 7810669cc3 Update api/prometheus/v1/api_test.go
Co-Authored-By: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: gotjosh <josue@grafana.com>
2020-02-27 17:52:05 +00:00
gotjosh bd79fe1bf1 Update api/prometheus/v1/api_test.go
Co-Authored-By: Tobias Guggenmos <tguggenm@redhat.com>
Signed-off-by: gotjosh <josue@grafana.com>
2020-02-27 17:52:05 +00:00
gotjosh 7f509dc4f4 API Client: Support new metadata endpoint in v1
Introduces support for the new metadata endpoint from Prometheus. The new endpoint provides information independent of targets and collapses the unique combinations of HELP, TYPE and UNIT.

Fixes #705

Signed-off-by: gotjosh <josue@grafana.com>
2020-02-26 17:48:57 +00:00
Joe Elliott 88792b1169 Moved warnings into apiclient
Signed-off-by: Joe Elliott <number101010@gmail.com>
2019-12-11 10:04:00 -05:00
Joe Elliott bd858421cd Fixed TestDoGetFallback test
Signed-off-by: Joe Elliott <number101010@gmail.com>
2019-12-11 09:36:49 -05:00
Joe Elliott 393adc9261 Refactor ~worked. All tests passing except one
Signed-off-by: Joe Elliott <number101010@gmail.com>
2019-12-10 16:53:38 -05:00
Joe Elliott 7f4279992e First pass unravel
Signed-off-by: Joe Elliott <number101010@gmail.com>
2019-12-10 15:16:44 -05:00
Beni Cherniavsky-Paskin 38c67520a3 api client examples: avoid shadowing package with variable
Signed-off-by: Beni Cherniavsky-Paskin <cben@redhat.com>
2019-12-09 14:55:16 +02:00
beorn7 b8308329f0 Fix function names in API examples
The part after the underscore has to be lowercase. Otherwise, it is
seen as the name of a Go type, which doesn't exist, which will result
in the example not showing up in godoc.

Signed-off-by: beorn7 <beorn@grafana.com>
2019-10-15 13:43:53 +02:00
Guangming Wang 49b3f23433 remove duplicated assignment in v1/api.go (#647)
Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
2019-10-02 00:47:28 +03:00
Chris Marchbanks 48fdc3021b
Provide godoc examples for using the api
Closes #194

Signed-off-by: Chris Marchbanks <csmarchbanks@gmail.com>
2019-08-07 20:53:38 -06:00
Thomas Jackson cd27091e79 Handle formatting when the time in nanoseconds requires more than a single int64
Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>

Fixup for #617
2019-07-09 09:23:52 -07:00
Thomas Jackson 9b5568b9ab Pass all precision instead of artificially limiting
Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
2019-07-09 07:31:37 -07:00
Thomas Jackson c52580de2b Change all time formatting to UTC and off of time.RFC3339Nano
Prometheus has issues parsing RFC3339Nano timestamps if the year has more than 4 digits, in addition it is the second-pass parse attempt. Since this is a client library and the interface is a `time.Time` it makes sense that we pick the clearest simplest format-- so I propose we use the `model.Time` representation of time in our communications to prometheus. This (1) removes the issues with timezones in those queries going downstream and (2) completely works around this #614 issue as the parsing mechanism in prometheus can handle those times in this format.

Related to #614

Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
2019-07-09 07:31:37 -07:00
Thomas Jackson 3d8379da8f Add Warnings to LabelValues and LabelNames (#609)
Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
2019-06-17 21:27:57 +03:00
Thomas Jackson 063470a3c9 Add warnings to series (#603)
Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
2019-06-15 00:28:28 +03:00
Thomas Jackson f213ad9bfc Add /labels API to client (#604)
API ref https://prometheus.io/docs/prometheus/latest/querying/api/#getting-label-names

Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
2019-06-14 16:49:58 +02:00
Thomas Jackson 1335ef46bd Pass warnings through on non-error responses (#599)
Return warnings as a separate string slice to simplify handling.

Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
2019-06-14 01:40:59 +02:00
Krasi Georgiev f6e51267db remove the tsdb dependancy
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
2019-05-28 15:42:25 +03:00
Yao Zengzeng 329278ec53 encapsulate target metadata api (#590)
Signed-off-by: YaoZengzeng <yaozengzeng@zju.edu.cn>
2019-05-28 14:27:09 +02:00
Alex Salt 301aa8906b /api/v1/rules: alert value as string (#585)
Signed-off-by: Alexander Saltykov <alexander-s@yandex-team.ru>
2019-05-28 13:57:09 +02:00
Thomas Jackson 7e60220fd3 Switch from encoding/json -> jsoniter (#570)
* Switch from encoding/json -> jsoniter

Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
2019-05-28 13:45:06 +02:00
Thomas Jackson d5f3c8d55d Add storage.Warnings to client
Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>

Fixes #560
2019-05-21 07:36:05 -07:00
Thomas Jackson 3f6cbd9560 Remove encode of params in query before DoGetFallback (#563)
Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
2019-05-01 09:28:05 +03:00
Thomas Jackson a4daf0098c Implement POST with get fallback for Query/QueryRange (#557)
* Implement POST with get fallback for Query/QueryRange

Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
2019-04-30 10:13:48 +03:00
Bjoern Rabenstein 1173d73405 Increase minimum required Go version to 1.9
This allows us to simplify a bunch of code while still supporting the
last four Go minor versions.

We have also run into minor annoyances a couple of times by now to
keep supporting 1.7 and 1.8.

It's time to pull the plug!

Signed-off-by: Bjoern Rabenstein <bjoern@rabenste.in>
2019-04-28 23:28:57 +02:00