Skip to content

API: add a new endpoint to export metrics in Prometheus format #1126

@josecelano

Description

@josecelano

Relates to: torrust/torrust-demo#20

Context

The only way to see tracker metrics is via this API endpoint:

http://127.0.0.1:1212/api/v1/stats?token=MyAccessToken

{
  "torrents": 378783,
  "seeders": 63963,
  "completed": 394744,
  "leechers": 171286,
  "tcp4_connections_handled": 648,
  "tcp4_announces_handled": 647,
  "tcp4_scrapes_handled": 1,
  "tcp6_connections_handled": 0,
  "tcp6_announces_handled": 0,
  "tcp6_scrapes_handled": 0,
  "udp4_connections_handled": 220330443,
  "udp4_announces_handled": 649148603,
  "udp4_scrapes_handled": 14483989,
  "udp6_connections_handled": 0,
  "udp6_announces_handled": 0,
  "udp6_scrapes_handled": 0
}

The endpoint doesn't include aggregate or historical data. To manage the tracker, having a dashboard with graphs for the data we collect would be very helpful.

Proposal

Add a new API endpoint returning stats in plain text that are ready to be consumed by Prometheus.

http://127.0.0.1:1212/api/v1/stats?format=prometheus&token=MyAccessToken

torrents 1
seeders 1
completed 0
leechers 0
tcp4_connections_handled 648
tcp4_announces_handled 647
tcp4_scrapes_handled 1
tcp6_connections_handled: 0
tcp6_announces_handled 0
tcp6_scrapes_handled 0
udp4_connections_handled 2200443
udp4_announces_handled 6498603
udp4_scrapes_handled 143989
udp6_connections_handled 0
udp6_announces_handled 0
udp6_scrapes_handled 0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions