Skip to content

A simple Python HTTP server exporting OwnTracks Recorder stats for Prometheus

License

Notifications You must be signed in to change notification settings

linusg/prometheus-owntracks-exporter

Repository files navigation

Prometheus OwnTracks Exporter

A simple Python HTTP server exporting OwnTracks Recorder stats for Prometheus

Build (Docker) Lint Docker Pulls License Black

Installation

Docker

Pre-built Docker images are available on Docker Hub: linusgroh/prometheus-owntracks-exporter

docker run -d \
  -v "/path/to/owntracks/storage:/owntracks" \
  -e OWNTRACKS_STORAGEDIR="/owntracks" \
  -e OWNTRACKS_URL="http:https://owntracks-recorder:8083" \
  linusgroh/prometheus-owntracks-exporter

Docker Compose

services:
  owntracks-recorder:
    ...

  prometheus:
    ...

  prometheus-owntracks-exporter:
    image: linusgroh/prometheus-owntracks-exporter
    depends_on:
      - prometheus
    volumes:
      - /path/to/owntracks/storage:/owntracks
    environment:
      OWNTRACKS_STORAGEDIR: /owntracks
      OWNTRACKS_URL: http:https://owntracks-recorder:8083

Manually

poetry install --no-root --no-dev
poetry run python main.py

Development

poetry install --no-root
poetry run uvicorn main:app --reload

Configuration

Configuration is done via environment variables (or by adding a .env file).

Name Description Default
DEBUG Run the underlying Starlette ASGI app in debug mode False
OWNTRACKS_STORAGEDIR Path to the OwnTracks Recorder storage directory (OTR_STORAGEDIR, --storagedir)
OWNTRACKS_URL Base URL to the OwnTracks Recorder's HTTP API (without /api/...)
SERVER_HOST HTTP server host "0.0.0.0"
SERVER_PORT HTTP server port 80
UPDATE_INTERVAL Interval in which the metrics are updated (in seconds) 60

prometheus.yml

scrape_configs:
  - job_name: 'owntracks'
    static_configs:
      - targets: ['prometheus-owntracks-exporter:80']

Metrics

Name Description
owntracks_cards_count Total number of cards
owntracks_devices_count Total number of devices
owntracks_last_locations_count Total number of last locations
owntracks_last_received_timestamp Timestamp of the last received message
owntracks_locations_count Total number of locations
owntracks_storagedir_size Size of the OwnTracks Recorder's storage directory in bytes
owntracks_users_count Total number of users
owntracks_version_info OwnTracks Recorder version
owntracks_waypoints_count Total number of waypoints

Grafana

A simple Grafana dashboard is available in grafana/owntracks.json.