Skip to content

Conversation

@digizeph
Copy link
Member

@digizeph digizeph commented Dec 9, 2025

Summary

Add new monocle as2rel command to query AS-level relationships between Autonomous Systems using BGPKIT's AS relationship data from data.bgpkit.com/as2rel.

Features

  • Query relationships for one or two ASNs
  • Output columns showing relationship percentages:
    • connected: Percentage of collectors seeing any connection
    • peer: Percentage seeing pure peering (connected - upstream - downstream)
    • as1_upstream: Percentage seeing asn1 as upstream of asn2
    • as2_upstream: Percentage seeing asn2 as upstream of asn1
  • Percentages calculated as count / max_peers_count * 100%
  • Local SQLite caching with automatic 7-day refresh
  • Displays last update time with human-readable relative time (e.g., "2 hours ago")
  • Sorting options:
    • By connected % descending (default)
    • By ASN2 ascending (--sort-by-asn)
  • Optional ASN2 organization name lookup from as2org database (--show-name)
  • JSON output support (--json)

Example Usage

# Query relationship between two ASNs
monocle as2rel 6939 13335

# Query all relationships for an ASN
monocle as2rel 400644

# Show organization names
monocle as2rel --show-name 400644

# JSON output
monocle --json as2rel 6939 13335

New Files

  • src/datasets/as2rel.rs: Library module with SQLite caching
  • src/bin/commands/as2rel.rs: CLI command implementation

Other Changes

  • Added batch lookup_org_names_batch() method to as2org module for performance
  • Updated README with as2rel documentation
  • Updated CHANGELOG

@digizeph digizeph force-pushed the feature/as2rel branch 2 times, most recently from 57f832c to 0642862 Compare December 9, 2025 23:50
Add new 'monocle as2rel' command to query AS-level relationships between
Autonomous Systems using BGPKIT's AS relationship data.

Features:
- Query relationships for one or two ASNs
- Output columns: connected, peer, as1_upstream, as2_upstream
- Percentages calculated as count/max_peers_count
- Local SQLite caching with 7-day auto-refresh
- Last update time with human-readable relative time
- Sorting options: by connected % (default) or by ASN
- Optional ASN2 organization name lookup via efficient SQL JOIN
- JSON output support

New files:
- src/datasets/as2rel.rs: Library module with SQLite caching
- src/bin/commands/as2rel.rs: CLI command implementation

Performance optimization:
- Use SQL JOIN for org_name lookup instead of separate queries
- UTF-8 safe string truncation for org names
@digizeph digizeph enabled auto-merge December 10, 2025 00:00
@digizeph digizeph merged commit add4c8e into main Dec 10, 2025
1 check passed
@digizeph digizeph deleted the feature/as2rel branch December 18, 2025 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants