Git Product home page Git Product logo

agh-exporter-rs's Introduction

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 [email protected]:molguin92/agh-exporter-rs.git

$ cd agh-exporter-rs

$ cargo build

License

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

agh-exporter-rs's People

Contributors

molguin92 avatar

Watchers

 avatar  avatar

Forkers

fuataydin8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.