You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Overhaul stats: Add the PeerClient and version as labels to metrics #1456
It would be invaluable to include the clients' software version as a label in the metrics so we can check what BitTorrent clients are producing those errors. If they are known clients with public repositories, we could open issues.
We should include the new labels in all metrics where the information is available.
We are using the aquatic PeerId which included the PeerClient info.
Since there are many clients, I won't use labeled metrics to count requests from these clients. That would generate a lot of time series in Prometheus.
The reason for adding this label was to identify peers that are sending the wrong connection ID. I'm assuming there could be some bad implementations. I only want to confirm if that happens.
Alternative Solution
I think we could change the BanService to include two new HashMaps to count:
Number of bans per client software (only the software name)
Number of bans per client software + version
That would help to identify if a concrete client software or version is not sending the connection ID.
We could expose these counters via the stats tracker API in a new route /stats/banning/info:
/stats
/stats/banning/banned/ips <- returns the list of banned IPs.
/stats/banning/info <- returns the counters for clients and client-versions
/metrics
On the other hand, I increased the ban period from 1 hour to 24 hours. It seems the number of banned IPS does not have an upper limit:
After discussing this issue today again with @da2ce7 I've realised that it does not matter whether I used the labelled metrics or an independent data structure. The real problem is if I add a new label to the udp_tracker_server_errors_total metric that increases the number of time series of that metric N times, where N is the number of combinations of client software + version. However, if I use a new metric for this, the number of time series would be the same as if I stored the same information in an independent HashMap. For example, having NC clients and NV versions per client,
Number of metric values = NC * NV
In a HashMap where the key is the client name and the value is a list of the number of bans per version of that client. Something like:
The number of time series generated in Prometheus would be the same as if we pull the JSON. Assuming, on average, 15 for the number of different clients and 5 versions per client, we would have only 75 new entries in the metrics collections. In my original idea of adding a new label to udp_tracker_server_errors_total, we should multiply the current number of time series by 75.
The key point is that even if it is related to requests, we disregard the rest of the request and focus solely on the relevant information for IP bans, specifically the client software.
Activity
josecelano commentedon Apr 23, 2025
The list of peer IDS included in BEP 20:
https://www.bittorrent.org/beps/bep_0020.html
The list of peer IDS from:
AI model: GPT-4o
📋 BitTorrent Client Peer ID Prefixes
Axxxxx---AA2A3B----AGYYYY-or-A~YYYY-AGorA~-AG1234--ARYYYY-AR-AR1234--AZYYYY-AZ-AZ2060--BBYYYY-BB-BB1234-exbc\xYY\xZZexbcexbc\x01\x23...-BFYYYY-BF-BF1100--WTYYYY-WT-WT1234-exbc\xYY\xZZLORDexbcexbc\x01\x23LORD...-AXYYYY-AX-AX1234--BRYYYY-BR-BR1000-\0\3BSor\0\2BSBS\0\3BS...Txxxxx---TT03A3---Mx-y-z--MM4-3-6---BXYYYY-BX-BX1234-AZYYYYBTAZAZ2500BT-BOWxxx-yyyyyyyyyyyyBOW-BOWA0C-ABCDEFGHIJKL-BGYYYY-BG-BG1234-Qxxxxx---QQ1A2B----BSYYYY-BS-BS1234--DEYYYY-DE-DE1230--ESYYYY-ES-ES1234--CDYYYY-CD-CD1234--EBYYYY-EB-EB1234--WYYYYY-WY-WY1234--FGYYYYFG-FG0180-FTYYYY-FT-FT1234--FXYYYY-FX-FX1234--FWYYYY-FW-FW1234--G3xxxxxxxxxG3-G3nickname-GSYYYY-GS-GS1234--HLYYYY-HL-HL1000--HNYYYY-HN-HN1234--KGYYYY-KG-KG1234--KTYYYY-KT-KT2200--LHYYYY-LH-LH1234--ltYYYY-lt-lt1234--LTYYYY-LT-LT1234--LWYYYY-LW-LW1234--LPYYYY-LP-LP1234--MLx.y.z-ML-ML2.7.2-kgjjfkd-MOYYYY-MO-MO1234--MTYYYY-MT-MT1234--MPYYYY-MP-MP1234--MRYYYY-MR-MR1234--NXYYYY-NX-NX1234-OPxxxxOPOP1234🔗 Sources
josecelano commentedon Apr 23, 2025
Since there are many clients, I won't use labeled metrics to count requests from these clients. That would generate a lot of time series in Prometheus.
The reason for adding this label was to identify peers that are sending the wrong connection ID. I'm assuming there could be some bad implementations. I only want to confirm if that happens.
Alternative Solution
I think we could change the BanService to include two new HashMaps to count:
That would help to identify if a concrete client software or version is not sending the connection ID.
We could expose these counters via the
statstracker API in a new route/stats/banning/info:On the other hand, I increased the ban period from 1 hour to 24 hours. It seems the number of banned IPS does not have an upper limit:
cc @da2ce7
josecelano commentedon May 5, 2025
After discussing this issue today again with @da2ce7 I've realised that it does not matter whether I used the labelled metrics or an independent data structure. The real problem is if I add a new label to the
udp_tracker_server_errors_totalmetric that increases the number of time series of that metric N times, where N is the number of combinations of client software + version. However, if I use a new metric for this, the number of time series would be the same as if I stored the same information in an independent HashMap. For example, having NC clients and NV versions per client,Number of metric values = NC * NV
In a HashMap where the key is the client name and the value is a list of the number of bans per version of that client. Something like:
If I create an independent metric like this:
udp_tracker_server_client_bans_total{client_software_name="qB",client_software_version="4.3.9"}The number of time series generated in Prometheus would be the same as if we pull the JSON. Assuming, on average, 15 for the number of different clients and 5 versions per client, we would have only 75 new entries in the metrics collections. In my original idea of adding a new label to
udp_tracker_server_errors_total, we should multiply the current number of time series by 75.The key point is that even if it is related to requests, we disregard the rest of the request and focus solely on the relevant information for IP bans, specifically the client software.
feat: [torrust#1456] wrapper over aquatic RequestParseError to make i…
feat: [torrust#1456] expose error kind in the UdpError event
refactor: [torrust#1456] remove unused enum variant in udp server error
refactor: [torrust#1456 clean code
refactor: [torrust#1456] extract methods
refactor: [torrust#1456] increase ban counters asyncronously
Merge #1552: Refactor UDP error event logic before adding new metrics
josecelano commentedon Jun 4, 2025
Implemented. I'm deploying it to the tracker demo.