hetzner-storagebox-exporter/README.md

95 lines
2.9 KiB
Markdown
Raw Permalink Normal View History

2022-10-06 20:43:36 +00:00
# Hetzner Storage Exporter
2023-03-23 23:51:53 +00:00
**Initially forked from https://github.com/gmasil/hetzner-storagebox-exporter**.
- Applied some improvements
- Adapted documentation
- Added pipeline for publish to DockerHub
2023-03-24 07:53:20 +00:00
The main git repository is hosted at **[https://git.myservermanager.com/varakh/hetzner-storagebox-exporter](https://git.myservermanager.com/varakh/hetzner-storagebox-exporter)**.
Other repositories are mirrors and pull requests, issues, and planning are managed there.
2022-10-06 20:43:36 +00:00
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:
2023-03-23 23:51:53 +00:00
```shell
# HELP hetzner_storage_available Available storage in kilobytes
2022-10-06 20:43:36 +00:00
# TYPE hetzner_storage_available gauge
hetzner_storage_available{host="u123456.your-storagebox.de"} 1062381134
2023-03-23 23:51:53 +00:00
# HELP hetzner_storage_used Used storage in kilobytes
# TYPE hetzner_storage_used gauge
2022-10-06 20:43:36 +00:00
hetzner_storage_used{host="u123456.your-storagebox.de"} 11360690
2023-03-23 23:51:53 +00:00
# HELP hetzner_storage_total Total storage in kilobytes
# TYPE hetzner_storage_total gauge
2022-10-06 20:43:36 +00:00
hetzner_storage_total{host="u123456.your-storagebox.de"} 1073741824
```
# Build
Build simply with docker:
```bash
2023-03-23 23:51:53 +00:00
docker build --no-cache -t "varakh/hetzner-storagebox-exporter:latest" .
2022-10-06 20:43:36 +00:00
```
2023-03-23 23:51:53 +00:00
**Note:** This will build an image called `varakh/hetzner-storagebox-exporter:latest`.
2022-10-06 20:43:36 +00:00
# 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.
2023-03-23 23:51:53 +00:00
Usage with `docker`:
2022-10-06 20:43:36 +00:00
```bash
2023-03-23 23:51:53 +00:00
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
2022-10-06 20:43:36 +00:00
```
2023-03-23 23:51:53 +00:00
Example `docker-compose` file:
2022-10-06 20:43:36 +00:00
2023-03-23 23:51:53 +00:00
```yml
2022-10-06 20:43:36 +00:00
version: '3'
services:
hetzner-storage-exporter:
2023-03-23 23:51:53 +00:00
container_name: hetzner-storage-exporter
restart: unless-stopped
image: varakh/hetzner-storagebox-exporter:latest
port:
- "9494:80"
2022-10-06 20:43:36 +00:00
environment:
- "USERNAME=u123456"
volumes:
2023-03-23 23:51:53 +00:00
- "/home/myuser/.ssh/id_rsa:/root/.ssh/id_rsa"
- "/home/myuser/.ssh/known_hosts:/root/.ssh/known_hosts"
2022-10-06 20:43:36 +00:00
```
## Prometheus
In your `prometheus.yml` you can add the hetzner-storage-exporter like this:
```yml
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.