RETIRED, Fuel anonymous statistics collector
Go to file
Alexander Kislitsky 8e16219249 Elasticsearch removing from fuel-stats analytics
We don't use Elasticsearch for flexible reports generation on the
fuel-stats web UI, only for five fixed reports. Thus using of
Elasticsearch is overhead and it can be removed from the servers
Instead of Elasticsearch we use fuel-stats json api calls and
PostgreSQL + Memcached.

Changes list:

 - api call added to fuel-stats json api for data required on the web UI page,
 - column release added to DB installation_structures table schema,
 - memcached is used for caching data for the web UI page,
 - elasticsearch client removed from js requirement,
 - web UI page rewritten to use fuel-stats json api instead Elaticsearch.

Co-Authored-By: Kate Pimenova <kpimenova@mirantis.com>
Change-Id: Ie752e0d0a3c80933888f986e2497b45adce730c9
Closes-Bug: #1595548
2016-07-13 14:33:24 +03:00
analytics Elasticsearch removing from fuel-stats analytics 2016-07-13 14:33:24 +03:00
collector Elasticsearch removing from fuel-stats analytics 2016-07-13 14:33:24 +03:00
migration Files permmission are fixed 2016-07-06 09:11:01 +00:00
tools Cluster attributes added to CSV report 2016-03-09 18:23:50 +03:00
.gitignore Filtered stats excluded from CSV reports 2015-06-30 17:19:36 +03:00
.gitreview Update .gitreview for new namespace 2015-10-17 22:27:16 +00:00
LICENSE Wrong license file fixed 2015-07-02 17:34:02 +03:00
MAINTAINERS Maintaners file added to fuel-stas 2015-10-12 13:05:56 +03:00
MANIFEST.in Fuel-stats prepared for OpenStack CI 2015-10-21 14:40:44 +03:00
README.rst Elasticsearch removing from fuel-stats analytics 2016-07-13 14:33:24 +03:00
requirements.txt Elasticsearch removing from fuel-stats analytics 2016-07-13 14:33:24 +03:00
setup.py Fuel-stats prepared for OpenStack CI 2015-10-21 14:40:44 +03:00
test-requirements.txt Fuel-stats prepared for OpenStack CI 2015-10-21 14:40:44 +03:00
tox.ini Cluster attributes added to CSV report 2016-03-09 18:23:50 +03:00

README.rst

Fuel stats

Project purpose

  • collects stats information about OpenStack installations made by Fuel,
  • generates stat reports in the CSV format,
  • provides API for fetching raw data in the JSON format,
  • provides Web UI for reports generation and basic stats charts/histograms.

Components

Collector is the service for collecting stats. It has REST API and DB storage. Analytics is the service for generating reports. It has REST API. Migrator is the tool for migrating data from the DB to the Elasticsearch.

The collector and analytics services are started by uWSGI. Migrator is started by cron to migrate the fresh data into Elasticsearch.

Collector

Data origin for collector is the Fuel master node. Stats collecting daemons collect and send data to the collector if allowed by the cloud operator.

Stats data is stored to the DB PostgreSQL.

Migrator

Migrator periodically migrates data from the fuel-stats DB to the Elasticsearch storage. This storage is used to generate basic stats charts and histograms for the Web UI.

Analytics

There are two sub-components in the analytics:

  • analytics service
  • Web UI

The analytics service API provides generation of CSV reports for installation info, plugins, and OpenStack workloads. The analytics API also provides export of data from DB as JSON.

The analytics Web UI provides basic summary stats charts and histograms with the possibility of filtering data by the Fuel release version. Also, in the Web UI we can generate and download stats reports on a selected time period.

How to configure development environment

To start fuel-stats on a localhost we need to have:

Install PostgreSQL and development libraries: :

sudo apt-get install --yes postgresql postgresql-server-dev-all

Configure Elasticsearch repo as described in the elasticsearch docs and install Elasticsearch::

sudo apt-get install --yes elasticsearch

Install pip and development tools: :

sudo apt-get install --yes python-dev python-pip

Install virtualenv. This step increases flexibility when dealing with environment settings and package installation: :

sudo pip install virtualenv virtualenvwrapper

You can add '. /usr/local/bin/virtualenvwrapper.sh' to .bashrc or just execute it.:

. /usr/local/bin/virtualenvwrapper.sh

Create and activate virtual env for fuel-stats: :

mkvirtualenv stats
workon stats

You can use any name for the virtual env instead of 'stats'.

Install the fuel-stats requirements: :

pip install -r test-requirements.txt

Create a DB user for fuel-stats: :

sudo -u postgres psql
CREATE ROLE collector WITH NOSUPERUSER NOCREATEDB NOCREATEROLE LOGIN ENCRYPTED PASSWORD 'collector';

Create a DB and grant privileges to it: :

sudo -u postgres psql
CREATE DATABASE collector;
GRANT ALL ON DATABASE collector TO collector;

Check that all tests are passed: :

cd fuel-stats/collector && tox
cd fuel-stats/migration && tox
cd fuel-stats/analytics && tox

NOTE: The collector tests must be performed the first.

Now you are ready to develop fuel-stats.

How to configure Web UI

We assume that you already have configured virtual env as described in howto configure dev environment.

Install elsticsearch library and create sample data: :

workon stats
pip install elasticsearch
cd migration
nosetests migration.test.report.test_reports:Reports.test_libvirt_type_distribution

Install nodejs: :

sudo apt-get remove nodejs nodejs-legacy npm
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

Install nodejs and bower packages: :

cd fuel-stats/analytics/static
npm install
gulp bower

You can anytime lint your code by running: :

gulp lint

Add site configuration to Nginx: :

server {
    listen 8888;
    location / {
        root /your-path-to-fuel-stats/fuel-stats/analytics/static;
    }
    location ~ ^(/fuel)?(/[A-Za-z_0-9])?/(_count|_search) {
        proxy_pass http://127.0.0.1:9200;
    }
}

Then restart Nginx: :

service nginx restart

After this, your local server will be available at 0.0.0.0:8888 or any other port you've set up.

How to start local collector

You can use uWSGI to start the collector. Sample config can be found in collector/uwsgi/collector_example.yaml.

Or test web service to be used. To start the test web service, run: :

python collector/manage_collector.py --mode test runserver

How to start local analytics

You can use uWSGI to start analytics. Sample config can be found in analytics/uwsgi/analytics_example.yaml.

Or test the web service to be used. To start the test web service, run: :

python analytics/manage_analytics.py --mode test runserver

How to deal with DB migrations

Create new DB migration: :

python manage_collector.py --mode test db migrate -m "Migration comment" \
-d collector/api/db/migrations/

Apply all DB migrations: :

python manage_collector.py --mode test db upgrade -d collector/api/db/migrations/

Revert all migrations: :

python manage_collector.py --mode test db downgrade -d collector/api/db/migrations/

Switching off Elasticsearch

Elasticsearch was chosen as data storage for the dynamically generated statistics reports, but now only CSV reports are used for analytical purposes. Thus, Elasticsearch is an unnecessary complication of the infrastructure and data flow.

Without Elasticsearch, we are using memcached as cache for the web UI. Data expiration is configured by the parameter MEMCACHED_JSON_REPORTS_EXPIRATION for fuel_analytics.

Changes in the Nginx config: :

# Add this to the block 'server'
location /api/ {
    proxy_pass http://IP_OF_ANALYTICS_SERVICE:PORT_OF_ANALYTICS_SERVICE/api/;
}