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