/
events.go
37 lines (30 loc) · 1.04 KB
/
events.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT
package logs
import "github.com/aws/amazon-cloudwatch-agent/tool/runtime"
type Events struct {
EventConfigs []*EventConfig
}
func (config *Events) ToMap(ctx *runtime.Context) (string, map[string]interface{}) {
resultMap := make(map[string]interface{})
collectList := []map[string]interface{}{}
for i := range config.EventConfigs {
_, singleEvent := config.EventConfigs[i].ToMap(ctx)
collectList = append(collectList, singleEvent)
}
resultMap["collect_list"] = collectList
return "windows_events", resultMap
}
func (config *Events) AddWindowsEvent(eventName, logGroupName, logStreamName, eventFormat string, eventLevls []string) {
if config.EventConfigs == nil {
config.EventConfigs = []*EventConfig{}
}
singleEvent := &EventConfig{
EventName: eventName,
LogGroup: logGroupName,
LogStream: logStreamName,
EventFormat: eventFormat,
EventLevels: eventLevls,
}
config.EventConfigs = append(config.EventConfigs, singleEvent)
}