The remote write path differs based on whether the data source is actually
Prometheus, Mimir, Cortex, or an older version of Cortex. We do not want
users to have to specify the path, so this change determines the path as
best it can.
It may be in the future we have to make this configurable per-datasource
to cater for setups where it's impossible to determine the correct path.
The change to use WriteDatasource was done in a previous commit, this adds a
test case using DatasourceWriter, in addition to the one using PrometheusWriter.
* Alerting: Implement arbitrary data source remote writer.
Recording rules currently remote write to the endpoint speficied in the
configuration file, but we want to change this so that it can be specified
on a per-rule basis. This change implements the updated RemoteWriter
interface, and dispatches writes to the correct data source.
Notes about the implementation:
- There is a defaulting behaviour, because we will need to handle situations
when upgrading from older Grafana versions, where recording rules do not a
data source target specified.
- In order to avoid re-creating the remote write clients for every request,
a cache is used. The entries have a TTL of 30 seconds at which point they
are recreated; this is the delay for picking up new data source settings.
Known limitations:
- There is no per data source configuration for the remote write path suffix.
- Not all data source settings will be used, but basic auth and TLS will be.
- There is no RBAC. This will be a follow up feature.
* Lint
* Alerting: Refactor NewPrometheusWriter function.
In order to re-use PrometheusWriter, changing the function take a
PrometheusWriterConfig instead of RecordingRulesSettings, and adapt the old
interface onto the new interface.
* Make linter happy
Extend the recording rule definition to include the target data source, allowing
configuration of where the output of the recording rule is written to. Also
extends the relevant interfaces in preparation for the next set of changes.
* Add success case and tests for writer using metrics
* Use testable version of clock
* Assert a specific series was written
* Fix linter
* Fix manually constructed writer
* Create some integration testing infra for RRs
* whoops
* Require no error in responding
* fix linter
* Panic, no need to pass testing around
* Extend status test