forked from ahjdzx/libbeat
-
Notifications
You must be signed in to change notification settings - Fork 1
/
outputs.go
77 lines (66 loc) · 1.53 KB
/
outputs.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package outputs
import (
"time"
"github.com/johann8384/libbeat/common"
)
type MothershipConfig struct {
Enabled bool
Save_topology bool
Host string
Port int
Hosts []string
Protocol string
Username string
Password string
Index string
Path string
Db int
Db_topology int
Topic string
Timeout int
Reconnect_interval int
Filename string
Rotate_every_kb int
Number_of_files int
DataType string
Flush_interval *int
Bulk_size *int
Max_retries *int
}
// Functions to be exported by a output plugin
type OutputInterface interface {
// Initialize the output plugin
Init(config MothershipConfig, topology_expire int) error
// Register the agent name and its IPs to the topology map
PublishIPs(name string, localAddrs []string) error
// Get the agent name with a specific IP from the topology map
GetNameByIP(ip string) string
// Publish event
PublishEvent(ts time.Time, event common.MapStr) error
}
// Output identifier
type OutputPlugin uint16
// Output constants
const (
UnknownOutput OutputPlugin = iota
RedisOutput
ElasticsearchOutput
FileOutput
KafkaOutput
StdOutput
)
// Output names
var OutputNames = []string{
"unknown",
"redis",
"elasticsearch",
"file",
"kafka",
"stdout",
}
func (o OutputPlugin) String() string {
if int(o) >= len(OutputNames) {
return "impossible"
}
return OutputNames[o]
}