Command-line routing stats with BGPKIT Monocle and Cloudflare Radar API

30/05/2024

Command-line routing stats with BGPKIT Monocle and Cloudflare Radar API

By Mingwei Zhang, senior systems engineer at Cloudflare

This was originally published on the BGPKIT blog.

Mingwei Zhang, Ph.-D is a senior systems engineer at Cloudflare, building complex high-throughput data pipelines and conducting data analysis on significant Internet routing events. He is the founder of open source BGP data analysis toolkit BGPKIT.

BGPKIT monocle is a command-line utility program that helps users quickly pull Internet routing-related information from publicly available sources and is available on GitHub.

In BGPKIT monocle version V0.5, we added support for querying Cloudflare Radar‘s new BGP routing statistics and prefix-to-origin mapping APIs, the same APIs that power the Cloudflare Radar routing section. monocle users can now quickly glance at routing stats for any given Autonomous System Number (ASN), economy, or the whole Internet. Users can also quickly look up prefix origins and examine their RPKI validation status as well as prefix visibility on the global routing tables.

Using monocle radar

We added a new monocle radar command group in V0.5, which contains the following subcommands:

(Free access, no subscription required)

  • monocle radar stats [QUERY]: Get routing stats (like prefix count, RPKI invalid count) for a given economy or ASN.
  • monocle radar pfx2as [QUERY] [–rpki-status valid|invalid|unknown]: Get prefix to origin mapping for a given prefix or ASN.
mingwei@terrier ~ % monocle radar

Cloudflare Radar API lookup (set CF_API_TOKEN to enable)

Usage: monocle radar <COMMAND>

Commands:

  stats   get routing stats

  pfx2as  look up prefix to origin mapping on the most recent global routing table snapshot

  help    Print this message or the help of the given subcommand(s)

Options:

  -h, --help     Print help

  -V, --version  Print version

Cloudflare API token needed

Since the monocle radar command relies on querying data using the Cloudflare Radar public API, we also need to specify a user API token as the environment variable CF_API_TOKEN. Obtaining an API token is free and only needs a Cloudflare account. Interested users can follow their official tutorial to obtain a token. The environment variable can be set in a .env file in the current directory, or set in ~/.bashrc or ~/.profile, and so on.

monocle radar stats

The views expressed by the authors of this blog are their own and do not necessarily reflect the views of LACNIC.

Subscribe
Notify of

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments