-
Notifications
You must be signed in to change notification settings - Fork 277
Expand file tree
/
Copy pathtypes.go
More file actions
133 lines (109 loc) · 4.76 KB
/
types.go
File metadata and controls
133 lines (109 loc) · 4.76 KB
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
124
125
126
127
128
129
130
131
132
133
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package metrics
import (
"github.com/microsoft/retina/pkg/log"
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/zap"
)
const (
// Control plane metrics
pluginManagerFailedToReconcileCounterName = "plugin_manager_failed_to_reconcile"
lostEventsCounterName = "lost_events_counter"
parsedPacketsCounterName = "parsed_packets_counter"
// Windows
hnsStats = "windows_hns_stats"
hnsStatsDescription = "Include many different metrics from packets sent/received to closed connections"
// Linux only metrics (for now).
nodeApiServerHandshakeLatencyHistName = "node_apiserver_handshake_latency_ms"
// Metric Descriptions
dropPacketsGaugeDescription = "Total dropped packets"
dropBytesGaugeDescription = "Total dropped bytes"
forwardPacketsGaugeDescription = "Total forwarded packets"
forwardBytesGaugeDescription = "Total forwarded bytes"
nodeConnectivityStatusGaugeDescription = "The last observed status of both ICMP and HTTP connectivity between the current Cilium agent and other Cilium nodes"
nodeConnectivityLatencySecondsGaugeDescription = "The last observed latency between the current Cilium agent and other Cilium nodes in seconds"
tcpStateGaugeDescription = "Number of active TCP connections by state"
tcpConnectionRemoteGaugeDescription = "Number of active TCP connections by remote address"
tcpConnectionStatsGaugeDescription = "TCP connections statistics"
tcpFlagGaugeDescription = "TCP gauges by flag"
ipConnectionStatsGaugeDescription = "IP connections statistics"
udpConnectionStatsGaugeDescription = "UDP connections statistics"
interfaceStatsGaugeDescription = "Interface statistics"
nodeAPIServerHandshakeLatencyDesc = "Histogram depicting latency of the TCP handshake between nodes and Kubernetes API server measured in milliseconds"
dnsRequestCounterDescription = "DNS requests by statistics"
dnsResponseCounterDescription = "DNS responses by statistics"
infinibandStatsGaugeDescription = "InfiniBand statistics gauge"
infinibandStatusParamsGaugeDescription = "InfiniBand Status Parameters gauge"
// Control plane metrics
pluginManagerFailedToReconcileCounterDescription = "Number of times the plugin manager failed to reconcile the plugins"
lostEventsCounterDescription = "Number of events lost in control plane"
parsedPacketsCounterDescription = "Number of packets parsed by the packetparser plugin"
// Conntrack metrics
ConntrackPacketTxDescription = "Number of tx packets"
ConntrackPacketRxDescription = "Number of rx packets"
ConntrackBytesTxDescription = "Number of tx bytes"
ConntrackBytesRxDescription = "Number of rx bytes"
ConntrackTotalConnectionsDescription = "Total number of connections"
// Build info
BuildInfoDescription = "Retina build information"
)
// Metric Counters
var (
// Prevent re-initialization
isInitialized bool
// Common gauges across os distributions
DropPacketsGauge GaugeVec
DropBytesGauge GaugeVec
ForwardPacketsGauge GaugeVec
ForwardBytesGauge GaugeVec
// Windows
HNSStatsGauge GaugeVec
// Common gauges across os distributions
NodeConnectivityStatusGauge GaugeVec
NodeConnectivityLatencyGauge GaugeVec
// TCP Stats
TCPStateGauge GaugeVec
TCPConnectionRemoteGauge GaugeVec
TCPConnectionStatsGauge GaugeVec
TCPFlagGauge GaugeVec
// IP States
IPConnectionStatsGauge GaugeVec
// UDP Stats
UDPConnectionStatsGauge GaugeVec
// Interface Stats
InterfaceStatsGauge GaugeVec
metricsLogger *log.ZapLogger
// Control Plane Metrics
PluginManagerFailedToReconcileCounter CounterVec
LostEventsCounter CounterVec
ParsedPacketsCounter CounterVec
// DNS Metrics.
DNSRequestCounter CounterVec
DNSResponseCounter CounterVec
InfinibandStatsGauge GaugeVec
InfinibandStatusParamsGauge GaugeVec
// Conntrack
ConntrackPacketsTx GaugeVec
ConntrackPacketsRx GaugeVec
ConntrackBytesTx GaugeVec
ConntrackBytesRx GaugeVec
ConntrackTotalConnections GaugeVec
// Build Info
BuildInfo GaugeVec
)
func ToPrometheusType(metric interface{}) prometheus.Collector {
if metric != nil {
return nil
}
switch m := metric.(type) {
case GaugeVec:
return m.(*prometheus.GaugeVec)
case CounterVec:
return m.(*prometheus.CounterVec)
default:
metricsLogger.Error("error converting unknown metric type", zap.Any("metric", m))
return nil
}
}
type DropReasonType uint32