Skip to content

feat(metrics): serve /metrics endpoint with prometheus-save-to-file - #667

Open
alex-ganin wants to merge 3 commits into
creativeprojects:masterfrom
alex-ganin:master
Open

feat(metrics): serve /metrics endpoint with prometheus-save-to-file#667
alex-ganin wants to merge 3 commits into
creativeprojects:masterfrom
alex-ganin:master

Conversation

@alex-ganin

Copy link
Copy Markdown

Adds an experimental HTTP endpoint that exposes a profile's prometheus-save-to-file together with the Go runtime metrics on /metrics, so a sidecar Prometheus can scrape the last backup status from either the schedule command or a stand-alone sidecar.

Two integration points, both opt-in via the hidden --metrics-port flag (or RESTICPROFILE_METRICS_PORT):

  • resticprofile --metrics-port schedule --all schedules cron jobs as usual, then blocks on SIGINT/SIGTERM serving /metrics for every profile and group. Textfile paths are de-duplicated across profiles that share one.

  • resticprofile --metrics-port serve-metrics long-running single-profile sidecar.

Response contract:

  • 200 OK runtime metrics + textfile body
  • 503 Service textfile not yet created (first backup has not run).
    Unavailable Prometheus treats this as up == 0 instead of a 404
    every scrape.
  • 500 Internal other I/O errors.

The endpoint binds on 0.0.0.0: for network_mode: host containers.

The serve command no longer mounts a companion metrics server; the two endpoints above cover the documented use cases without coupling the metrics feature to the experimental client/server mode.

alex-ganin and others added 3 commits July 10, 2026 21:28
Adds an experimental HTTP endpoint that exposes a profile's
prometheus-save-to-file together with the Go runtime metrics on /metrics,
so a sidecar Prometheus can scrape the last backup status from either the
schedule command or a stand-alone sidecar.

Two integration points, both opt-in via the hidden --metrics-port flag
(or RESTICPROFILE_METRICS_PORT):

  * resticprofile --metrics-port <port> schedule --all
      schedules cron jobs as usual, then blocks on SIGINT/SIGTERM
      serving /metrics for every profile and group. Textfile paths are
      de-duplicated across profiles that share one.

  * resticprofile --metrics-port <port> <profile> serve-metrics
      long-running single-profile sidecar.

Response contract:
  * 200 OK           runtime metrics + textfile body
  * 503 Service      textfile not yet created (first backup has not run).
    Unavailable      Prometheus treats this as up == 0 instead of a 404
                     every scrape.
  * 500 Internal     other I/O errors.

The endpoint binds on 0.0.0.0:<port> for network_mode: host containers.

The serve command no longer mounts a companion metrics server; the two
endpoints above cover the documented use cases without coupling the
metrics feature to the experimental client/server mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant