Skip to content

zcbxxx1/clash-exporter-tracing

 
 

Repository files navigation

Clash Exporter

This is an exporter for Clash, for used by the Prometheus and loki to monitor clash network traffic.
该项目融合了zxh326/clash-exporterclash-tracing_by_Dreamacro两位大佬的作品并在OpenClash上运行良好
(关于OpenClash的P核 即tun核如何开启tracing参考) vernesong/OpenClash#2154

图片 图片 图片

Usage

deploy with docker compose

git clone [https://github.com/zxh326/clash-exporter](https://github.com/zcbxxx1/clash-exporter-tracing)

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

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

About

A prometheus and loki exporter for clash

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published