No description
Find a file
2023-11-27 19:58:58 +01:00
.forgejo/workflows Add periodic automatic re-build of latest published version #noissue 2023-11-27 19:58:58 +01:00
check-storage.sh Initial adapted version 2023-03-24 00:51:53 +01:00
Dockerfile Move to Forgejo (#1) 2023-08-17 19:25:57 +00: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 Update README.md 2023-08-17 19:27:11 +00:00

Hetzner Storage Exporter

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

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

The main git repository is hosted at https://git.myservermanager.com/varakh/hetzner-storagebox-exporter. Other repositories are mirrors and pull requests, issues, and planning are managed there.

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.