agh-exporter-rs

Crates.ioagh-exporter-rs
lib.rsagh-exporter-rs
version0.1.4
sourcesrc
created_at2024-01-02 21:39:31.787632
updated_at2024-01-17 19:23:15.590536
descriptionA small HTTP server exporting AdGuard Home metrics for consumption in Prometheus.
homepagehttps://github.com/molguin92/agh-exporter-rs
repositoryhttps://github.com/molguin92/agh-exporter-rs
max_upload_size
id1086702
size77,814
Manuel Olguín Muñoz, Ph.D. (molguin92)

documentation

README

agh-exporter-rs

A small HTTP server exporting AdGuard Home metrics for consumption in Prometheus, built on top of tokio-rs, serde-rs, reqwest, and axum. Exported metrics are named identically to the output of the AdGuard Home metrics; for details, see the AdGuard Home openapi specification.

Example metrics:

$ curl http://agh-exporter:9100/metrics
num_dns_queries 47578
num_blocked_filtering 8447
num_replaced_safebrowsing 0
num_replaced_safesearch 0
num_replaced_parental 0
avg_processing_time 0.031464
top_clients{client = "192.168.1.28"} 10321
top_clients{client = "192.168.1.32"} 6308
top_clients{client = "192.168.1.16"} 6266
...
top_upstreams_responses{upstream = "1.1.1.1:53"} 15264
top_upstreams_responses{upstream = "1.0.0.1:53"} 14659
top_upstreams_avg_time{upstream = "1.1.1.1:53"} 0.0497817546514675
top_upstreams_avg_time{upstream = "1.0.0.1:53"} 0.04927965318234532
top_queried_domains{domain = "www.baidu.com"} 4120
top_queried_domains{domain = "raw.githubusercontent.com"} 3064
top_queried_domains{domain = "1.0.168.192.in-addr.arpa"} 2181
...
top_blocked_domains{domain = "os-12-5-alpha.logs.roku.com"} 2353
top_blocked_domains{domain = "scribe.logs.roku.com"} 2208
top_blocked_domains{domain = "dit.whatsapp.net"} 862
...

Installing and running the crate

From crates.io

Install using cargo:

$ cargo install agh-exporter-rs

$ agh-exporter-rs -h           
A small HTTP server exporting AdGuard Home metrics for consumption in Prometheus.

Usage: agh-exporter-rs [OPTIONS]

Options:
  -a, --agh-host <AGH_HOST>
          Base AGH API URL. Note the trailing slash! [env: AGH_HOST=] [default: http://localhost/control/]
  -s, --serve-addr <SERVE_ADDR>
          Address to bind to and serve metrics from, including metrics URL [env: AGH_SERVE_ADDR=] [default: http://0.0.0.0:9100/metrics]
  -u, --agh-username <AGH_USERNAME>
          AGH username [env: AGH_USERNAME=]
  -p, --agh-password <AGH_PASSWORD>
          AGH password [env: AGH_PASSWORD=]
  -i, --scrape-interval <SCRAPE_INTERVAL>
          Scrape interval, in seconds. Should ideally be less than half the Prometheus server scrape interval [env: AGH_SCRAPE_INTERVAL=] [default: 5]
  -h, --help
          Print help
  -V, --version
          Print version

Using Docker

Pull the image from the GitHub Container Registry:

$ docker pull ghcr.io/molguin92/agh-exporter-rs:latest

You can also include the image in a docker-compose.yml like so:

version: '3'
services:
  agh-exporter:
    image: ghcr.io/molguin92/agh-exporter-rs:latest
    environment:
      AGH_HOST: http://localhost/adguard/control/
      AGH_SERVE_ADDR: http://localhost:9100/metrics
      AGH_USERNAME: foo
      AGH_PASSWORD: bar
      AGH_SCRAPE_INTERVAL: 5
    ports:
      - "9100:9100"
    restart: on-failure

Make sure to update the environment variables to match your AdGuard Home deployment.

Building locally

Clone the repository and build with cargo:

$ git clone git@github.com:molguin92/agh-exporter-rs.git

$ cd agh-exporter-rs

$ cargo build

License

Licensed under an Apache 2.0 License. See LICENSE for details.

Commit count: 0

cargo fmt