forked from falcosecurity/falcosidekick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.go
94 lines (87 loc) · 3.31 KB
/
stats.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
package main
import (
"expvar"
"fmt"
"runtime"
"github.com/falcosecurity/falcosidekick/outputs"
"github.com/falcosecurity/falcosidekick/types"
)
func getInitStats() *types.Statistics {
expvar.Publish("goroutines", expvar.Func(func() interface{} {
return fmt.Sprintf("%d", runtime.NumGoroutine())
}))
expvar.Publish("cpu", expvar.Func(func() interface{} {
return fmt.Sprintf("%d", runtime.NumCPU())
}))
stats = &types.Statistics{
Requests: getInputNewMap("requests"),
FIFO: getInputNewMap("fifo"),
GRPC: getInputNewMap("grpc"),
Falco: expvar.NewMap("falco.priority"),
Slack: getOutputNewMap("slack"),
Rocketchat: getOutputNewMap("rocketchat"),
Mattermost: getOutputNewMap("mattermost"),
Teams: getOutputNewMap("teams"),
Datadog: getOutputNewMap("datadog"),
Discord: getOutputNewMap("discord"),
Alertmanager: getOutputNewMap("alertmanager"),
Elasticsearch: getOutputNewMap("elasticsearch"),
Loki: getOutputNewMap("loki"),
Nats: getOutputNewMap("nats"),
Stan: getOutputNewMap("stan"),
Influxdb: getOutputNewMap("influxdb"),
AWSLambda: getOutputNewMap("awslambda"),
AWSSQS: getOutputNewMap("awssqs"),
AWSSNS: getOutputNewMap("awssns"),
AWSCloudWatchLogs: getOutputNewMap("awscloudwatchlogs"),
AWSS3: getOutputNewMap("awss3"),
SMTP: getOutputNewMap("smtp"),
Opsgenie: getOutputNewMap("opsgenie"),
Statsd: getOutputNewMap("statsd"),
Dogstatsd: getOutputNewMap("dogstatsd"),
Webhook: getOutputNewMap("webhook"),
CloudEvents: getOutputNewMap("cloudevents"),
AzureEventHub: getOutputNewMap("azureeventhub"),
GCPPubSub: getOutputNewMap("gcppubsub"),
GCPStorage: getOutputNewMap("gcpstorage"),
GCPCloudFunctions: getOutputNewMap("gcpcloudfunctions"),
GCPCloudRun: getOutputNewMap("gcpcloudrun"),
GoogleChat: getOutputNewMap("googlechat"),
Kafka: getOutputNewMap("kafka"),
KafkaRest: getOutputNewMap("kafkarest"),
Pagerduty: getOutputNewMap("pagerduty"),
Kubeless: getOutputNewMap("kubeless"),
Openfaas: getOutputNewMap("openfaas"),
WebUI: getOutputNewMap("webui"),
Rabbitmq: getOutputNewMap("rabbitmq"),
Wavefront: getOutputNewMap("wavefront"),
Fission: getOutputNewMap("fission"),
Grafana: getOutputNewMap("grafana"),
YandexS3: getOutputNewMap("yandexs3"),
Syslog: getOutputNewMap("Syslog"),
}
stats.Falco.Add(outputs.Emergency, 0)
stats.Falco.Add(outputs.Alert, 0)
stats.Falco.Add(outputs.Critical, 0)
stats.Falco.Add(outputs.Error, 0)
stats.Falco.Add(outputs.Warning, 0)
stats.Falco.Add(outputs.Notice, 0)
stats.Falco.Add(outputs.Informational, 0)
stats.Falco.Add(outputs.Debug, 0)
stats.Falco.Add(outputs.None, 0)
return stats
}
func getInputNewMap(s string) *expvar.Map {
e := expvar.NewMap("inputs." + s)
e.Add(outputs.Total, 0)
e.Add(outputs.Rejected, 0)
e.Add(outputs.Accepted, 0)
return e
}
func getOutputNewMap(s string) *expvar.Map {
e := expvar.NewMap("outputs." + s)
e.Add(outputs.Total, 0)
e.Add(outputs.Error, 0)
e.Add(outputs.OK, 0)
return e
}