WiproOpenSource / galaxia

Next Generation Universal monitoring framework for infrastructure, applications & microservices
Apache License 2.0
20 stars 19 forks source link

======= GALAXIA

Universal Monitoring Framework

Galaxia is envisioned as a dynamic monitoring framework with the following goals

Index

Why Galaxia


With the advent of cloud & container technologies monitoring needs for an enterprise has reached multiple folds. Today there is no single open source solution which provides collecting & co-relating monitoring statistics from various systems. Some of the pain points today organization face:

Architecture


alt tag

Galaxia Current Capabilities


Future Roadmap


Galaxia UI Solution


Currently galaxia has integration with following 2 UI projects:

Summary of the complete target infrastructure
This screenshot details the complete summary of your target infrastructure and applications. Summary of the complete target infrastructure


List of hosts currently being monitored
This screenshot Lists the summary of host bein monitored currently List of hosts currently being monitored

Favorite metrics for host
This screenshot lists the favorite metrics of host being monitored currently host favorite metrics

Favorite metrics for host
This screenshot lists the drill down between host and containers Drill down

How Galaxia works?


Galaxia works on the concept of exporter, aggregator and renderer. Here exporter is a docker container which exports metrics to the aggregator. Exporter unit runs on each node from which we wish to capture the metrics. Aggregator collates metrics from all the exporter in its local database. Renderer connects to aggregator and generates the monitoring dashboard. Currently renderer is only supported for promdash.

Setup an ALL-IN-ONE Galaxia


We recommend using Vagrant to set up galaxia. Here are the steps to setup Vagrant on ubuntu:

- sudo apt-get install virtualbox
- sudo apt-get install vagrant
vagrant ssh galaxia

This brings up a virtual environment and now proceed with installing galaxia

Galaxia can be installed in following 2 ways

Using Ansible


We recommend using vagrant to run this installation steps.

The install directory in galaxia source has the ansible script to install galaxia and all the dependent components. To run this script the host needs to have Ansible installed.

Now set the following entry in /etc/ansible/hosts

[galaxiainstall]
localhost

If you are on AWS than you need to add the following entry instead

[galaxiainstall]
<hostname> ansible_ssh_private_key_file=<location_of_your_private_key>

Clone the galaxia source code

git clone https://github.com/WiproOpenSourcePractice/galaxia

Now galaxia by default supports sqlite as the backend. Go to install directory & run the command

ansible-playbook site.yml

If instead of sqlite you want to use mysql as the backend than follow the below steps:

  1. Uncomment the mysql role in site.yml
  2. In galaxia/templates modify the galaxia.conf.j2 and under [db] change the type from 'sqlite' to 'mysql'
  3. In galaxia/tasks/install.yml. Under the task name "Install galaxia" modify "--type sqlite" to "--type mysql"

Once done you can run the playbook as suggested above.

This will setup an ALL-IN-ONE Galaxia with-in few minutes depending on your network speed. Once done skip to section Testing Galaxia Services

Manual Setup


Follow the steps below to setup Galaxia, the steps are specific to ubuntu operating system and hence will have to be modified accordingly for other OS.

We are using vagrant box with ubuntu 14.04 to add up all the components To successfully operate Galaxia following softwares are required to be installed

Python v2.7

Ubuntu comes with Python v2.7 out of the box

Python Pip

Install Python Pip on ubuntu using the following command sudo apt-get -y install python-pip

mysql-server

Follow the steps below to install mysql-server on ubuntu

- sudo apt-get update
- sudo apt-get install -y mysql-server

When prompted Set up username as "root" and password as "root". By default mysql server listens on port 3306.

rabbitmq-server

sudo apt-get install -y rabbitmq-server

By default rabbitmq server listens on 5672.

Prometheus


    # my global config
        global:
            scrape_interval:     15s # By default, scrape targets every 15 seconds.
            evaluation_interval: 15s # By default, scrape targets every 15 seconds.
    # scrape_timeout is set to the global default (10s).

    # Attach these labels to any time series or alerts when communicating with
    # external systems (federation, remote storage, Alertmanager).
    #        external_labels:
    #            monitor: 'codelab-monitor'

    # Load and evaluate rules in this file every 'evaluation_interval' seconds.
            rule_files:
                # - "first.rules"
                # - "second.rules"

    # A scrape configuration containing exactly one endpoint to scrape:
    # Here it's Prometheus itself.
            scrape_configs:
    # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
                - job_name: 'prometheus'

    # Override the global default and scrape targets from this job every 5 seconds.
                  scrape_interval: 5s
                  scrape_timeout: 10s

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

                  target_groups:
                    - targets: ['localhost:8090']

    ./prometheus -config.file=prometheus.yml

Prometheus by default listens on port 9090

Promdash

Steps to install Promdash

sudo apt-get install -y git
git clone https://github.com/prometheus/promdash
cp config/database.yml.example config/database.yml

    export DATABASE_URL="mysql2://username:password@host/galaxia"
    export RAILS_ENV="production"
sudo apt-get install -y bundler"
sudo apt-get install -y libpq-dev mysql-client libmysqlclient-dev libsqlite3-dev
bundle install
bundle exec rake db:setup

This will set up db tables required for promdash

make build
bin/env bin/bundle exec bin/thin -p 3000  start

Promdash is listening on port 3000

Docker

Install docker using the link https://docs.docker.com/engine/installation/linux/ubuntulinux/

cadvisor

