Optional service for the TubeArchivist project to export metrics for users who run prometheus/grafana
Go to file
simon 592d03f936 reset head to master after build 2022-05-08 08:01:32 +07:00
.github/ISSUE_TEMPLATE Update issue templates 2022-05-07 17:12:45 +01:00
tubearchivist-metrics re-formatting prints to utilise printf 2022-05-03 02:24:09 +01:00
.gitignore updating gitignore to ignore __pycache__ 2022-04-14 19:46:57 +01:00
CONTRIBUTING.md Adding in contributing / issues file 2022-04-14 19:19:17 +01:00
Dockerfile Bumping base image version to match main repository 2022-05-07 17:05:01 +01:00
LICENSE Adding in License 2022-04-14 19:18:53 +01:00
README.md Merge pull request #5 from tubearchivist/testing 2022-05-08 01:50:20 +01:00
deploy.sh reset head to master after build 2022-05-08 08:01:32 +07:00


Tube Archivist Metrics

Provide Tube Archivist metrics in Prometheus/OpenMetrics format

This is an optional service as part of the Tube Archivist stack.

This is WIP


Metrics reported

channel_count = Number of channels
playlist_count = Number of playlists
download_count = Number of downloads
download_queue = Number of pending downloads
subtitle_count = Number of subtitles downloaded for videos


Environment variables

ES_URL: The URL to your ElasticSearch server. Defaults to http://archivist-es:9200
ES_USER: The username for authentication to ElasticSearch. Defaults to elastic
ES_PASSWORD: The password for authentication to ElasticSearch. No default is set.
LISTEN_PORT: The listen port for the metrics server to run on. Defaults to 9934
POLL_INTERVAL: The interval in seconds for the data to be scraped from ElasticSearch. Defaults to 60

Running via Docker Compose (supported)

This metrics service is designed to be ran inside of docker.

To view the main compose file for TubeArchivist, please see the main repository here: TA Repo

To add the metrics service in, place this into your compose file and update the environment variables as required.

    image: bbilly1/tubearchivist-metrics:latest
    container_name: archivist-metrics
    restart: always
      - "ES_USER=elastic"
      - "ES_PASSWORD=verysecret"
      - "ES_URL=http://archivist-es:9200"
      - "LISTEN_PORT=9934"
      - "POLL_INTERVAL=60"
      - 9934:9934

Running via Standalone

Should you want to, you can install and run this without docker.

To do so, clone this repo, install the python libraries with pip3 install -r requirements.txt

then run python3 tubearchivist-metrics/main.py

Environment variables can be passed in via normal syntax for your OS.

Prometheus example config

      - job_name: 'tubearchivist-metrics'
        metrics_path: /
          - targets:
              - <server>:9934

How are metrics gathered?

Typically, a prometheus server will poll the HTTP endpoint of the metrics service to obtain its metrics.

In most scenarios, a service will then retrieve the data for the metric, and then respond to the prometheus http call. However this can be quite harsh on databases and applications, especially when prometheus is polling every 15 seconds.

To prevent performance issues and unncessecary load on ElasticSearch. We prefetch the metric information from ES every 60 seconds (default). The metric is then updated on the HTTP endpoint after we have retrieved the data and cached for prometheus to scrape.

This means prometheus can scrape the endpoint every second if it likes, but no database calls to ES will be made until the polling interval is reached.

If you require more granular polling, you can update the POLLING_INTERVAL environment variable