No description
Find a file
Varakh d488f9c10f
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Make pipeline more useful
2023-03-24 08:36:59 +01:00
.drone.yml Make pipeline more useful 2023-03-24 08:36:59 +01:00
check-storage.sh Initial adapted version 2023-03-24 00:51:53 +01:00
Dockerfile Initial adapted version 2023-03-24 00:51:53 +01:00
header.sh Initial adapted version 2023-03-24 00:51:53 +01:00
LICENSE.md init 2022-10-06 22:43:36 +02:00
README.md Add monthly rebuild of image 2023-03-24 01:01:17 +01:00

Hetzner Storage Exporter

Build Status

Initially forked from https://github.com/gmasil/hetzner-storagebox-exporter.

  • Applied some improvements
  • Adapted documentation
  • Added pipeline for publish to DockerHub

This is a simple prometheus exporter to provide storage space metrics of a Hetzner Storagebox.

Example

The exporter will start a webserver on port 80 (no HTTPS/TLS) and provide its metrics under every URI. The exporter checks the storage box under a given USERNAME. A SSH private key to login via SSH has to be provided and SSH has to be enabled in Hetzner Robot.

Here you can see an example output of the hetzner-storage-exporter:

# HELP hetzner_storage_available Available storage in kilobytes
# TYPE hetzner_storage_available gauge
hetzner_storage_available{host="u123456.your-storagebox.de"} 1062381134
# HELP hetzner_storage_used Used storage in kilobytes
# TYPE hetzner_storage_used gauge
hetzner_storage_used{host="u123456.your-storagebox.de"} 11360690
# HELP hetzner_storage_total Total storage in kilobytes
# TYPE hetzner_storage_total gauge
hetzner_storage_total{host="u123456.your-storagebox.de"} 1073741824

Build

Build simply with docker:

docker build --no-cache -t "varakh/hetzner-storagebox-exporter:latest" .

Note: This will build an image called varakh/hetzner-storagebox-exporter:latest.

Usage

The exporter will listen on port 80 and exposes it by default.

You have to provide your username for your storage box via environment variable USERNAME and a SSH private key to login. Additionally you need a known_hosts file to accept the SSH connection.

Usage with docker:

docker run --rm -p 80:80 -e "USERNAME=u123456" \
  -v "/home/myuser/.ssh/id_rsa:/root/.ssh/id_rsa" \
  -v "/home/myuser/.ssh/known_hosts:/root/.ssh/known_hosts" \
  varakh/hetzner-storagebox-exporter:latest

Example docker-compose file:

version: '3'

services:
  hetzner-storage-exporter:
    container_name: hetzner-storage-exporter
    restart: unless-stopped
    image: varakh/hetzner-storagebox-exporter:latest
    port:
      - "9494:80"
    environment:
      - "USERNAME=u123456"
    volumes:
      - "/home/myuser/.ssh/id_rsa:/root/.ssh/id_rsa"
      - "/home/myuser/.ssh/known_hosts:/root/.ssh/known_hosts"

Prometheus

In your prometheus.yml you can add the hetzner-storage-exporter like this:

global:
  scrape_interval: 15s
  evaluation_interval: 15s

scrape_configs:
  - job_name: "hetznerstorage"
    static_configs:
      - targets:
          - hetzner-storage-exporter:80

Note: As the exporter will provide the metrics on all URIs, you can leave all defaults like scraping on the /metrics URI.