This project is a Python script that exports data from a Matomo instance to Prometheus. It is designed to be as simple as possible to use and deploy in a container.
Since Matomo works with 'period' (day, week, month, year), the exporter will export the data for all types of periods and use labels to differentiate them.
- Create a docker-compose file with the following content:
services:
matomo-exporter:
build:
context: .
dockerfile: Dockerfile
image: ghcr.io/qjoly/matomo-exporter:1.0.0
restart: always
ports:
- 9000:9000
env_file: .env
environment:
- LOG_LEVEL=DEBUG
- SCRAPE_INTERVAL=60
- Create a
.env
file with the following content using your Matomo URL and token:
MATOMO_URL=https://matomo.yourdomain.com
MATOMO_TOKEN=yourtoken
Note: You can get your token by going to your Matomo instance on path /index.php?module=UsersManager&action=userSecurity
or in the Auth tokens
section of the Security
tab.
- Run the container with the following command:
docker-compose up -d
- Access the metrics on
http://localhost:9000/metrics
.
You can configure the exporter using environment variables or arguments.
The following environment variables are available:
Environment variable | Argument | Description | Default |
---|---|---|---|
MATOMO_URL |
--url |
Matomo URL | None |
MATOMO_TOKEN |
--token |
Matomo token | None |
LOG_LEVEL |
None | Log level | INFO |
SCRAPE_INTERVAL |
--scrape-interval |
Scrape interval in seconds | 60 |
PORT |
--port |
Port to expose the metrics | 9000 |
IP |
--ip |
IP to expose the metrics | 0.0.0.0 |
CONCURRENT_THREADS |
--concurrent-threads |
Number of concurrent threads | 4 |
The following metrics are exported:
Metric | Description | Labels |
---|---|---|
number_of_sites |
Number of sites | |
number_of_visits |
Number of visits | site_name , period |
number_uniq_visitors |
Number of unique visitors | site_name , period |
number_bouncing_rate |
Bouncing rate | site_name , period |
number_of_actions |
Number of actions | site_name , period |
number_of_visits_per_page |
Number of visits per page | site_name , page , period |
number_of_visitors_per_os_version |
Number of visitors per OS version | site_name , os_version , period |
number_of_visitors_per_country |
Number of visitors per country | site_name , country , period |
number_of_visitors_per_region |
Number of visitors per region | site_name , region , period , country , latitude , longitude |
Contributions are welcome! Here are several ways you can contribute:
- Report Issues: Submit bugs found or log feature requests for the
.
project. - Submit Pull Requests: Review open PRs, and submit your own PRs.
- Join the Discussions: Share your insights, provide feedback, or ask questions.
Contributing Guidelines
- Fork the Repository: Start by forking the project repository to your local account.
- Clone Locally: Clone the forked repository to your local machine using a git client.
git clone https://github.com/qjoly/matomo-exporter.git
- Create a New Branch: Always work on a new branch, giving it a descriptive name.
git checkout -b new-feature-x
- Make Your Changes: Develop and test your changes locally.
- Commit Your Changes: Commit with a clear message describing your updates.
git commit -m 'Implemented new feature x.'
- Push to local: Push the changes to your forked repository.
git push origin new-feature-x
- Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
- Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!