2017-01-23

Episode 49 : Piwik



Piwik is an open-source analytics platform with a clear and friendly interface.

You can host your statistics yourself and you don’t need a third-party company.

Piwik’s interface is customizable and you can install several plugins.

Piwik is developed in PHP and uses a MySQL database to save all the data it needs.

Preparations

The Versions

CoreOS Stable 1010.6

Piwik 2.16.2

The prerequisites to deploy this stack

These should be routine by now:

An Internet access

A Linux shell

A Cloudwatt account with a valid keypair

The tools of the trade: OpenStack CLI

A local clone of the Cloudwatt applications git repository (if you are creating your stack from a shell)

Size of the instance

By default, the stack deploys on an instance of type “Standard 1” (n1.cw.standard-1). A variety of other instance types exist to suit your various needs, allowing you to pay only for the services you need. Instances are charged by the minute and capped at their monthly price (you can find more details on the Pricing page on the Cloudwatt website).

Stack parameters, of course, are yours to tweak at your fancy.

By the way…

If you do not like command lines, you can go directly to the “run it thru the console” section by clicking here

What will you find in the repository

Once you have cloned the github, you will find in the bundle-trusty-piwik/ repository:

blueprint-coreos-piwik.heat.yml: HEAT orchestration template. It will be use to deploy the necessary infrastructure.

stack-start.sh: Stack launching script. This is a small script that will save you some copy-paste.

stack-get-url.sh: Flotting IP recovery script.

Start-up

Initialize the environment

Have your Cloudwatt credentials in hand and click HERE.
If you are not logged in yet, you will go thru the authentication screen then the script download will start. Thanks to it, you will be able to initiate the shell accesses towards the Cloudwatt APIs.

Source the downloaded file in your shell. Your password will be requested.

Once this done, the Openstack command line tools can interact with your Cloudwatt user account.

Adjust the parameters

With the blueprint-coreos-piwik.heat.yml file, you will find at the top a section named parameters. The sole mandatory parameter to adjust is the one called keypair_name. Its default value must contain a valid keypair with regards to your Cloudwatt user account. You will also enter the piwik password account of your MySQL database. This is within this same file that you can adjust the instance size by playing with the flavor parameter.

Start stack

In a shell, run the script stack-start.sh with his name in parameter:

Within 5 minutes the stack will be fully operational. (Use watch to see the status in real-time)

The start-stack.sh script takes care of running the API necessary requests to execute the normal heat template which:

Starts an CoreOS based instance with the docker container Piwik attached to Apache2 and his Mysql database

Expose it on the Internet via a floating IP.

All of this is fine, but…

You do not have a way to create the stack from the console?

We do indeed! Using the console, you can deploy Piwik:

Go the Cloudwatt Github in the applications/blueprint-coreos-piwik repository

Click on the file named blueprint-coreos-piwik.heat.yml

Click on RAW, a web page will appear containing purely the template

Save the file to your PC. You can use the default name proposed by your browser (just remove the .txt)

Go to the « Stacks » section of the console

Click on « Launch stack », then « Template file » and select the file you just saved to your PC, and finally click on « NEXT »

Name your stack in the « Stack name » field

Enter the name of your keypair in the « SSH Keypair » field

Write a passphrase that will be used for the database piwik user

Choose your instance size using the « Instance Type » dropdown and click on « LAUNCH »

The stack will be automatically generated (you can see its progress by clicking on its name). When all modules become green, the creation will be complete. You can then go to the “Instances” menu to find the floating IP, or simply refresh the current page and check the Overview tab for a handy link.

If you’ve reached this point, you’re already done! Go enjoy Piwik!

A one-click deployment sounds really nice…

… Good! Go to the Apps page on the Cloudwatt website, choose the apps, press DEPLOY and follow the simple steps… 2 minutes later, a green button appears… ACCESS: you have your Piwik.

Enjoy

Once all this makes you can connect on your server in SSH by using your keypair beforehand downloaded on your compute,

You are now in possession of your own Piwik analytics tool, you can enter via the URL http://ip-floatingip. Your full URL will be present in your stack overview in horizon Cloudwatt console.

At your first connexion you will ask to give the information about the website you want to analyze and how to access to the database. Complete the fields as below, the password is which one you chose when you created the stack.



You can now setup Piwik, this one being hosted in France in a safe environment, you can completely trust on this product.

So watt?

The goal of this tutorial is to accelerate your start. At this point you are the master of the stack.

You now have an SSH access point on your virtual machine through the floating-IP and your private keypair (default userusername core).

You have access to the web interface via the address specified in your output stack in horizon console.

Here are some news sites to learn more:

https://www.piwik.org/

https://www.piwik.org/docs/

Have fun. Hack in peace.

Show more