{"id":31600294,"url":"https://github.com/r167/starlink_exporter","last_synced_at":"2025-10-06T06:56:10.299Z","repository":{"id":318020856,"uuid":"1069729853","full_name":"R167/starlink_exporter","owner":"R167","description":null,"archived":false,"fork":false,"pushed_at":"2025-10-04T15:56:24.000Z","size":267,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-04T16:08:41.443Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/R167.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-04T14:06:27.000Z","updated_at":"2025-10-04T15:56:22.000Z","dependencies_parsed_at":"2025-10-04T16:08:43.424Z","dependency_job_id":"a890e6ea-f5a3-4fb0-887e-b403dab61226","html_url":"https://github.com/R167/starlink_exporter","commit_stats":null,"previous_names":["r167/starlink_exporter"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/R167/starlink_exporter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R167%2Fstarlink_exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R167%2Fstarlink_exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R167%2Fstarlink_exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R167%2Fstarlink_exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/R167","download_url":"https://codeload.github.com/R167/starlink_exporter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R167%2Fstarlink_exporter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278572004,"owners_count":26008686,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-06T06:56:06.465Z","updated_at":"2025-10-06T06:56:10.293Z","avatar_url":"https://github.com/R167.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Starlink Prometheus Exporter\n\nA Prometheus exporter for Starlink Dishy metrics written in Go. Exports bandwidth, energy, ping latency, and device statistics from your Starlink terminal.\n\n## Features\n\n- **Bandwidth tracking**: Cumulative upload/download bytes from historical data\n- **Energy monitoring**: Total energy consumption in joules\n- **Ping metrics**: Latency and drop rate statistics with Prometheus summary metrics\n- **Device info**: Hardware version, software version, uptime, GPS status\n- **Background ticker**: 1-second updates independent of Prometheus scrapes\n- **Resilient**: Handles network issues, concurrent scrapes, and dishy restarts\n- **Structured logging**: Configurable log levels with `log/slog`\n\n## Quick Start\n\n### Using Docker (Recommended)\n\n```bash\n# Run with defaults (listens on :9999, connects to 192.168.100.1:9200)\ndocker run -p 9999:9999 ghcr.io/r167/starlink_exporter:master\n\n# Custom configuration\ndocker run -p 8080:8080 ghcr.io/r167/starlink_exporter:master \\\n  --listen :8080 --dish 192.168.100.1:9200 --log-level debug\n\n# View metrics\ncurl -s localhost:9999/metrics | grep starlink_\n```\n\n### Using Go\n\n```bash\n# Run with defaults (listens on :9999, connects to 192.168.100.1:9200)\ngo run ./cmd/exporter\n\n# Custom configuration\ngo run ./cmd/exporter --listen :8080 --dish 192.168.100.1:9200 --log-level debug\n\n# View metrics\ncurl -s localhost:9999/metrics | grep starlink_\n```\n\n## Installation\n\n```bash\n# Clone the repository\ngit clone \u003crepository-url\u003e\ncd starlink_exporter\n\n# Install dependencies\ngo mod download\n\n# Generate proto files from Starlink dish (requires grpcurl and protoc)\nmake proto\n\n# Run tests\ngo test ./...\n\n# Run the exporter\ngo run ./cmd/exporter\n```\n\n### Generating Proto Files\n\nThe proto files are sourced from the Starlink dish via gRPC reflection and are not checked into git. To generate them:\n\n```bash\n# Fetch proto files and generate Go code (requires Starlink dish access)\nmake proto\n\n# Or run each step individually:\nmake fetch-protos    # Fetch .proto files via grpcurl reflection\nmake fix-protos      # Add go_package options to proto files\n```\n\n**Requirements:**\n- `grpcurl` - gRPC client with reflection support\n- `protoc` - Protocol buffer compiler\n- Access to Starlink dish at `192.168.100.1:9200` (or set `DISH_ADDR` env var)\n\n## Configuration\n\n| Flag | Default | Description |\n|------|---------|-------------|\n| `--listen` | `:9999` | HTTP metrics server address |\n| `--dish` | `192.168.100.1:9200` | Starlink dish gRPC address |\n| `--log-level` | `info` | Log level: debug, info, warn, error |\n\n## Metrics\n\n### Counters (Integrated from Historical Data)\n- `starlink_download_bytes_total` - Cumulative download bytes\n- `starlink_upload_bytes_total` - Cumulative upload bytes\n- `starlink_energy_joules_total` - Total energy consumed (joules)\n- `starlink_ping_latency_seconds_sum` - Sum of ping latencies (seconds)\n- `starlink_ping_latency_seconds_count` - Count of ping samples\n- `starlink_ping_drop_total` - Total ping drops\n\n### Gauges (Current Values)\n- `starlink_downlink_throughput_bps` - Current downlink throughput\n- `starlink_uplink_throughput_bps` - Current uplink throughput\n- `starlink_pop_ping_latency_ms` - Current latency to POP\n- `starlink_uptime_seconds` - Device uptime\n- `starlink_obstruction_fraction` - Fraction of time obstructed\n- `starlink_gps_satellites` - Number of GPS satellites\n- `starlink_eth_speed_mbps` - Ethernet speed\n- `starlink_up` - Scrape success indicator (1=success, 0=failure)\n\n### Info Labels\n- `starlink_info{id, hardware_version, software_version, country_code}` - Device metadata\n\n## Prometheus Queries\n\n### Average Ping Latency (5-minute window)\n```promql\nrate(starlink_ping_latency_seconds_sum[5m]) / rate(starlink_ping_latency_seconds_count[5m])\n```\n\n### Average Power Consumption (watts)\n```promql\nrate(starlink_energy_joules_total[5m])\n```\n\n### Total Energy (kWh)\n```promql\nstarlink_energy_joules_total / 3600000\n```\n\n### Bandwidth Rate (bytes/sec)\n```promql\nrate(starlink_download_bytes_total[5m])\nrate(starlink_upload_bytes_total[5m])\n```\n\n## Architecture\n\nThe exporter uses a **background ticker** that runs every 1 second to:\n1. Fetch 15 minutes of historical data from the Starlink dish\n2. Process the **circular buffer arrays** (900 samples @ 1sec intervals)\n3. Integrate metrics: bandwidth (bits→bytes), energy (watts→joules), ping latency (ms→seconds)\n4. Accumulate into thread-safe counters\n5. Export to Prometheus on `/metrics`\n\n### Critical: Circular Buffer Arrays\nHistory arrays are **circular buffers** indexed by `Current % 900`:\n- Array length: 900 samples (15 minutes)\n- Current field: Timestamp indicating \"now\"\n- New samples: From `(lastCurrent + 1) % 900` to `Current % 900`\n\n## API Details\n\nThe exporter connects to the Starlink dish gRPC API:\n- **Endpoint**: `192.168.100.1:9200` (default)\n- **Protocol**: gRPC with native protobuf\n- **Service**: `SpaceX.API.Device.Device/Handle`\n- **Methods**: `get_status`, `get_history`\n\n## Development\n\n```bash\n# Run tests\ngo test ./internal/collector/... -v\n\n# Run all tests, vet, and format\ngo test ./... \u0026\u0026 go vet ./... \u0026\u0026 go fmt ./...\n\n# Debug logging\ngo run ./cmd/exporter --log-level debug\n\n# Makefile targets\nmake proto      # Fetch and generate proto files\nmake test       # Run tests\nmake run        # Run the exporter\nmake dev        # Rebuild protos and run\nmake clean      # Remove generated files\n\n# Build Docker image locally\ndocker build -t starlink_exporter .\ndocker run -p 9999:9999 starlink_exporter\n```\n\n### Debug Output\n```\ntime=2025-10-04T09:14:05.272Z level=DEBUG msg=\"Metrics update\"\n  time_delta=1 sample_indices=[529]\n  download_delta_bytes=48472.5234375\n  upload_delta_bytes=38558.23828125\n  energy_delta_joules=48.950096130371094\n  ping_latency_delta_seconds=0.022024417877197266\n  ping_sample_count=1\n  ping_drop_delta=0\n```\n\n## Dependencies\n\n- `google.golang.org/grpc` - gRPC client\n- `google.golang.org/protobuf` - Protobuf support\n- `github.com/prometheus/client_golang` - Prometheus client\n\n## License\n\nApache License 2.0 - see [LICENSE](LICENSE) file for details\n\n## Contributing\n\n[Add contribution guidelines here]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr167%2Fstarlink_exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr167%2Fstarlink_exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr167%2Fstarlink_exporter/lists"}