Documentation ¶
Index ¶
- Variables
- func DoGetRequest(u string, auth config.AuthConfig) ([]byte, error)
- func NewMulti(errs ...error) multiError
- func ParseAndGroupAlerts(b []byte) (map[string][]v1.Alert, error)
- func ParseAndGroupMetrics(b []byte) (map[string][]promql.Sample, error)
- func ParseAndGroupRules(b []byte) (map[string]*v1.RuleGroup, error)
- type AlertMessageParser
- type Alerts
- type Data
- type GETAlertsResponse
- type GETMetricsResponse
- type GETRulesResponse
- type Metrics
- type RemoteWriter
- type RuleGroup
- type TestSuite
- type TestSuiteOptions
- type Vector
Constants ¶
This section is empty.
Variables ¶
var AlertMessageParsers = map[string]AlertMessageParser{ "default": func(b []byte) ([]notifier.Alert, error) { var alerts []notifier.Alert err := json.Unmarshal(b, &alerts) return alerts, err }, "alertmanager": func(b []byte) ([]notifier.Alert, error) { msg := webhook.Message{} err := json.Unmarshal(b, &msg) if err != nil { return nil, err } alerts := make([]notifier.Alert, 0, len(msg.Alerts)) for _, al := range msg.Alerts { alerts = append(alerts, notifier.Alert{ Labels: labels.FromMap(al.Labels), Annotations: labels.FromMap(al.Annotations), StartsAt: al.StartsAt, EndsAt: al.EndsAt, GeneratorURL: al.GeneratorURL, }) } return alerts, nil }, }
AlertMessageParsers is a map of the parser name to the parser function. The parser name is the one to be used in the config file. You can extend this map to include your custom parser and it will be matched with the config file.
Functions ¶
func DoGetRequest ¶
func DoGetRequest(u string, auth config.AuthConfig) ([]byte, error)
TODO: add retries and set some timeouts.
func NewMulti ¶
func NewMulti(errs ...error) multiError
NewMulti returns multiError with provided errors added if not nil.
func ParseAndGroupAlerts ¶
ParseAndGroupAlerts parses the alerts and groups by the rule group name. The alerts are assumed to have a `rulegroup` label.
func ParseAndGroupMetrics ¶
ParseAndGroupMetrics parses samples and groups by the rule group name. The metrics are assumed to have a `rulegroup` label.
Types ¶
type GETAlertsResponse ¶
type GETMetricsResponse ¶
type GETRulesResponse ¶
type RemoteWriter ¶
type RemoteWriter struct {
// contains filtered or unexported fields
}
RemoteWriter remote writes the time series provided AddTimeSeries() in sorted fashion w.r.t. the timestamps.
func NewRemoteWriter ¶
func (*RemoteWriter) AddTimeSeries ¶
func (rw *RemoteWriter) AddTimeSeries(ts []prompb.TimeSeries)
AddTimeSeries adds more timeseries to the queue. The timestamp of the samples should be 0 based. It should not be called after calling Start().
func (*RemoteWriter) Error ¶
func (rw *RemoteWriter) Error() error
func (*RemoteWriter) Start ¶
func (rw *RemoteWriter) Start() time.Time
Start starts remote-writing the given timeseries. It returns the time corresponding to the 0 timestamp.
func (*RemoteWriter) Stop ¶
func (rw *RemoteWriter) Stop()
func (*RemoteWriter) Wait ¶
func (rw *RemoteWriter) Wait()
type TestSuite ¶
type TestSuite struct {
// contains filtered or unexported fields
}
TestSuite runs the entire test suite from start to end.
func NewTestSuite ¶
func NewTestSuite(opts TestSuiteOptions) (*TestSuite, error)
func (*TestSuite) Error ¶
Error() returns any error occured during execution of test and does not tell if the tests passed or failed.
func (*TestSuite) WasTestSuccessful ¶
WasTestSuccessful tells if all the tests passed. It returns an explanation if any test failed. Before calling this method:
- Error() should be checked for no errors.
- The test should have finished (i.e. Wait() is not blocking).