mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
36 lines
857 B
Go
36 lines
857 B
Go
package historian
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/infra/log"
|
|
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
|
"github.com/grafana/grafana/pkg/services/ngalert/state"
|
|
)
|
|
|
|
type remoteLokiClient interface {
|
|
ping() error
|
|
}
|
|
|
|
type RemoteLokiBackend struct {
|
|
client remoteLokiClient
|
|
log log.Logger
|
|
}
|
|
|
|
func NewRemoteLokiBackend(cfg LokiConfig) *RemoteLokiBackend {
|
|
logger := log.New("ngalert.state.historian", "backend", "loki")
|
|
return &RemoteLokiBackend{
|
|
client: newLokiClient(cfg, logger),
|
|
log: logger,
|
|
}
|
|
}
|
|
|
|
func (h *RemoteLokiBackend) TestConnection() error {
|
|
return h.client.ping()
|
|
}
|
|
|
|
func (h *RemoteLokiBackend) RecordStatesAsync(ctx context.Context, _ *models.AlertRule, _ []state.StateTransition) {
|
|
logger := h.log.FromContext(ctx)
|
|
logger.Debug("Remote Loki state history backend was called with states")
|
|
}
|