-
Notifications
You must be signed in to change notification settings - Fork 224
/
Copy pathtypes.go
123 lines (101 loc) · 4.36 KB
/
types.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
// 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"
// 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
dropCountTotalDescription = "Total dropped packets"
dropBytesTotalDescription = "Total dropped bytes"
forwardCountTotalDescription = "Total forwarded packets"
forwardBytesTotalDescription = "Total forwarded bytes"
nodeConnectivityStatusDescription = "The last observed status of both ICMP and HTTP connectivity between the current Cilium agent and other Cilium nodes"
nodeConnectivityLatencySecondsDescription = "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"
tcpConnectionStatsDescription = "TCP connections Statistics"
tcpFlagCountersDescription = "TCP counters by flag"
ipConnectionStatsDescription = "IP connections Statistics"
udpConnectionStatsDescription = "UDP connections Statistics"
udpActiveSocketsCounterDescription = "number of active UDP sockets"
interfaceStatsDescription = "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"
infinibandCounterStatsDescription = "InfiniBand Counter Statistics"
infinibandStatusParamsDescription = "InfiniBand Status Parameters"
flowPacketForwardDescription = "Number of forward packets per flow"
flowPacketReplyDescription = "Number of reply packets per flow"
flowBytesForwardDescription = "Number of forward bytes per flow"
flowBytesReplyDescription = "Number of reply bytes per flow"
// Control plane metrics
pluginManagerFailedToReconcileCounterDescription = "Number of times the plugin manager failed to reconcile the plugins"
lostEventsCounterDescription = "Number of events lost in control plane"
)
// Metric Counters
var (
// Prevent re-initialization
isInitialized bool
// Common counters across os distributions
DropCounter IGaugeVec
DropBytesCounter IGaugeVec
ForwardCounter IGaugeVec
ForwardBytesCounter IGaugeVec
WindowsCounter IGaugeVec
// Common gauges across os distributions
NodeConnectivityStatusGauge IGaugeVec
NodeConnectivityLatencyGauge IGaugeVec
// TCP Stats
TCPStateGauge IGaugeVec
TCPConnectionRemoteGauge IGaugeVec
TCPConnectionStats IGaugeVec
TCPFlagCounters IGaugeVec
// IP States
IPConnectionStats IGaugeVec
// UDP Stats
UDPConnectionStats IGaugeVec
UDPActiveSocketsCounter IGaugeVec
// Interface Stats
InterfaceStats IGaugeVec
metricsLogger *log.ZapLogger
// Control Plane Metrics
PluginManagerFailedToReconcileCounter ICounterVec
LostEventsCounter ICounterVec
// DNS Metrics.
DNSRequestCounter ICounterVec
DNSResponseCounter ICounterVec
InfinibandCounterStats IGaugeVec
InfinibandStatusParams IGaugeVec
FlowPacketsForward IGaugeVec
FlowPacketsReply IGaugeVec
FlowBytesForward IGaugeVec
FlowBytesReply IGaugeVec
)
func ToPrometheusType(metric interface{}) prometheus.Collector {
if metric != nil {
return nil
}
switch m := metric.(type) {
case IGaugeVec:
return m.(*prometheus.GaugeVec)
case ICounterVec:
return m.(*prometheus.CounterVec)
case IHistogramVec:
return m.(prometheus.Histogram)
default:
metricsLogger.Error("error converting unknown metric type", zap.Any("metric", m))
return nil
}
}
type DropReasonType uint32