Skip to content

Prometheus api

Prometheus API is not included by default, see Installation.

Structure

{
  "listen": "127.0.0.1:9090",
  "path": "/metrics",
  "export": "sing-box",
  "basic_auth_username": "",
  "basic_auth_password": "",
  "label_whitelist": [],
  "label_blacklist": []
}

Example

{
  "experimental": {
    "prometheus_api": {
      "listen": "127.0.0.1:9090",
      "export": "my-sing-box"
    }
  }
}

Fields

listen

Prometheus API listening address. Prometheus API will be disabled if empty.

path

Metrics path, default /metrics.

The Prometheus scrape path must match this value in your scrape_configs.

export

The value of the export label on all metrics, default sing-box.

Use this to differentiate multiple sing-box instances when scraping them into the same Prometheus.

basic_auth_username

Username for Basic Auth. Both basic_auth_username and basic_auth_password must be set together.

Basic Auth is recommended when Prometheus API is listening on a non-loopback address.

basic_auth_password

Password for Basic Auth. Both basic_auth_username and basic_auth_password must be set together.

Basic Auth is recommended when Prometheus API is listening on a non-loopback address.

label_whitelist

List of label keys to include in per-connection metrics.

When set, only the specified label keys will be present. The export label is always included.

Mutually exclusive with label_blacklist.

label_blacklist

List of label keys to exclude from per-connection metrics.

When set, all label keys except the specified ones will be present. The export label is never excluded.

Mutually exclusive with label_whitelist.

label_whitelist and label_blacklist cannot be used together.