1

I have noticed that metrics options were added in PR 2096. However, when I open http://127.0.0.1:37991/metrics I get only a blank page.

I use tor.exe file to send HTTP requests through Tor's SOCKS5 endpoint. This means that I don't use Tor Browser. Instead I run tor.exe like this:

./tor.exe --SOCKSPort 127.0.0.1:12345 --CookieAuthentication 1 --ControlPort XYZ --CookieAuthFile "C:\path\to\data\control_auth_cookie" --DataDirectory "C:\path\to\data\data_directory" --MetricsPort 127.0.0.1:37991 --MetricsPortPolicy "accept 127.0.0.1" --Log "notice file C:\path\to\data\my.log"

Am I supposed to see any metrics or not in my use case? I mean what metrics are actually being recorded?

1
  • I get an empty http response also when requesting /metrics with wget
    – Spikolynn
    19 hours ago
1

Tor metrics are not the web interface but an API. If you need some out-of-the-box metrics - use nyx tool, it gives you quite a nice metrics in a text TTY console, so it's suitable for SSH too

Well, first of all - about nyx - it's a very handy tool from the Tor Project -> https://nyx.torproject.org/ it's open source, so you can see how to read metrics in it's code. It's simple but a shiny one, give it a try!

And about metrics, just as it's said in the official man page :

[[MetricsPort]] **MetricsPort** ['address'**:**]{empty}__port__ [__format__]::
    WARNING: Before enabling this, it is important to understand that exposing
    tor metrics publicly is dangerous to the Tor network users. Please take
    extra precaution and care when opening this port. Set a very strict access
    policy with MetricsPortPolicy and consider using your operating systems
    firewall features for defense in depth.
     +
    We recommend, for the prometheus __format__, that the only address that
    can access this port should be the Prometheus server itself. Remember that
    the connection is unencrypted (HTTP) hence consider using a tool like
    stunnel to secure the link from this port to the server.
     +
    If set, open this port to listen for an HTTP GET request to "/metrics".
    Upon a request, the collected metrics in the the tor instance are
    formatted for the given format and then sent back. If this is set,
    MetricsPortPolicy must be defined else every request will be rejected.
     +
    Supported format is "prometheus" which is also the default if not set. The
    Prometheus data model can be found here:
    https://prometheus.io/docs/concepts/data_model/

The Prometheus is one of the industry-standard open source metrics collecting package like Zabbix et cetera, so you can use the Prometheus API client(because the Tor process is a server here - it serves you the data) to query the metrics out of your application, or - for instance of the complex metrics - raise a local Prometheus and connect it to the Tor data source, after that you can utilize the Prometheus data extraction API, it has quite a decent docs and real working examples: https://prometheus.io/docs/prometheus/latest/querying/api/

3
  • Thank you for explanation! (I confess that I don't understand it in detail though.) Do you possibly have a link for a tutorial/example/whatever how to do that? I don't actually know nyx. I know curl, wget or I can program an API request in a programming language... if that is what you mean.
    – Centrury
    Oct 22 at 20:30
  • yes, that's what I mean - I will update my answer to provide a better deep-dive into the subject
    – Alexey Vesnin
    Oct 25 at 17:24
  • Thank you very much for this!
    – Centrury
    Oct 26 at 6:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.