Skip to content

Monitoring

BastionXP CA serves metrics for Prometheus on an address of its own, never on the addresses clients use.

metrics:
  address: 127.0.0.1:9100
  token_file: /etc/bastionxp-ca/metrics-token   # optional

The metrics are at http://<address>/metrics.

Choosing the address

127.0.0.1 works only for a Prometheus on the CA machine itself. For one elsewhere, bind to an address it can reach:

Where Prometheus is metrics.address
On the CA machine 127.0.0.1:9100
On another machine The CA's internal address, e.g. 10.0.0.5:9100, with a firewall rule that lets only the Prometheus server in. Avoid 0.0.0.0 on a machine with a public interface.
BastionXP CA in a container 0.0.0.0:9100 inside the container (its 127.0.0.1 is not reachable even from the host), published to an internal address only: -p 10.0.0.5:9100:9100.
Kubernetes 0.0.0.0:9100, with a NetworkPolicy that lets only Prometheus in.

Protecting the endpoint

With token_file, only requests with Authorization: Bearer <token> get the metrics. Use it whenever the address is reachable from other machines.

openssl rand -base64 32 | sudo install -m 600 -o bastionxp-ca /dev/stdin /etc/bastionxp-ca/metrics-token

Prometheus scrape job:

prometheus.yml
scrape_configs:
  - job_name: bastionxp-ca
    static_configs:
      - targets: ["10.0.0.5:9100"]
    authorization:
      credentials_file: /etc/prometheus/bastionxp-ca-token

Metrics

The metrics are counts and dates, never names, serial numbers or usernames (who got what is in the log).

Metric Labels What it counts
bastionxp_ca_certificates_issued_total kind, verifier Certificates issued. verifier: token, login, acme, scep, scep_static, renewal, scep_renewal.
bastionxp_ca_requests_refused_total reason Refusals: invalid_token, token_used, wrong_key, not_allowed, unsound, rate_limited.
bastionxp_ca_logins_total method, result OIDC and LDAP logins: success, failed, no_rule, too_many_failures.
bastionxp_ca_certificates kind, state Certificates in the database: valid, expired, revoked. Read from the database, so it includes bxp revoke.
bastionxp_ca_ca_certificate_expiry_timestamp_seconds certificate When the root and the intermediate expire (Unix time).
bastionxp_ca_http_request_duration_seconds route, code Requests and their duration (histogram).
bastionxp_ca_build_info version The version.

Alerts

bastionxp-ca-alerts.yml
groups:
  - name: bastionxp-ca
    rules:
      - alert: BastionXPCAIntermediateExpiresSoon
        expr: bastionxp_ca_ca_certificate_expiry_timestamp_seconds{certificate="intermediate"} - time() < 180 * 86400
        annotations:
          summary: "The BastionXP CA intermediate expires in less than 180 days: run bxp new-intermediate"
      - alert: BastionXPCALoginFailures
        expr: increase(bastionxp_ca_logins_total{result=~"failed|too_many_failures"}[15m]) > 20
        annotations:
          summary: "Many failed logins at BastionXP CA"
      - alert: BastionXPCADown
        expr: up{job="bastionxp-ca"} == 0
        for: 5m

Other checks

Check How
Liveness GET /health on the HTTPS address returns {"status":"ok"}.
Full setup bxp doctor, exit status 1 on failure.
Audit trail The log.