Prometheus Toggl Track Exporter
Extract Toggl Track API metrics via Prometheus with this exporter.
Features
- Collects metrics from the Toggl Track API v9 using the
requestslibrary - Exposes these metrics in Prometheus format
- Tracks currently running time entries
- Configurable through environment variables
- Includes Docker support for easy deployment
- Uses Poetry for dependency management
- Includes Taskfile for command orchestration
- Manages tool versions with asdf
- Uses Ruff for lightning-fast Python linting and formatting
- Includes a pre-configured Grafana dashboard (
grafana/dashboard.json) for visualizing metrics
Metrics
The exporter currently provides the following metrics:
| Metric | Description | Labels |
|---|---|---|
toggl_time_entry_running |
Indicates if a time entry is currently running (1=running, 0=stopped) | workspace_id, project_id, project_name, task_id, task_name, description, tags, billable |
toggl_time_entry_start_timestamp |
Start time of the current running time entry (Unix timestamp) | workspace_id, project_id, project_name, task_id, task_name, description, tags, billable |
toggl_api_errors |
Number of Toggl API errors encountered | endpoint |
toggl_scrape_duration_seconds |
Time taken to collect Toggl metrics | - |
More metrics (e.g., total projects, clients, tags) might be added in the future.
Configuration
The exporter can be configured using environment variables:
| Variable | Description | Default |
|---|---|---|
TOGGL_API_TOKEN |
Toggl Track API token (required) | - |
EXPORTER_PORT |
Port for the HTTP server | 9090 |
COLLECTION_INTERVAL |
Seconds between metric collections | 60 |
Installation
Using Docker
Pull the latest image from GitHub Container Registry:
docker pull ghcr.io/echohello-dev/prometheus-toggl-track-exporter:latest
Run the exporter:
docker run -p 9090:9090 -e TOGGL_API_TOKEN=your_api_token ghcr.io/echohello-dev/prometheus-toggl-track-exporter:latest
Using Docker Compose
The compose.yaml file sets up the Toggl Track exporter, a Prometheus instance, and a Grafana instance for visualization.
-
Copy the example environment file and edit it with your API token:
cp .env.example .env # Edit .env with your Toggl Track API token
-
Then start the services:
docker compose up -d # Or use 'task docker-compose-up'
This will start:
- The Toggl Track exporter (port
9090) - Prometheus (port
9091), pre-configured to scrape the exporter. - Grafana (port
3000), pre-configured with Prometheus as a data source and a default Toggl Track dashboard. Credentials areadmin / admin.
Access Grafana at http://localhost:3000 to view your metrics.
Using Poetry
-
Install Poetry (if not already installed):
curl -sSL https://install.python-poetry.org | python3 -
-
Install the package:
poetry add prometheus-toggl-track-exporter
-
Set up your environment variables:
cp .env.example .env # Edit .env with your Toggl Track API token
-
Run the exporter:
source .env && poetry run toggl-track-exporter
Local Development
Quick Start
-
Clone the repository:
git clone https://github.com/echohello-dev/prometheus-toggl-track-exporter.git cd prometheus-toggl-track-exporter
-
Set up development environment:
task setup-devThis will:
- Copy
.env.exampleto.env(if it doesn't exist) - Install dependencies via Poetry
- Install pre-commit hooks
- Copy
-
Edit the
.envfile with your Toggl Track API token:# Edit .env with your preferred editor nano .env
-
Run the exporter:
source .env && task run
Using asdf for tool version management
This project uses asdf to manage tool versions (Python, Poetry, Task).
-
Install asdf following the installation instructions.
-
Clone the repository:
git clone https://github.com/echohello-dev/prometheus-toggl-track-exporter.git cd prometheus-toggl-track-exporter
-
Install the required tools with asdf:
task setupThis will install the correct versions of Python, Poetry, and Task as specified in
.tool-versions, and set up your development environment. -
Run the exporter:
source .env && task run
-
Run tests:
task test
Pre-commit Hooks
This project uses pre-commit to enforce code quality and standards. The hooks ensure that all code commits meet the project's requirements.
To install the pre-commit hooks:
task pre-commit-install
To manually run the pre-commit checks:
task pre-commit-run
The following checks are included:
- Code formatting with Ruff
- Linting with Ruff
- Basic file checks (trailing whitespace, YAML validation, etc.)
- Poetry configuration verification
- Running tests
Using Taskfile
This project includes a Taskfile for easy command orchestration. You need to have Task installed, or you can use the version installed by asdf.
Available tasks (refer to Taskfile.yml for the full list):
# Set up local development environment
task setup-dev
# Set up asdf with all required tools
task setup
# Install dependencies
task install
# Format the code
task format
# Run linting
task lint
# Run tests
task test
# Run the exporter
task run
# Install pre-commit hooks
task pre-commit-install
# Run pre-commit checks
task pre-commit-run
# Build Docker image
task docker-build
# Run Docker container
task docker-run
# Start services with docker-compose
task docker-compose-up
# Run all quality checks (format, lint, test)
task all
Building from Source
-
Clone the repository:
git clone https://github.com/echohello-dev/prometheus-toggl-track-exporter.git cd prometheus-toggl-track-exporter
-
Install tools and dependencies (requires asdf):
task setup task install
-
Build the Docker image:
task docker-build
License
This project is licensed under the MIT License.
GitHub Workflow Setup
This repository uses GitHub Actions workflows for continuous integration, release management, and container publishing.
Workflow Overview
-
CI Workflow (
ci.yml)- Runs linting and tests for every push and pull request.
-
Release Please Workflow (
release-please.yml)- Automates versioning and release creation.
- Creates a PR with version bump and changelog updates.
- When merged, creates a GitHub release with appropriate tags.
-
PyPI Publish Workflow (
publish-pypi.yml)- Triggered when Release Please creates a new release.
- Builds and publishes the Python package to PyPI.
-
Docker Publish Workflow (
docker-publish.yml)- Builds and tests the Docker image.
- Publishes the image to GitHub Container Registry (
ghcr.io). - Tags the image appropriately (latest, version, SHA).
Required Secrets
POETRY_PYPI_TOKEN_PYPI: A PyPI API token for publishing.
Development to Production Workflow
- Local Development: Edit
.env, runtask setup-dev, code,source .env && task run. - Submit Changes: Create PR, CI runs.
- Release Process: Merge PR, Release Please creates release PR. Merge release PR -> GitHub Release, PyPI Publish, Docker Publish.
- Using Released Version:
docker pull ghcr.io/echohello-dev/prometheus-toggl-track-exporter:latestor usedocker-compose up -d.
Metadata
Release files for prometheus-toggl-track-exporter 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| prometheus_toggl_track_exporter-1.2.0.tar.gz | 14.7 kB | Without provenance | Details for prometheus_toggl_track_exporter-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| prometheus_toggl_track_exporter-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for prometheus_toggl_track_exporter-1.2.0-py3-none-any.whl |
Total release size: 28.4 kB
Release files / prometheus_toggl_track_exporter-1.2.0.tar.gz
| Download URL | prometheus_toggl_track_exporter-1.2.0.tar.gz |
|---|---|
| Size | 14.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bde8324787e58514be32737ed435a4786aaddca8eea9e990760eb2a3d2224f49
|
|
BLAKE2b-256 checksum How to use checksums |
2eb0170352bd751716a631955306b612db806dc5e21b449e2219ae075030a507
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.13.2 Linux/6.8.0-1021-azure
|
Release files / prometheus_toggl_track_exporter-1.2.0-py3-none-any.whl
| Download URL | prometheus_toggl_track_exporter-1.2.0-py3-none-any.whl |
|---|---|
| Size | 13.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7347dfb69ecebc4eb3909ccbfb366ebb77ef28cac45507833dbefb6492c591ee
|
|
BLAKE2b-256 checksum How to use checksums |
82c31b5e78f2afe389dfc7dc4f228d59f37bd9747526024a7c4cb12809cc92ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.13.2 Linux/6.8.0-1021-azure
|
Security for prometheus-toggl-track-exporter 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.