Sign inSign up

eclaesson/bunnynet_prometheus

By eclaesson

•Updated 4 months ago

Expose Bunny.net statistics as a scrapable prometheus endpoint

Image
Networking
Monitoring & observability
0

1.0K

eclaesson/bunnynet_prometheus repository overview

⁠bunnynet_prometheus

Expose Bunny.net⁠ statistics as a scrapable Prometheus endpoint.

bunnynet_prometheus is a daemon that periodically polls the Bunny.net API⁠ for usage and performance statistics and re-exposes it as Prometheus metrics on an HTTP endpoint.

All available statistics endpoints in the Bunny.net API are covered: Magic Containers, DNS zones, Edge scripts, Storage zones, Video libraries, Video transcribing, Video DRM, Pull zones, Pull zone optimizers, Pull zone origin shield queues, Pull zone SafeHops and Shield zones. Each category of statistics is implemented as a separate collector that can be individually enabled. Details about available collectors and the metrics they emit can be found under Collectors⁠.

Counter values are persisted to disk between poll cycles, so restarts don't reset totals and day rollovers are correctly handled. If the daemon has been stopped for an extended period, missed days will be backfilled. The day rollover follows Bunny.net (UTC). Each collector keeps a state file in the state directory (default ~/.local/share/bunnynet_prometheus/state) which maintains a running tally of totals.

⁠Installation

bunnynet_prometheus can be compiled with cargo or you can download prebuilt releases⁠.

It is also available on crates.io⁠:

cargo install bunnynet_prometheus

⁠Usage

bunnynet_prometheus [OPTIONS] --collectors <COLLECTORS>...

Options:
  -v, --verbose
          Enable verbose output
  -q, --quiet
          Only output warnings and errors
  -k, --access-key <ACCESS_KEY>
          Bunny.net API access key (Can also be set by environment variable BUNNYNET_ACCESS_KEY)
  -f, --access-key-file <ACCESS_KEY_FILE>
          Path to a file containing a Bunny.net API access key
  -r, --api-request-timeout <API_REQUEST_TIMEOUT>
          Timeout in seconds for Bunny.net API requests [default: 10]
  -n, --api-concurrency <API_CONCURRENCY>
          Maximum number of concurrent Bunny.net API requests [default: 5]
  -i, --poll-interval <POLL_INTERVAL>
          Update interval in seconds [default: 300]
  -s, --state-dir <STATE_DIR>
          Path to a directory to store persistent state files in [default: ~/.local/share/bunnynet_prometheus/state]
  -a, --bind-addr <BIND_ADDR>
          HTTP server bind address [default: 0.0.0.0]
  -p, --bind-port <BIND_PORT>
          HTTP server bind port [default: 9000]
  -c, --collectors <COLLECTORS>...
          Comma-separated list of categories of statistics to poll [possible values: application, dns_zone, edge_script, storage_zone, video_library, video_library_transcribing, video_library_drm, pull_zone, pull_zone_optimizer, pull_zone_origin_shield_queue, pull_zone_safehop, shield_zone]
  -h, --help
          Print help
  -V, --version
          Print version

You can create your API access key in the Bunny.net dashboard⁠.

The HTTP endpoint will respond on any path.

⁠Example

Load the access key from a file, poll the dns_zone and storage_zone collectors and expose metrics on the default port (9000).

bunnynet_prometheus -f ~/.bunnynet.key -c dns_zone,storage_zone

⁠Internal metrics

These metrics are always enabled and expose the health and age of the collectors.

NameTypeTags
bunnynet_last_update_attempt_timestamp_secondsGauge
bunnynet_last_successful_update_timestamp_secondsGauge
bunnynet_last_collector_update_timestamp_secondsGaugecollector

⁠Collectors

