A Prometheus exporter for Todoist
Project description
Prometheus Todoist Exporter
Extract Todoist API metrics via Prometheus with this exporter.
[!IMPORTANT] This project is not affiliated with Todoist. It is a community-driven project.
Features
- Collects metrics from the Todoist API using the official Python client
- Exposes these metrics in Prometheus format
- Provides comprehensive task, project, collaborator, section, and comment metrics
- Tracks completed tasks through the Todoist Sync API
- Monitors tasks by labels, sections, and due dates
- 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
Metrics
The exporter provides the following metrics:
| Metric | Description | Labels |
|---|---|---|
todoist_tasks_total |
Total number of active tasks | project_name, project_id |
todoist_tasks_overdue |
Number of overdue tasks | project_name, project_id |
todoist_tasks_due_today |
Number of tasks due today | project_name, project_id |
todoist_project_collaborators |
Number of collaborators per project | project_name, project_id |
todoist_sections_total |
Number of sections per project | project_name, project_id |
todoist_comments_total |
Number of comments | project_name, project_id |
todoist_priority_tasks |
Number of tasks by priority | project_name, project_id, priority |
todoist_api_errors |
Number of API errors encountered | endpoint |
todoist_scrape_duration_seconds |
Time taken to collect Todoist metrics | - |
todoist_tasks_completed_today |
Number of tasks completed today | project_name, project_id |
todoist_tasks_completed_week |
Number of tasks completed in the last N days | project_name, project_id, days |
todoist_tasks_completed_hours |
Number of tasks completed in the last N hours | project_name, project_id, hours |
todoist_section_tasks |
Number of tasks in a section | project_name, project_id, section_name, section_id |
todoist_label_tasks |
Number of tasks with a specific label | label_name |
todoist_tasks_with_due_date |
Number of tasks with a due date | project_name, project_id |
todoist_recurring_tasks |
Number of recurring tasks | project_name, project_id |
todoist_sync_api_completed_tasks |
Number of tasks completed via Sync API | project_name, project_id, timeframe |
Grafana Dashboard
This project includes a pre-configured Grafana dashboard to visualize the exported metrics. You can find the dashboard definition in grafana/dashboard.json.
To import the dashboard into your Grafana instance:
- Navigate to your Grafana UI.
- Go to
Dashboards->Browse. - Click the
Importbutton (usually in the top right). - Click
Upload JSON fileand select thegrafana/dashboard.jsonfile from this repository. - Alternatively, you can paste the JSON content directly into the text area.
- Configure the dashboard options, such as selecting your Prometheus data source.
- Click
Import.
This dashboard provides panels for visualizing active tasks, completion trends, task breakdowns by project/priority/label, and exporter health metrics.
Configuration
The exporter can be configured using environment variables:
| Variable | Description | Default |
|---|---|---|
TODOIST_API_TOKEN |
Todoist API token (required) | - |
EXPORTER_PORT |
Port for the HTTP server | 9090 |
METRICS_PATH |
HTTP path for metrics | /metrics |
COLLECTION_INTERVAL |
Seconds between metric collections | 60 |
COMPLETED_TASKS_DAYS |
Number of days to look back for completed tasks | 7 |
COMPLETED_TASKS_HOURS |
Number of hours to look back for completed tasks | 24 |
Installation
Using Docker
Pull the latest image from GitHub Container Registry:
docker pull ghcr.io/echohello-dev/prometheus-todoist-exporter:latest
Run the exporter:
docker run -p 9090:9090 -e TODOIST_API_TOKEN=your_api_token ghcr.io/echohello-dev/prometheus-todoist-exporter:latest
Using Docker Compose
- Copy the example environment file and edit it with your API token:
cp .env.example .env
# Edit .env with your Todoist API token
- Then start the services:
docker-compose up -d
This will start both the Todoist exporter and a Prometheus instance configured to scrape metrics from the exporter.
Using Kubernetes
Kubernetes manifests are provided in the deploy/kubernetes directory. These can be applied directly or deployed with Kustomize.
-
Create the namespace:
kubectl create namespace monitoring
-
Create a Secret with your Todoist API token:
TODOIST_API_TOKEN_B64=$(echo -n 'your-todoist-api-token' | base64) sed "s/<BASE64_ENCODED_API_TOKEN>/$TODOIST_API_TOKEN_B64/" deploy/kubernetes/secret.yaml | kubectl apply -f -
Or create the Secret manually:
kubectl create secret generic todoist-secret -n monitoring --from-literal=api-token=your-todoist-api-token
-
Deploy with Kustomize:
kubectl apply -k deploy/kubernetes
-
To access the metrics endpoint:
kubectl port-forward -n monitoring service/prometheus-todoist-exporter 9090:9090
-
View the metrics at http://localhost:9090/metrics
Using Helm
A Helm chart is available in the deploy/helm/prometheus-todoist-exporter directory.
-
Deploy the chart:
helm install todoist-exporter ./deploy/helm/prometheus-todoist-exporter \ --namespace monitoring --create-namespace \ --set todoist.apiToken="your-todoist-api-token"
-
Configure with custom values:
helm install todoist-exporter ./deploy/helm/prometheus-todoist-exporter \ --namespace monitoring --create-namespace \ --set todoist.apiToken="your-todoist-api-token" \ --set exporter.collectionInterval=30 \ --set service.type=NodePort
-
Using a custom values file:
# Create a values.yaml file with your custom configuration cat > my-values.yaml << EOF todoist: apiToken: "your-todoist-api-token" exporter: collectionInterval: 30 serviceMonitor: enabled: true EOF # Install with custom values helm install todoist-exporter ./deploy/helm/prometheus-todoist-exporter \ --namespace monitoring --create-namespace \ --values my-values.yaml
-
To upgrade the deployment:
helm upgrade todoist-exporter ./deploy/helm/prometheus-todoist-exporter \ --namespace monitoring \ --reuse-values \ --set exporter.completedTasksDays=14
-
To uninstall:
helm uninstall todoist-exporter --namespace monitoring
Using Poetry
-
Install Poetry (if not already installed):
curl -sSL https://install.python-poetry.org | python3 -
-
Install the package:
poetry add prometheus-todoist-exporter
-
Set up your environment variables:
cp .env.example .env # Edit .env with your Todoist API token
-
Run the exporter:
source .env && poetry run todoist-exporter
Local Development
Quick Start
-
Clone the repository:
git clone https://github.com/echohello-dev/prometheus-todoist-exporter.git cd prometheus-todoist-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 Todoist 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-todoist-exporter.git cd prometheus-todoist-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:
# Set up local development environment (copy .env.example to .env and install deps)
task setup-dev
# Set up asdf with all required tools
task setup
# Install dependencies
task install
# Format the code with Ruff
task format
# Run linting with Ruff
task lint
# Run linting and fix issues with Ruff
task lint-fix
# Run tests
task test
# Run the exporter
task run
# Install pre-commit hooks
task pre-commit-install
# Run pre-commit checks on all files
task pre-commit-run
# Update pre-commit hooks to latest versions
task pre-commit-update
# Build Docker image
task docker-build
# Run Docker container
task docker-run
# Start services with docker-compose
task docker-compose-up
# Stop services with docker-compose
task docker-compose-down
# Deploy to Kubernetes with kustomize
task k8s-deploy
# Delete Kubernetes deployment
task k8s-delete
# Deploy with Helm
task helm-deploy
# Delete Helm deployment
task helm-delete
# Lint Helm chart
task helm-lint
# Generate Kubernetes manifests from Helm chart
task helm-template
# Run all quality checks (format, lint, test)
task all
Building from Source
-
Clone the repository:
git clone https://github.com/echohello-dev/prometheus-todoist-exporter.git cd prometheus-todoist-exporter
-
Install tools and dependencies (requires asdf):
task setup-asdf 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
- Ensures code quality and functionality
-
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 with:
- Latest release version
- Latest tag (for release only)
- Branch name (for non-release builds)
- Git SHA
Required Secrets
To enable these workflows, ensure the following secrets are set in your repository:
-
For PyPI publishing:
POETRY_PYPI_TOKEN_PYPI: A PyPI API token with upload permissions
-
For Docker publishing:
- GitHub Token with
packages:writepermission (automatic)
- GitHub Token with
Development to Production Workflow
-
Local Development
- Set up local environment using:
cp .env.example .env # Add your Todoist API token task setup-dev # Install dependencies ``` - Make code changes and test locally with: ```bash source .env && task run
- Set up local environment using:
-
Submit Changes
- Create a pull request with your changes
- CI will run tests to ensure quality
-
Release Process
- Release Please will automatically create a release PR when changes are merged to main
- When the release PR is merged:
- A GitHub release is created
- The PyPI package is published
- The Docker container is built and published to GHCR
-
Using the Released Version
- Pull the latest container image:
docker pull ghcr.io/echohello-dev/prometheus-todoist-exporter:latest
- Or run with docker-compose:
cp .env.example .env # Add your Todoist API token docker-compose up -d
- Pull the latest container image:
Helm Chart Management
The project includes a Helm chart in the deploy/helm/prometheus-todoist-exporter directory. When making changes to the Helm chart, follow these guidelines:
Chart Versioning
- The Helm chart follows semantic versioning (
major.minor.patch) - Chart version is specified in
deploy/helm/prometheus-todoist-exporter/Chart.yaml - When updating the chart:
- For non-breaking changes, increment the patch version
- For new features (non-breaking), increment the minor version
- For breaking changes, increment the major version
Testing Chart Changes
Before committing chart changes:
-
Lint the chart:
task helm-lint -
Test template rendering:
task helm-template -
Test installation in a dev environment:
task helm-deploy
Chart Documentation
Keep the chart documentation in deploy/helm/prometheus-todoist-exporter/README.md synchronized with any changes to:
- Chart parameters and defaults
- Required Kubernetes versions
- Examples
Release Process
When a new version of the exporter is released, the chart's appVersion should be updated to match the released version.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prometheus_todoist_exporter-1.1.0.tar.gz.
File metadata
- Download URL: prometheus_todoist_exporter-1.1.0.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.13.2 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81d99750b6a37bd4ed504100777eea110935c2a9d0eec07a20c2a1b9ab4669b0
|
|
| MD5 |
30503dc8813acb0d37c064122e574ccd
|
|
| BLAKE2b-256 |
58b24f5aca018e3da6a6d9fdf3832c53fb1ff7e61f37cfe5c69d902428149088
|
File details
Details for the file prometheus_todoist_exporter-1.1.0-py3-none-any.whl.
File metadata
- Download URL: prometheus_todoist_exporter-1.1.0-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.13.2 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb023a990dff5752eabd8b629cb63a24afeabe13a0d22059e9f65130807e264b
|
|
| MD5 |
0f12ce4b0e8d99b2fbbfa22c96048410
|
|
| BLAKE2b-256 |
f6228fa8864f17f7e889ddc57f3cb923e6a36ef6bd9bbd66e1fa349049ae2587
|