@@ -60,7 +60,7 @@ func newProxyCollector(proto string) (*proxyCollector, error) {
6060 prometheus.CounterOpts {
6161 Name : "data_bytes_per_location" ,
6262 Help : "Bytes transferred by the proxy, per location" ,
63- }, []string {"proto" , "dir" , "location" , "asn" }).CurryWith (map [string ]string {"proto" : proto })
63+ }, []string {"proto" , "dir" , "location" , "asn" , "asorg" }).CurryWith (map [string ]string {"proto" : proto })
6464 if err != nil {
6565 return nil , err
6666 }
@@ -82,16 +82,16 @@ func (c *proxyCollector) Collect(ch chan<- prometheus.Metric) {
8282
8383func (c * proxyCollector ) addClientTarget (clientProxyBytes , proxyTargetBytes int64 , accessKey string , clientInfo ipinfo.IPInfo ) {
8484 addIfNonZero (clientProxyBytes , c .dataBytesPerKey , "c>p" , accessKey )
85- addIfNonZero (clientProxyBytes , c .dataBytesPerLocation , "c>p" , clientInfo .CountryCode .String (), asnLabel (clientInfo .ASN ) )
85+ addIfNonZero (clientProxyBytes , c .dataBytesPerLocation , "c>p" , clientInfo .CountryCode .String (), asnLabel (clientInfo .ASN . Number ), clientInfo . ASN . Organization )
8686 addIfNonZero (proxyTargetBytes , c .dataBytesPerKey , "p>t" , accessKey )
87- addIfNonZero (proxyTargetBytes , c .dataBytesPerLocation , "p>t" , clientInfo .CountryCode .String (), asnLabel (clientInfo .ASN ) )
87+ addIfNonZero (proxyTargetBytes , c .dataBytesPerLocation , "p>t" , clientInfo .CountryCode .String (), asnLabel (clientInfo .ASN . Number ), clientInfo . ASN . Organization )
8888}
8989
9090func (c * proxyCollector ) addTargetClient (targetProxyBytes , proxyClientBytes int64 , accessKey string , clientInfo ipinfo.IPInfo ) {
9191 addIfNonZero (targetProxyBytes , c .dataBytesPerKey , "p<t" , accessKey )
92- addIfNonZero (targetProxyBytes , c .dataBytesPerLocation , "p<t" , clientInfo .CountryCode .String (), asnLabel (clientInfo .ASN ) )
92+ addIfNonZero (targetProxyBytes , c .dataBytesPerLocation , "p<t" , clientInfo .CountryCode .String (), asnLabel (clientInfo .ASN . Number ), clientInfo . ASN . Organization )
9393 addIfNonZero (proxyClientBytes , c .dataBytesPerKey , "c<p" , accessKey )
94- addIfNonZero (proxyClientBytes , c .dataBytesPerLocation , "c<p" , clientInfo .CountryCode .String (), asnLabel (clientInfo .ASN ) )
94+ addIfNonZero (proxyClientBytes , c .dataBytesPerLocation , "c<p" , clientInfo .CountryCode .String (), asnLabel (clientInfo .ASN . Number ), clientInfo . ASN . Organization )
9595}
9696
9797type tcpConnMetrics struct {
@@ -175,12 +175,12 @@ func newTCPCollector() (*tcpServiceMetrics, error) {
175175 Namespace : namespace ,
176176 Name : "connections_opened" ,
177177 Help : "Count of open TCP connections" ,
178- }, []string {"location" , "asn" }),
178+ }, []string {"location" , "asn" , "asorg" }),
179179 closedConnections : prometheus .NewCounterVec (prometheus.CounterOpts {
180180 Namespace : namespace ,
181181 Name : "connections_closed" ,
182182 Help : "Count of closed TCP connections" ,
183- }, []string {"location" , "asn" , "status" , "access_key" }),
183+ }, []string {"location" , "asn" , "asorg" , " status" , "access_key" }),
184184 connectionDurationMs : prometheus .NewHistogramVec (
185185 prometheus.HistogramOpts {
186186 Namespace : namespace ,
@@ -217,11 +217,11 @@ func (c *tcpServiceMetrics) Collect(ch chan<- prometheus.Metric) {
217217}
218218
219219func (c * tcpServiceMetrics ) openConnection (clientInfo ipinfo.IPInfo ) {
220- c .openConnections .WithLabelValues (clientInfo .CountryCode .String (), asnLabel (clientInfo .ASN ) ).Inc ()
220+ c .openConnections .WithLabelValues (clientInfo .CountryCode .String (), asnLabel (clientInfo .ASN . Number ), clientInfo . ASN . Organization ).Inc ()
221221}
222222
223223func (c * tcpServiceMetrics ) closeConnection (status string , duration time.Duration , accessKey string , clientInfo ipinfo.IPInfo ) {
224- c .closedConnections .WithLabelValues (clientInfo .CountryCode .String (), asnLabel (clientInfo .ASN ) , status , accessKey ).Inc ()
224+ c .closedConnections .WithLabelValues (clientInfo .CountryCode .String (), asnLabel (clientInfo .ASN . Number ), clientInfo . ASN . Organization , status , accessKey ).Inc ()
225225 c .connectionDurationMs .WithLabelValues (status ).Observe (duration .Seconds () * 1000 )
226226}
227227
@@ -310,7 +310,7 @@ func newUDPCollector() (*udpServiceMetrics, error) {
310310 Namespace : namespace ,
311311 Name : "packets_from_client_per_location" ,
312312 Help : "Packets received from the client, per location and status" ,
313- }, []string {"location" , "asn" , "status" }),
313+ }, []string {"location" , "asn" , "asorg" , " status" }),
314314 addedNatEntries : prometheus .NewCounter (
315315 prometheus.CounterOpts {
316316 Namespace : namespace ,
@@ -351,7 +351,7 @@ func (c *udpServiceMetrics) removeNatEntry() {
351351}
352352
353353func (c * udpServiceMetrics ) addPacketFromClient (status string , clientProxyBytes , proxyTargetBytes int64 , accessKey string , clientInfo ipinfo.IPInfo ) {
354- c .packetsFromClientPerLocation .WithLabelValues (clientInfo .CountryCode .String (), asnLabel (clientInfo .ASN ) , status ).Inc ()
354+ c .packetsFromClientPerLocation .WithLabelValues (clientInfo .CountryCode .String (), asnLabel (clientInfo .ASN . Number ), clientInfo . ASN . Organization , status ).Inc ()
355355 c .proxyCollector .addClientTarget (clientProxyBytes , proxyTargetBytes , accessKey , clientInfo )
356356}
357357
@@ -408,7 +408,7 @@ func newTunnelTimeMetrics(ip2info ipinfo.IPInfoMap) *tunnelTimeMetrics {
408408 Namespace : namespace ,
409409 Name : "seconds_per_location" ,
410410 Help : "Tunnel time, per location." ,
411- }, []string {"location" , "asn" }),
411+ }, []string {"location" , "asn" , "asorg" }),
412412 }
413413}
414414
@@ -433,7 +433,7 @@ func (c *tunnelTimeMetrics) reportTunnelTime(ipKey IPKey, client *activeClient,
433433 tunnelTime := tNow .Sub (client .startTime )
434434 slog .LogAttrs (nil , slog .LevelDebug , "Reporting tunnel time." , slog .String ("key" , ipKey .accessKey ), slog .Duration ("duration" , tunnelTime ))
435435 c .tunnelTimePerKey .WithLabelValues (ipKey .accessKey ).Add (tunnelTime .Seconds ())
436- c .tunnelTimePerLocation .WithLabelValues (client .info .CountryCode .String (), asnLabel (client .info .ASN ) ).Add (tunnelTime .Seconds ())
436+ c .tunnelTimePerLocation .WithLabelValues (client .info .CountryCode .String (), asnLabel (client .info .ASN . Number ), client . info . ASN . Organization ).Add (tunnelTime .Seconds ())
437437 // Reset the start time now that the tunnel time has been reported.
438438 client .startTime = tNow
439439}
0 commit comments