Lot's of assumptions here:
* We want separate module (we don't have processes on how to version it and release).
* We want to expose generated protos, without gogo.
Signed-off-by: bwplotka <bwplotka@gmail.com>
* client: Add Option to provide limit query param for APIs that support it
Signed-off-by: Ivan Ryabov <abbyssoul@gmail.com>
* Renamed formatOptions -> addOptionalURLParams and comment as per review feedback
Signed-off-by: Ivan Ryabov <abbyssoul@gmail.com>
---------
Signed-off-by: Ivan Ryabov <abbyssoul@gmail.com>
The upstream prometheus HTTP API supports POSTS for these methods (the
same as Query and QueryRange). Similar to the original issue
(https://github.com/prometheus/client_golang/issues/428) we can hit 414
errors with these other APIs. This change simply duplicates the logic to
these other endpoints
Related to: https://github.com/jacksontj/promxy/issues/588
Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>
For one, this pulls up the histogram-related json-iterator usage from
prometheus/common into the API client. Previously, the only
json-iterater usage was here in the API client. But then json-iterator
was used for the native histogram additions directly in
prometheus/common, see
https://github.com/prometheus/common/pull/440/files . This however
meant that any user of prometheus/common/model would now link in
json-iterator, even if they are not using the JSON marshaling at
all. To keep prometheus/common/model more leightweight, this commit
moves all the json-iterator usage into the API client itself, as it
was done before for the normal float samples.
This commit also adds an unmarshaling function for native histograms,
which didn't even exist in prometheus/common/model so far.
It also adds json-iterator marshaling and un-marshaling for
model.SampleStream, which is only needed for the benchmark
(BenchmarkSamplesJsonSerialization). This fixes the benchmark such
that it actually compares json-iterator and std-lib json encoding
(which didn't work before because the custom marshaling methods of
model.SampleStream enforced std-lib json encoding for floats and
json-iterator encoding for histograms in all cases).
I expect this to fix#1179.
Signed-off-by: beorn7 <beorn@grafana.com>
* Add new Go 1.19 metrics
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
* Format files with the latest formatter
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
* fix assorted oddities found by golangci-lint
Signed-off-by: Christoph Mewes <christoph@kubermatic.com>
* permanently enable the linters
Signed-off-by: Christoph Mewes <christoph@kubermatic.com>
* post-rebase blues
Signed-off-by: Christoph Mewes <christoph@kubermatic.com>
* Add timeout parameter for queries
Signed-off-by: Joseph Woodward <joseph.woodward@xeuse.com>
* Update api/prometheus/v1/api.go
Co-authored-by: Kemal Akkoyun <kakkoyun@users.noreply.github.com>
Signed-off-by: Joseph Woodward <joseph.woodward@xeuse.com>
* Update api/prometheus/v1/api.go
Co-authored-by: Kemal Akkoyun <kakkoyun@users.noreply.github.com>
Signed-off-by: Joseph Woodward <joseph.woodward@xeuse.com>
* Pass timeout as stringified time.Duration instead of millisecond value
Signed-off-by: Joseph Woodward <joseph.woodward@xeuse.com>
* Update QueryRange API to support timeouts
Signed-off-by: Joseph Woodward <joseph.woodward@xeuse.com>
* Add timeout to test request params
Signed-off-by: Joseph Woodward <joseph.woodward@xeuse.com>
Co-authored-by: Kemal Akkoyun <kakkoyun@users.noreply.github.com>
* Make Query requests idempotent
Address #1020.
Signed-off-by: Tomáš Dohnálek <dohnto@gmail.com>
* Use empty header
Signed-off-by: Tomáš Dohnálek <dohnto@gmail.com>
* Document issue with original documentation
Signed-off-by: Tomáš Dohnálek <dohnto@gmail.com>
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>
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>
* 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>
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>
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>