cadvisor is being used as a metrics exporter here, we use a docker image here


     sudo docker run --volume=/:/rootfs:ro --volume=/var/run:/var/run:rw --volume=/sys:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro  --publish=8090:8080   --detach=true
     --name=cadvisor google/cadvisor

Galaxia

Steps to install Galaxia


    sudo apt-get -y build-dep python-mysqldb
    sudo pip install MySQL-python
    sudo pip install -r requirements.txt
    sudo python setup.py install

    python database.py --host localhost --type mysql --username root --password root**

This completes galaxia installation.

Starting galaxia services


Galaxia comes up with following services gapi, grenderer and gexporter. Let us start them one by one To test gexporter service you will need to setup OpenStack

Run the following commands to start gapi service. The gapi service can be started in on of the two ways.

Run the following commands to start grenderer service

```
 source openrc_example
 grenderer --config-file etc/galaxia/galaxia.conf
```

Run the following commands to start gexporter service

```
source openrc_example
gexporter --config-file etc/galaxia/galaxia.conf

```

Testing Galaxia Services


Currently galaxia supports containers and hence we need to start some containers on the host to test galaxia services. We will use httpd server(https://hub.docker.com/_/httpd/) images from docker hub for that

sudo docker run --name sample_http -d  httpd
sudo docker run --name sample_http1 -d  httpd
source openrc_example
1) galaxia --help
2) galaxia metrics list - This will give the list of supported metrics for each type. Some examples
below:
galaxia metrics list --type docker
galaxia metrics list --type node
galaxia metrics list --type postgres
galaxia metrics list --type mysql
galaxia metrics list --type tomcat
3) galaxia dashboard create - This will create a dashboard on promdash.Some examples below:
galaxia dashboard create --name terase092 --metrics-list container_memory_usage_bytes container_cpu_system_seconds_total 
--search-string 192.168.76 --search-type instance --unit-type docker
galaxia dashboard create --name terase092 --metrics-list container_memory_usage_bytes container_cpu_system_seconds_total 
--search-string 192.168.76 --search-type instance --unit-type docker –-exclude 1
4) galaxia catalogue list - This will list all the entities being monitored for a type
galaxia catalogue list --unit-type container
galaxia catalogue list --unit-type node
5) galaxia status list - availability monitoring
galaxia status list --unit-type container
galaxia status list --unit-type container --time-interval 1w
6) galaxia label list - List out the labels for a metrics
galaxia label list --unit-type container --meter-name container_fs_read_seconds_total
galaxia label list --unit-type app  --meter-name pg_runtime_variable_max_connections
7) galaxia register agent - Onboards an application, node, container
galaxia register agent --unit-type app --host 192.168.76.20 --port 9104 --instance-key mysql001 --job-name OpenSourcePractice

1) Create Dashboard

 http://localhost:7000/v1/gapi "PUT Request" with the following data
{"name": "ashish08" , "unit_type": "docker", "metrics_list": ["container_memory_usage_bytes", "container_cpu_system_seconds_total"], "names_list": ["httpd1_ecom1", "test123"]}

2) Update Dashboard

http://localhost:7000/v1/gapi "POST Request" with the following data
{"name": "ashish08" , "unit_type": "docker", "metrics_list": ["container_memory_usage_bytes", "container_cpu_system_seconds_total"], "names_list": ["httpd1_ecom1"]}

3) Delete Dashboard

http://localhost:7000/v1/gapi "DELETE Request" with the following data
{"name": "ashish08"}

4) Create Dashboard using search strings and type

http://localhost:7000/v1/gapi "PUT Request" with the following data
{"name": "ashish09" , "unit_type": "docker", "metrics_list": ["container_memory_usage_bytes", "container_cpu_system_seconds_total"], "search_string": "httpd", "search_type": "image"}

5) Catalogue API usage

http://localhost:7000/v1/catalogue?unit_type=container
http://localhost:7000/v1/catalogue?unit_type=dashboard

6) Metrics API usage

http://localhost:7000/v1/metrics?type=container

7) Exporter API usage

http://localhost:7000/v1/exporter
{"source_system": "prometheus", "target_system": "ceilometer", "metrics_list": ["cpu"], "time_interval": "1", "unit_type": "docker",  "exporter_name": "ashish2"}

8) Alert and Notification API Galaxia now supports alert and notifications. There are two capabilities supported

  1. Retrieve all the active alerts
  2. Post alerts from custom systems to alertmanager.

To retrieve all the active alerts run a GET call as

http://localhost:7000/v1/alert

To post a custom alert. Send a POST request with the following payload

http://localhost:7000/v1/alert
{"labels": {"service": "Galaxia","name": "galaxia-node"},
 "description": "Service galaxia for node has been successfully spawned",
 "generator": "openapp"
}

Contributing to Galaxia


Working with Pull Requests


1.Fork the repository.

Go to 'Galaxia' project on github website and click on the 'Fork' button to create your fork.

Fork repository

2.Clone the repository locally.

Clone repository

Copy your fork repository URL and run the following command from git bash.

git clone <your-repository-url>

3.Create a branch - creating an environment where you can try out your ideas. This will not affect master branch.

git branch <branch-name>

git checkout <branch-name>

4.Make your changes and test it out. Once you are ready to commit, follow the next step.

5.Commit your changes to your fork.

git add <file-name>

git commit -m "your commit message"

git push origin <branch-name>

6.Open pull requests from your fork to main repository from github website.

Join the chat at https://gitter.im/WiproOpenSourcePractice/openapphack