⁠application
NameTypeTags
bunnynet_application_target_latencyGaugeapp_id, name
bunnynet_application_active_regionsGaugeapp_id, name
bunnynet_application_latencyGaugeapp_id, name
bunnynet_application_instancesGaugeapp_id, name
bunnynet_application_cpu_usageGaugeapp_id, name
bunnynet_application_ram_usageGaugeapp_id, name
bunnynet_application_traffic_totalCounterapp_id, name
bunnynet_application_volume_usageGaugeapp_id, name, volume
bunnynet_application_volume_capacityGaugeapp_id, name, volume
⁠dns_zone
NameTypeTags
bunnynet_dns_zone_normal_queries_totalCounterzone_id, domain
bunnynet_dns_zone_smart_queries_totalCounterzone_id, domain
bunnynet_dns_zone_queries_by_type_totalCounterzone_id, domain, type
⁠edge_script
NameTypeTags
bunnynet_edge_script_requests_served_totalCounterscript_id, name
bunnynet_edge_script_cpu_time_totalCounterscript_id, name
bunnynet_edge_script_average_cpu_timeGaugescript_id, name
⁠storage_zone
NameTypeTags
bunnynet_storage_zone_storage_usedGaugezone_id, name
bunnynet_storage_zone_file_countGaugezone_id, name
⁠video_library
NameTypeTags
bunnynet_video_library_views_totalCounterlibrary_id, name
bunnynet_video_library_watch_time_totalCounterlibrary_id, name
bunnynet_video_library_country_views_totalCounterlibrary_id, name, country
bunnynet_video_library_country_watch_time_totalCounterlibrary_id, name, country
⁠video_library_drm
NameTypeTags
bunnynet_video_library_drm_licenses_issued_totalCounterlibrary_id, name
⁠video_library_transcribing
NameTypeTags
bunnynet_video_library_transcribing_seconds_totalCounterlibrary_id, name
⁠pull_zone
NameTypeTags
bunnynet_pull_zone_bandwidth_used_totalCounterzone_id, name
bunnynet_pull_zone_bandwidth_cached_totalCounterzone_id, name
bunnynet_pull_zone_requests_served_totalCounterzone_id, name
bunnynet_pull_zone_pull_requests_pulled_totalCounterzone_id, name
bunnynet_pull_zone_origin_shield_bandwidth_used_totalCounterzone_id, name
bunnynet_pull_zone_origin_shield_internal_bandwidth_used_totalCounterzone_id, name
bunnynet_pull_zone_origin_traffic_totalCounterzone_id, name
bunnynet_pull_zone_errors_3xx_totalCounterzone_id, name
bunnynet_pull_zone_errors_4xx_totalCounterzone_id, name
bunnynet_pull_zone_errors_5xx_totalCounterzone_id, name
bunnynet_pull_zone_origin_response_timeGaugezone_id, name
bunnynet_pull_zone_cache_hit_rateGaugezone_id, name
bunnynet_pull_zone_geo_traffic_totalCounterzone_id, name, region
⁠pull_zone_optimizer
NameTypeTags
bunnynet_pull_zone_optimizer_requests_optimized_totalCounterzone_id, name
bunnynet_pull_zone_optimizer_traffic_saved_totalCounterzone_id, name
bunnynet_pull_zone_optimizer_average_compressionGaugezone_id, name
bunnynet_pull_zone_optimizer_average_processing_timeGaugezone_id, name
⁠pull_zone_origin_shield_queue
NameTypeTags
bunnynet_pull_zone_origin_shield_queue_concurrent_requestsGaugezone_id, name
bunnynet_pull_zone_origin_shield_queue_queued_requestsGaugezone_id, name
⁠pull_zone_safehop
NameTypeTags
bunnynet_pull_zone_safehop_requests_retried_totalCounterzone_id, name
bunnynet_pull_zone_safehop_requests_saved_totalCounterzone_id, name
⁠shield_zone
NameTypeTags
bunnynet_shield_zone_requests_totalCountershield_zone_id, pull_zone_id, category, action
bunnynet_shield_zone_clean_requests_limitGaugeshield_zone_id, pull_zone_id
bunnynet_shield_zone_billable_requests_this_monthGaugeshield_zone_id, pull_zone_id

Tag summary

Content type

Image

Digest

sha256:13821ebaf…

Size

3 MB

Last updated

4 months ago

docker pull eclaesson/bunnynet_prometheus