Code Monkey home page Code Monkey logo

matomo-exporter's Introduction

Helm LOGO

Blog Python Matomo

Matomo Exporter

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.

How to run

  • 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.

Configuration

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

Exported metrics

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

Contributing

Contributions are welcome! Here are several ways you can contribute:

Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your local account.
  2. Clone Locally: Clone the forked repository to your local machine using a git client.
    git clone https://github.com/qjoly/matomo-exporter.git
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
  6. Push to local: Push the changes to your forked repository.
    git push origin new-feature-x
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
  8. Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
Contributor Graph


matomo-exporter's People

Contributors

qjoly avatar renovate[bot] avatar

Watchers

 avatar

matomo-exporter's Issues

Fix datetime inside the container

Actually, It seems that the time zone is not set correctly inside the container. Add the required environment variable to set the time zone to the correct value.

Add authentication to the exporter

To secure the exporter, we need to add authentication in the web server. This will allow us to restrict access to the exporter to only those who have the correct credentials.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.