* Add initial sketch of Codec interface.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Introduce JSON codec.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Expose Response type so that consuming applications (eg. Mimir) can implement their own Codecs.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Add sketch of what supporting different codecs could look like.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Rename fallbackCodec to defaultCodec.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Remove defaultCodec as a field on API.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Rename AddCodec() and clarify expected behaviour.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Modify TestRespond to test JsonCodec directly.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Refactor existing respond() test in preparation for content negotiation test cases.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Add tests for content negotiation.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Add missing documentation comments.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Add another test case.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Rename JsonCodec to JSONCodec.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Fix linting issue.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Fallback to JSON codec if no acceptable codec can be found for the Accept header.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Move custom jsoniter code into json_codec.go.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
---------
Signed-off-by: Charles Korn <charles.korn@grafana.com>
This commit adds a new 'keep_firing_for' field to Prometheus alerting
rules. The 'resolve_delay' field specifies the minimum amount of time
that an alert should remain firing, even if the expression does not
return any results.
This feature was discussed at a previous dev summit, and it was
determined that a feature like this would be useful in order to allow
the expression time to stabilize and prevent confusing resolved messages
from being propagated through Alertmanager.
This approach is simpler than having two PromQL queries, as was
sometimes discussed, and it should be easy to implement.
This commit does not include tests for the 'resolve_delay' field. This
is intentional, as the purpose of this commit is to gather comments on
the proposed design of the 'resolve_delay' field before implementing
tests. Once the design of the 'resolve_delay' field has been finalized,
a follow-up commit will be submitted with tests."
See https://github.com/prometheus/prometheus/issues/11570
Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
In most cases, there is no sample at `maxt`, so `PeekBack` has to be
used. So far, `PeekBack` did not return a float histogram, and we
disregarded even any returned normal histogram. This fixes both, and
also tweaks the unit test to discover the problem (by using an earlier
timestamp than "now" for the samples in the TSDB).
Signed-off-by: beorn7 <beorn@grafana.com>
* Add API endpoints for getting scrape pool names
This adds api/v1/scrape_pools endpoint that returns the list of *names* of all the scrape pools configured.
Having it allows to find out what scrape pools are defined without having to list and parse all targets.
The second change is adding scrapePool query parameter support in api/v1/targets endpoint, that allows to
filter returned targets by only finding ones for passed scrape pool name.
Both changes allow to query for a specific scrape pool data, rather than getting all the targets for all possible scrape pools.
The problem with api/v1/targets endpoint is that it returns huge amount of data if you configure a lot of scrape pools.
Signed-off-by: Łukasz Mierzwa <l.mierzwa@gmail.com>
* Add a scrape pool selector on /targets page
Current targets page lists all possible targets. This works great if you only have a few scrape pools configured,
but for systems with a lot of scrape pools and targets this slow things down a lot.
Not only does the /targets page load very slowly in such case (waiting for huge API response) but it also take
a long time to render, due to huge number of elements.
This change adds a dropdown selector so it's possible to select only intersting scrape pool to view.
There's also scrapePool query param that will open selected pool automatically.
Signed-off-by: Łukasz Mierzwa <l.mierzwa@gmail.com>
Signed-off-by: Łukasz Mierzwa <l.mierzwa@gmail.com>
Use `FromStrings` instead of assuming the data structure.
And don't sort individual labels, since `labels.Labels` are always sorted.
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Patterned after `Chunk.Iterator()`: pass the old iterator in so it
can be re-used to avoid allocating a new object.
(This commit does not do any re-use; it is just changing all the method
signatures so re-use is possible in later commits.)
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
We have 2 bugfixes, one which is important for Windows users and
another one on native histograms. I think it is worth cutting another
bugfix release before 2.41 comes out.
Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>