Matomo on the Ametnes Platform#
This tutorial series covers provisioning an Ametnes Matomo analytics service and integrating it with Keycloak-protected applications so every page view is tracked against the authenticated user's identity.
What to read next#
| Topic | Page |
|---|---|
| Track page views from Keycloak-protected applications | Keycloak Integration |
Prerequisites#
- An Ametnes Platform account.
- A configured Data Service Location.
Provision Matomo on Ametnes Platform#
- Sign in to the Ametnes Platform console.
- Click New Resource.
- Enter:
- Name: a unique name for your Matomo service.
- Resource Kind:
matomo. - Tier: choose a preset tier size that matches your expected traffic and archiving load.
- Storage: choose capacity for Matomo's bundled database.
- Select your Data Service Location.
- Click Create.
- Save the generated connection details: URL, username, and password.
Deploying data services at scale is easier with the Ametnes Cloud Terraform provider.
Create an API token
In your Ametnes Cloud account:
- Navigate to Users.
- Click Edit on your user.
- Click Get User Token and a user token will be generated for you.
- Keep the generated token in a secure place, as it will not be shown again.
Install Terraform
Follow the instructions here to install Terraform on your computer.
Create your project
Add these files to an empty folder on your workstation.
Set up the variables
Add your API key secrets
Define your resources
The architecture config option selects the preset tier size (Starter, Small, Basic, Medium, Large, XLarge, 2XLarge, 3XLarge, or 4XLarge) and capacity.storage sizes Matomo's bundled database. You do not need to attach a separate Network Access resource: it is created for you automatically.
Deploy your Terraform resources
- Run
terraform init. - Run
terraform planto see the resources that will be created. - Run
terraform apply -auto-approve. - Once Terraform finishes, the
service_connectionsoutput contains the connection details for your Matomo service.
Note
Matomo is deployed inside your private environment and is only accessible within your internal network.
Tip
Matomo ships with a bundled MariaDB database for its application state. If you want to perform detailed data analytics on your data, you can connect directly to your database — this is the use case for the direct database connection. Treat the admin credentials like any production admin account and rotate them if they were shown only once during creation.
Connect to the Matomo database#
Matomo bundles a MariaDB database for its application data. To connect to it directly:
- Open your Matomo resource in the Ametnes Platform console.
- Under Connections, find the
mariadbconnection and note its host and port. - Connect with the
mysqlclient:
mysql -h <matomo_host_name> -P <matomo_port> -u root -p<matomo_password> --connect-timeout=60 --protocol=TCP --verbose
Replace <matomo_host_name> and <matomo_port> with the values from Connections, and <matomo_password> with the admin password saved during creation.
Open Matomo#
- Open the Matomo URL in a browser (from your resource details in the console, or from the
service_connectionsoutput if you used Terraform). - Sign in with the username and password saved during creation.
Validation checklist#
- Matomo resource status is
onlinein Ametnes Platform. - You can sign in to the Matomo UI using the saved URL and credentials.
- You can connect to the bundled MariaDB using the
mysqlclient.