|
|
@@ -1,31 +1,106 @@
|
|
|
1
|
+// Stats package has implementations of events.Observers for different
|
|
|
2
|
+// monitoring systems.
|
|
|
3
|
+//
|
|
|
4
|
+// Observer is a consumer of events produced by mtg. Consumers, defined
|
|
|
5
|
+// in this package, process these events and provide information used by
|
|
|
6
|
+// different monitoring system or time series databases.
|
|
1
|
7
|
package stats
|
|
2
|
8
|
|
|
3
|
9
|
const (
|
|
|
10
|
+ // DefaultMetricPrefix defines a base prefix for all metrics.
|
|
4
|
11
|
DefaultMetricPrefix = "mtg"
|
|
5
|
12
|
|
|
|
13
|
+ // DefaultStatsdMetricPrefix defines a base prefix for metrics
|
|
|
14
|
+ // which are passed to statsd.
|
|
6
|
15
|
DefaultStatsdMetricPrefix = DefaultMetricPrefix + "."
|
|
7
|
|
- DefaultStatsdTagFormat = "datadog"
|
|
8
|
16
|
|
|
9
|
|
- MetricClientConnections = "client_connections"
|
|
10
|
|
- MetricTelegramConnections = "telegram_connections"
|
|
|
17
|
+ // DefaultStatsdTagFormat defines a format of tags for statsd
|
|
|
18
|
+ // observer.
|
|
|
19
|
+ DefaultStatsdTagFormat = "datadog"
|
|
|
20
|
+
|
|
|
21
|
+ // MetricClientConnections defines a metric which is responsible for a
|
|
|
22
|
+ // number of currently active connections established by client.
|
|
|
23
|
+ //
|
|
|
24
|
+ // Type: gauge
|
|
|
25
|
+ // Tags:
|
|
|
26
|
+ // ip_family | A type of ip (ipv4 or ipv6) of the client.
|
|
|
27
|
+ MetricClientConnections = "client_connections"
|
|
|
28
|
+
|
|
|
29
|
+ // MetricTelegramConnections defines a metric which is responsible for
|
|
|
30
|
+ // a count of active connections to Telegram servers.
|
|
|
31
|
+ //
|
|
|
32
|
+ // Type: gauge
|
|
|
33
|
+ // Tags:
|
|
|
34
|
+ // telegram_ip | IP address of the telegram server.
|
|
|
35
|
+ // dc | Index of the datacenter to connect to.
|
|
|
36
|
+ MetricTelegramConnections = "telegram_connections"
|
|
|
37
|
+
|
|
|
38
|
+ // MetricDomainFrontingConnections defines a metric which is
|
|
|
39
|
+ // responsible for a count of active connections to a fronting domain.
|
|
|
40
|
+ // Fronting domain is that one that is encoded in a secret.
|
|
|
41
|
+ //
|
|
|
42
|
+ // Type: gauge
|
|
|
43
|
+ // Tags:
|
|
|
44
|
+ // ip_family | A type of IP (ipv4 or ipv6) that was used.
|
|
11
|
45
|
MetricDomainFrontingConnections = "domain_fronting_connections"
|
|
12
|
46
|
|
|
13
|
|
- MetricTelegramTraffic = "telegram_traffic"
|
|
|
47
|
+ // MetricTelegramTraffic defines a metric for traffic (in bytes) that
|
|
|
48
|
+ // is sent to and from Telegram servers.
|
|
|
49
|
+ //
|
|
|
50
|
+ // Type: counter
|
|
|
51
|
+ // Tags:
|
|
|
52
|
+ // telegram_ip | IP address of the telegram server.
|
|
|
53
|
+ // dc | Index of the datacenter
|
|
|
54
|
+ // direction | Direction of the traffc flow. Values are
|
|
|
55
|
+ // | 'to_client' and 'from_client'
|
|
|
56
|
+ MetricTelegramTraffic = "telegram_traffic"
|
|
|
57
|
+
|
|
|
58
|
+ // MetricDomainFrontingTraffic defines a metric for traffic (in bytes)
|
|
|
59
|
+ // that is sent to and from fronting domain.
|
|
|
60
|
+ //
|
|
|
61
|
+ // Type: counter
|
|
|
62
|
+ // Tags:
|
|
|
63
|
+ // direction | Direction of the traffc flow. Values are
|
|
|
64
|
+ // | 'to_client' and 'from_client'
|
|
14
|
65
|
MetricDomainFrontingTraffic = "domain_fronting_traffic"
|
|
15
|
66
|
|
|
16
|
|
- MetricDomainFronting = "domain_fronting"
|
|
|
67
|
+ // MetricDomainFronting defines a metric for a number of domain
|
|
|
68
|
+ // fronting routing events.
|
|
|
69
|
+ //
|
|
|
70
|
+ // Type: counter
|
|
|
71
|
+ MetricDomainFronting = "domain_fronting"
|
|
|
72
|
+
|
|
|
73
|
+ // MetricConcurrencyLimited defines a metric for a count of events,
|
|
|
74
|
+ // when the client was blocked due to the concurrency limit.
|
|
|
75
|
+ //
|
|
|
76
|
+ // Type: counter
|
|
17
|
77
|
MetricConcurrencyLimited = "concurrency_limited"
|
|
18
|
|
- MetricIPBlocklisted = "ip_blocklisted"
|
|
19
|
|
- MetricReplayAttacks = "replay_attacks"
|
|
20
|
78
|
|
|
|
79
|
+ // MetricIPBlocklisted defines a metric for a count of events, when
|
|
|
80
|
+ // client was blocked because her IP address was found in blocklists.
|
|
|
81
|
+ //
|
|
|
82
|
+ // Type: counter
|
|
|
83
|
+ MetricIPBlocklisted = "ip_blocklisted"
|
|
|
84
|
+
|
|
|
85
|
+ // MetricReplayAttacks defines a metric for a count of events, when
|
|
|
86
|
+ // mtg has detected a replay attack. Just a reminder: mtg immediately
|
|
|
87
|
+ // routes a connection to a fronting domain if such event is detected.
|
|
|
88
|
+ //
|
|
|
89
|
+ // Type: counter
|
|
|
90
|
+ MetricReplayAttacks = "replay_attacks"
|
|
|
91
|
+
|
|
|
92
|
+ // TagIPFamily defines a name of the 'ip_family' tag and all values.
|
|
21
|
93
|
TagIPFamily = "ip_family"
|
|
22
|
94
|
TagIPFamilyIPv4 = "ipv4"
|
|
23
|
95
|
TagIPFamilyIPv6 = "ipv6"
|
|
24
|
96
|
|
|
|
97
|
+ // TagTelegramIP defines a name of the 'telegram_ip' tag.
|
|
25
|
98
|
TagTelegramIP = "telegram_ip"
|
|
26
|
99
|
|
|
|
100
|
+ // TagDC defines a name of the 'dc' tag.
|
|
27
|
101
|
TagDC = "dc"
|
|
28
|
102
|
|
|
|
103
|
+ // TagDirection defines a name of the 'direction' tag.
|
|
29
|
104
|
TagDirection = "direction"
|
|
30
|
105
|
TagDirectionToClient = "to_client"
|
|
31
|
106
|
TagDirectionFromClient = "from_client"
|