| 76 | } |
| 77 | |
| 78 | func newIPVSCollector(logger *slog.Logger) (*ipvsCollector, error) { |
| 79 | var ( |
| 80 | c ipvsCollector |
| 81 | err error |
| 82 | subsystem = "ipvs" |
| 83 | ) |
| 84 | |
| 85 | if c.backendLabels, err = c.parseIpvsLabels(*ipvsLabels); err != nil { |
| 86 | return nil, err |
| 87 | } |
| 88 | |
| 89 | c.logger = logger |
| 90 | c.fs, err = procfs.NewFS(*procPath) |
| 91 | if err != nil { |
| 92 | return nil, fmt.Errorf("failed to open procfs: %w", err) |
| 93 | } |
| 94 | |
| 95 | c.connections = typedDesc{prometheus.NewDesc( |
| 96 | prometheus.BuildFQName(namespace, subsystem, "connections_total"), |
| 97 | "The total number of connections made.", |
| 98 | nil, nil, |
| 99 | ), prometheus.CounterValue} |
| 100 | c.incomingPackets = typedDesc{prometheus.NewDesc( |
| 101 | prometheus.BuildFQName(namespace, subsystem, "incoming_packets_total"), |
| 102 | "The total number of incoming packets.", |
| 103 | nil, nil, |
| 104 | ), prometheus.CounterValue} |
| 105 | c.outgoingPackets = typedDesc{prometheus.NewDesc( |
| 106 | prometheus.BuildFQName(namespace, subsystem, "outgoing_packets_total"), |
| 107 | "The total number of outgoing packets.", |
| 108 | nil, nil, |
| 109 | ), prometheus.CounterValue} |
| 110 | c.incomingBytes = typedDesc{prometheus.NewDesc( |
| 111 | prometheus.BuildFQName(namespace, subsystem, "incoming_bytes_total"), |
| 112 | "The total amount of incoming data.", |
| 113 | nil, nil, |
| 114 | ), prometheus.CounterValue} |
| 115 | c.outgoingBytes = typedDesc{prometheus.NewDesc( |
| 116 | prometheus.BuildFQName(namespace, subsystem, "outgoing_bytes_total"), |
| 117 | "The total amount of outgoing data.", |
| 118 | nil, nil, |
| 119 | ), prometheus.CounterValue} |
| 120 | c.backendConnectionsActive = typedDesc{prometheus.NewDesc( |
| 121 | prometheus.BuildFQName(namespace, subsystem, "backend_connections_active"), |
| 122 | "The current active connections by local and remote address.", |
| 123 | c.backendLabels, nil, |
| 124 | ), prometheus.GaugeValue} |
| 125 | c.backendConnectionsInact = typedDesc{prometheus.NewDesc( |
| 126 | prometheus.BuildFQName(namespace, subsystem, "backend_connections_inactive"), |
| 127 | "The current inactive connections by local and remote address.", |
| 128 | c.backendLabels, nil, |
| 129 | ), prometheus.GaugeValue} |
| 130 | c.backendWeight = typedDesc{prometheus.NewDesc( |
| 131 | prometheus.BuildFQName(namespace, subsystem, "backend_weight"), |
| 132 | "The current backend weight by local and remote address.", |
| 133 | c.backendLabels, nil, |
| 134 | ), prometheus.GaugeValue} |
| 135 | |