Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAlertMethod ¶ added in v0.1.55
func NewAlertMethod(config *AlertMethodConfig) (alert.Method, error)
NewAlertMethod returns a new *AlertMethod or a non-nil error if there was an error.
Types ¶
type AlertMethod ¶ added in v0.1.55
type AlertMethod struct {
// contains filtered or unexported fields
}
AlertMethod implements the alert.AlertMethod interface for writing new alerts to a file.
func (*AlertMethod) Write ¶ added in v0.1.55
Write creates JSON-formatted logs from the records and writes them to the file specified at the creation of the AlertMethod. If there was an error writing logs to disk, it returns a non-nil error.
Example ¶
records := []*alert.Record{
{
Filter: "hits.hits._source",
Text: `Lorem ipsum dolor sit amet...`,
},
{
Filter: "aggregation.hostname.buckets",
Fields: []*alert.Field{
{
Key: "foo",
Count: 2,
},
{
Key: "bar",
Count: 3,
},
},
},
}
fm, err := NewAlertMethod(&AlertMethodConfig{
OutputFilepath: "testdata/results.log",
})
if err != nil {
fmt.Printf("error creating new *AlertMethod: %v", err)
return
}
err = fm.Write(context.Background(), "Test Rule", records)
if err != nil {
fmt.Printf("error writing data to file: %v", err)
return
}
type AlertMethodConfig ¶ added in v0.1.55
type AlertMethodConfig struct {
// OutputFilepath is the file where logs will be written
OutputFilepath string `mapstructure:"file"`
}
AlertMethodConfig configures to what file alerts will be written.
Click to show internal directories.
Click to hide internal directories.