-
Notifications
You must be signed in to change notification settings - Fork 179
/
stats.go
119 lines (111 loc) · 4.49 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
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
// SPDX-License-Identifier: MIT OR Apache-2.0
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"),
Cliq: getOutputNewMap("cliq"),
Rocketchat: getOutputNewMap("rocketchat"),
Mattermost: getOutputNewMap("mattermost"),
Teams: getOutputNewMap("teams"),
Webex: getOutputNewMap("webex"),
Datadog: getOutputNewMap("datadog"),
Discord: getOutputNewMap("discord"),
Alertmanager: getOutputNewMap("alertmanager"),
Elasticsearch: getOutputNewMap("elasticsearch"),
Quickwit: getOutputNewMap("quickwit"),
Loki: getOutputNewMap("loki"),
SumoLogic: getOutputNewMap("sumologic"),
Nats: getOutputNewMap("nats"),
Stan: getOutputNewMap("stan"),
Influxdb: getOutputNewMap("influxdb"),
AWSLambda: getOutputNewMap("awslambda"),
AWSSQS: getOutputNewMap("awssqs"),
AWSSNS: getOutputNewMap("awssns"),
AWSCloudWatchLogs: getOutputNewMap("awscloudwatchlogs"),
AWSS3: getOutputNewMap("awss3"),
AWSSecurityLake: getOutputNewMap("awssecuritylake"),
AWSKinesis: getOutputNewMap("awskinesis"),
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"),
Tekton: getOutputNewMap("tekton"),
WebUI: getOutputNewMap("webui"),
Rabbitmq: getOutputNewMap("rabbitmq"),
Wavefront: getOutputNewMap("wavefront"),
Fission: getOutputNewMap("fission"),
Grafana: getOutputNewMap("grafana"),
GrafanaOnCall: getOutputNewMap("grafanaoncall"),
YandexS3: getOutputNewMap("yandexs3"),
YandexDataStreams: getOutputNewMap("yandexdatastreams"),
Syslog: getOutputNewMap("syslog"),
MQTT: getOutputNewMap("mqtt"),
Spyderbat: getOutputNewMap("spyderbat"),
PolicyReport: getOutputNewMap("policyreport"),
NodeRed: getOutputNewMap("nodered"),
Zincsearch: getOutputNewMap("zincsearch"),
Gotify: getOutputNewMap("gotify"),
TimescaleDB: getOutputNewMap("timescaledb"),
Redis: getOutputNewMap("redis"),
Telegram: getOutputNewMap("telegram"),
N8N: getOutputNewMap("n8n"),
OpenObserve: getOutputNewMap("openobserve"),
Dynatrace: getOutputNewMap("dynatrace"),
OTLPTraces: getOutputNewMap("otlptraces"),
Talon: getOutputNewMap("talon"),
}
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
}