sing-box icon indicating copy to clipboard operation
sing-box copied to clipboard

metric-api: Add prometheus metrics

Open juvenn opened this issue 1 year ago • 4 comments

It adds Prometheus metrics api, along with built-in go process metrics, it includes a few more packet metrics

  "experimental": {
    "metrics": {
      "listen": ":8080"
    }
  }
curl localhost:8080/metrics

# HELP inbound_packet_bytes Total bytes of inbound packets
# TYPE inbound_packet_bytes counter
inbound_packet_bytes{inbound="mixed-in",user=""} 1310
# HELP outbound_packet_bytes Total bytes of outbound packets
# TYPE outbound_packet_bytes counter
outbound_packet_bytes{outbound="DIRECT",user=""} 4081
outbound_packet_bytes{outbound="Proxies",user=""} 8704

It should close #87 and serves a starting point for #1564

juvenn avatar Aug 24 '24 04:08 juvenn

@nekohasekai PTAL, let me know if you've any questions.

juvenn avatar Aug 27 '24 08:08 juvenn

New features need to be designed. Instead of providing an example PR, you should open an issue to discuss what statistics should be provided.

nekohasekai avatar Aug 28 '24 00:08 nekohasekai

Ok. Following #87, I noticed pull request welcome is labelled, so I assume a pull-request could better showcase how it look like.

No problem, should I open a new issue to discuss the design? is there a PR example I could look into, or contribution guideline I can follow on?

Thanks for taking a look!

juvenn avatar Aug 28 '24 09:08 juvenn

Sorry, I don't have experience with this either, maybe you can refer to the prometheus metrics provided by Clash and make a proposal.

nekohasekai avatar Aug 28 '24 14:08 nekohasekai