-
Notifications
You must be signed in to change notification settings - Fork 14
/
auto.go
123 lines (119 loc) · 4.86 KB
/
auto.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* skogul, receiver automation
*
* Copyright (c) 2019 Telenor Norge AS
* Author(s):
* - Kristian Lyngstøl <kly@kly.no>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
/*
Package receiver provides various skogul Receivers that accept data and
execute a handler. They are the "inbound" API of Skogul.
*/
package receiver
import (
"github.com/telenornms/skogul"
)
// Auto maps names to Receivers to allow auto configuration
var Auto skogul.ModuleMap
func init() {
Auto.Add(skogul.Module{
Name: "http",
Aliases: []string{"https"},
Alloc: func() interface{} { return &HTTP{} },
Help: "Listen for metrics on HTTP or HTTPS. Optionally requiring authentication. Each request received is passed to a handler, and a single HTTP receiver can listen for multiple formats depending on URL used.",
Extras: []interface{}{HTTPAuth{}},
})
Auto.Add(skogul.Module{
Name: "file",
Alloc: func() interface{} { return &File{} },
Help: "Reads from a file, then stops. Assumes one collection per line. E.g.: If the file has json data, the each line has to be a self-contained document/container.",
})
Auto.Add(skogul.Module{
Name: "wholefile",
Aliases: []string{"wfile"},
Alloc: func() interface{} { return &WholeFile{} },
Help: "Reads an entire file and parses it as a single container, optionally repeatedly.",
})
Auto.Add(skogul.Module{
Name: "fifo",
Alloc: func() interface{} { return &LineFile{} },
Help: "Reads continuously from a file. Can technically read from any file, but since it will re-open and re-read the file upon EOF, it is best suited for reading a fifo. Assumes one collection per line.",
})
Auto.Add(skogul.Module{
Name: "fileadvanced",
Aliases: []string{"filea"},
Alloc: func() interface{} { return &LineFileAdvanced{} },
Help: "Reads a file line by line. Assumes one collection per line. Renames the file after reading it, and optionally executes a shell command (e.g.: reload a service or send SIGHUP).",
})
Auto.Add(skogul.Module{
Name: "logrus",
Aliases: []string{"log"},
Alloc: func() interface{} { return &LogrusLog{} },
Help: "Attaches to the internal logging of Skogul and diverts log messages.",
})
Auto.Add(skogul.Module{
Name: "mqtt",
Alloc: func() interface{} { return &MQTT{} },
Help: "Listen for Skogul-formatted JSON on a MQTT endpoint.",
})
Auto.Add(skogul.Module{
Name: "nats",
Alloc: func() interface{} { return &Nats{} },
Help: "Connect to a Nats.io server/cluster and subscribe to a subject.",
})
Auto.Add(skogul.Module{
Name: "stats",
Alloc: func() interface{} { return &Stats{} },
Help: "Gather internal Skogul metrics and send them on to the specified handler. Metrics gathered depends on modules used, and verbosity and completeness also depends on the modules. Examples of metrics gathered are: parse errors, send errors, number of received messages.",
})
Auto.Add(skogul.Module{
Name: "stdin",
Alloc: func() interface{} { return &Stdin{} },
Help: "Reads from standard input, one collection per line, allowing you to pipe collections to Skogul on a command line or similar.",
})
Auto.Add(skogul.Module{
Name: "test",
Alloc: func() interface{} { return &Tester{} },
Help: "Generate dummy-data. Useful for testing, including in combination with the http sender to send dummy-data to an other skogul instance.",
})
Auto.Add(skogul.Module{
Name: "tcp",
Alloc: func() interface{} { return &TCPLine{} },
Help: "Listen for data on a tcp socket, reading one collection per line.",
})
Auto.Add(skogul.Module{
Name: "sql",
Alloc: func() interface{} { return &SQL{} },
Help: "Periodically poll a database for information. Single threaded.",
})
Auto.Add(skogul.Module{
Name: "udp",
Alloc: func() interface{} { return &UDP{} },
Help: "Accept UDP messages, one UDP message is one container. Combine with protobuf parser to receive Juniper telemetry.",
})
Auto.Add(skogul.Module{
Name: "kafka",
Alloc: func() interface{} { return &Kafka{} },
Help: "Connect to a Kafka topic and consume messages.",
})
Auto.Add(skogul.Module{
Name: "rabbitmq",
Alloc: func() interface{} { return &Rabbitmq{} },
Help: "Connect to a Rabbitmq topic and consume messages.",
})
}