Git Product home page Git Product logo

restic-metrics-to-pushgateway's Introduction

Restic snapshot metrics to Prometheus Pushgateway

Simple script to push metrics of the latest restic backup snapshot to Prometheus Pushgateway.

There are also Prometheus exporters for restic, but the underlying restic stats command they use comes with high CPU and memory consumption (#2126). Since I'm only interested in the last snapshot for alerting rather than creating detailed dashboards, regularly pushing the latest snapshot infos seemed to be the easier route.

Usage

The scripts expects environment variables to access the restic repository, and the Pushgateway URL as parameter:

usage: restic_metrics_to_pushgateway.py [-h] [--loglevel] --pushgateway_url URL [--tls_skip_verify]

Send metrics of latest restic snapshot to Prometheus Pushgateway.

options:
  -h, --help            show this help message and exit
  --loglevel LEVEL      log level ({CRITICAL,ERROR,WARNING,INFO,DEBUG}, default: INFO)
  --pushgateway_url URL Prometheus Pushgateway URL
                        (e.g. "http://pushgateway.example.org:9091/metrics/job/some_job/instance/some_instance")
  --tls_skip_verify     Skip TLS certificate verification.

Example Prometheus alerting rule

groups:
  - name: restic
    rules:
      - alert: ResticOutdatedBackup
        annotations:
          summary: Restic backup on {{ $labels.hostname }} is outdated
          description: |
            Restic backup on {{ $labels.hostname }} is outdated:
            Last backup: {{ $value | humanizeTimestamp }}
            User: {{ $labels.username }}
            Paths: {{ $labels.paths }}
            Tags: {{ $labels.tags }}
        # 86400 = 24 hours
        expr: time() - restic_last_snapshot{hostname!="ares"} > 86400
        for: 24h
        labels:
          severity: critical

License

MIT

restic-metrics-to-pushgateway's People

Contributors

fhemberger avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.