Git Product home page Git Product logo

clash-exporter's Introduction

Clash Exporter

This is an exporter for Clash, for used by the Prometheus to monitor clash network traffic.

Usage

run in command

Go to https://github.com/zxh326/clash-exporter/releases download latest release binary file

โžœ  ./clash-exporter -h
Usage of ./clash-exporter:
  -collectDest
        enable collector dest
        Warning: if collector destination enabled, will generate a large number of metrics, which may put a lot of pressure on Prometheus. (default true)
  -collectTracing
        enable collector tracing.
        It must be the Clash premium version, and the profile.tracing must be enabled in the Clash configuration file. (default false)
  -port int
        port to listen on (default 2112)

deploy with docker compose

git clone https://github.com/zxh326/clash-exporter

# check docker-compose.yml and update environment
cat docker-compose.yml
docker compose up -d

visit localhost:3000 and import example dashboard or via id 18530

tips: grafana default username / password is admin/admin

Prometheus Example Config

- job_name: "clash"
  metrics_path: /metrics
  scrape_interval: 1s
  static_configs:
    - targets: ["127.0.0.1:2112"]

Record Rule Config

groups:
  - name: discard_destination
    rules:
      - record: source_policy_type:clash_network_traffic_bytes_total:sum
        expr: sum without (destination, job) (clash_network_traffic_bytes_total)

Grafana Example Dashboard

  • You can import clash-dashboard.json to obtain the example effect, or you can create one yourself based on the following metrics introduction.

  • or Import via grafana.com with id 18530

Metrics

Metric name Metric type Labels
clash_info Gauge version, premium
clash_download_bytes_total Gauge
clash_upload_bytes_total Gauge
clash_active_connections Gauge
clash_network_traffic_bytes_total Counter source,destination(if enabled),policy,type(download,upload)
clash_tracing_rule_match_duration_milliseconds Histogram
clash_tracing_dns_request_duration_milliseconds Histogram type(dnsType)
clash_tracing_proxy_dial_duration_milliseconds Histogram policy

FAQ

  • tracing metrics is empty

    • Required clash premium version
    • Follow clash profile docs enable profile tracing
    • Add -collectTracing=true flag in clash-exporter start script
  • high Prometheus Memory

    This may be caused by the default enable of collector destination traffic, which can generate a large number of metrics. Try use -collectDest=false disable it.

TODO

  • dns query metrics
  • proxy dial metrics

clash-exporter's People

Contributors

zxh326 avatar

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.