Difference between revisions of "Graphite: Instalasi"

From OnnoWiki
Jump to navigation Jump to search
(New page: Sumber: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-graphite-on-an-ubuntu-14-04-server ==Instalasi== sudo apt-get update sudo apt-get install graphite-web ...)
 
 
(16 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
  sudo apt-get install graphite-web graphite-carbon
 
  sudo apt-get install graphite-web graphite-carbon
  
 +
Jika di tanya "Carbon to remove the database files" bisa jawab "No" jika kita tidak ingin data yang sudah ada hilang. Jika ini merupakan instalasi yang fresh / baru, kita bisa jawab "Yes".
  
  
  
 +
==Install PostgreSQL==
  
 +
sudo apt-get install postgresql libpq-dev python-psycopg2
 +
 +
 +
 +
==Buat Database User dan Database==
 +
 +
sudo -u postgres psql
 +
 +
Buat database graphite, user graphite dengan password graphite
 +
 +
CREATE USER graphite WITH PASSWORD 'graphite';
 +
CREATE DATABASE graphite WITH OWNER graphite;
 +
\q
 +
 +
 +
 +
==Konfigurasi Graphite Web Application==
 +
 +
Edit
 +
 +
sudo nano /etc/graphite/local_settings.py
 +
sudo vi /etc/graphite/local_settings.py
 +
 +
Set SECRET_KEY dengan password yang panjang, unik, dan aman, misalnya
 +
 +
SECRET_KEY = '123456'
 +
SECRET_KEY = 'UNSAFE_DEFAULT'
 +
SECRET_KEY = 'a_salty_string'
 +
 +
Set TIME_ZONE
 +
 +
TIME_ZONE = 'Asia/Jakarta'
 +
 +
Set USE_REMOTE_USER_AUTHENTICATION
 +
 +
USE_REMOTE_USER_AUTHENTICATION = True
 +
 +
Set DATABASES
 +
 +
DATABASES = {
 +
    'default': {
 +
        'NAME': 'graphite',
 +
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
 +
        'USER': 'graphite',
 +
        'PASSWORD': 'graphite',
 +
        'HOST': '127.0.0.1',
 +
        'PORT': ''
 +
    }
 +
}
 +
 +
Save konfigurasi
 +
 +
 +
 +
 +
==Sync Database==
 +
 +
Ketik
 +
 +
sudo graphite-manage syncdb
 +
 +
Akan keluar dan perlu di isi
 +
 +
You just installed Django's auth system, which means you don't have any superusers defined.
 +
Would you like to create one now? (yes/no): yes
 +
Username (leave blank to use 'root'):
 +
Email address: onno@indo.net.id
 +
Password:
 +
Password (again):
 +
 +
 +
==Konfigurasi Carbon==
 +
 +
Carbon adalah Graphite storage backend.
 +
 +
Edit
 +
 +
sudo nano /etc/default/graphite-carbon
 +
sudo vi /etc/default/graphite-carbon
 +
 +
Pastikan
 +
 +
CARBON_CACHE_ENABLED=true
 +
 +
Save file.
 +
 +
Edit
 +
 +
sudo nano /etc/carbon/carbon.conf
 +
sudo vi /etc/carbon/carbon.conf
 +
 +
Aktifkan log rotation, dengan
 +
 +
ENABLE_LOGROTATION = True
 +
 +
Save file.
 +
 +
 +
 +
 +
==Konfigurasi Storage Schemas==
 +
 +
Edit
 +
 +
sudo nano /etc/carbon/storage-schemas.conf
 +
sudo vi /etc/carbon/storage-schemas.conf
 +
 +
Di dalamnya, akan ada entry seperti berikut,
 +
 +
[carbon]
 +
pattern = ^carbon\.
 +
retentions = 60:90d
 +
 +
[default_1min_for_1day]
 +
pattern = .*
 +
retentions = 60s:1d
 +
 +
Bisa juga di tambahkan
 +
 +
[test]
 +
pattern = ^test\.
 +
retentions = 10s:10m,1m:1h,10m:1d
 +
 +
yang akan menyimpan setiap 10 detik, selama 10 menit dst.
 +
 +
Save.
 +
 +
 +
==Metoda Agregasi Storage==
 +
 +
Copy contoh konfigurasi
 +
 +
sudo cp /usr/share/doc/graphite-carbon/examples/storage-aggregation.conf.example /etc/carbon/storage-aggregation.conf
 +
 +
Edit
 +
 +
sudo nano /etc/carbon/storage-aggregation.conf
 +
sudo vi /etc/carbon/storage-aggregation.conf
 +
 +
This looks a bit similar to the last file. You will find entries that look like this:
 +
 +
[min]
 +
pattern = \.min$
 +
xFilesFactor = 0.1
 +
aggregationMethod = min
 +
 +
 +
Nama section dan pattern sama dengan storage-schemas file.
 +
 +
Save file.
 +
 +
Start Carbon Cache
 +
 +
sudo service carbon-cache start
 +
 +
 +
 +
 +
 +
==Instalasi dan Konfigurasi Apache==
 +
 +
Install apache
 +
 +
sudo apt-get install apache2 libapache2-mod-wsgi
 +
 +
Disable virtual host file
 +
 +
sudo a2dissite 000-default
 +
 +
Copy Graphite Apache virtual host file ke site directory
 +
 +
sudo cp /usr/share/graphite-web/apache2-graphite.conf /etc/apache2/sites-available
 +
 +
Enable virtual host file
 +
 +
sudo a2ensite apache2-graphite
 +
 +
Reload apache,
 +
 +
sudo service apache2 reload
 +
 +
 +
Atau dalam satu klik
 +
 +
 +
sudo apt-get install apache2 libapache2-mod-wsgi
 +
 +
sudo a2dissite 000-default
 +
sudo cp /usr/share/graphite-web/apache2-graphite.conf /etc/apache2/sites-available
 +
sudo a2ensite apache2-graphite
 +
sudo service apache2 reload
 +
 +
 +
 +
 +
 +
 +
==Cek Web==
 +
 +
Browse ke
 +
 +
http://server_domain_name_or_IP
 +
http://192.168.0.100
 +
 +
 +
Kondisi server dapat dilihat di
 +
 +
Graphite > carbon > agents > .... > cache
 +
 +
 +
 +
==Coba kirim data==
 +
 +
Data dikirim menggunakan TCP.
 +
Cara paling sederhana menggunakan nc
 +
 +
echo "test.count 3 `date +%s`" | nc -q0 192.168.0.100 2003
 +
 +
Format data yang dikirim kita-kira
 +
 +
test.count 3 1456194469
 +
 +
Data dikirim secara realtime.
  
 
==Referensi==
 
==Referensi==
  
 
* https://www.digitalocean.com/community/tutorials/how-to-install-and-use-graphite-on-an-ubuntu-14-04-server
 
* https://www.digitalocean.com/community/tutorials/how-to-install-and-use-graphite-on-an-ubuntu-14-04-server

Latest revision as of 09:37, 23 February 2016

Sumber: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-graphite-on-an-ubuntu-14-04-server

Instalasi

sudo apt-get update
sudo apt-get install graphite-web graphite-carbon

Jika di tanya "Carbon to remove the database files" bisa jawab "No" jika kita tidak ingin data yang sudah ada hilang. Jika ini merupakan instalasi yang fresh / baru, kita bisa jawab "Yes".


Install PostgreSQL

sudo apt-get install postgresql libpq-dev python-psycopg2


Buat Database User dan Database

sudo -u postgres psql

Buat database graphite, user graphite dengan password graphite

CREATE USER graphite WITH PASSWORD 'graphite';
CREATE DATABASE graphite WITH OWNER graphite;
\q


Konfigurasi Graphite Web Application

Edit

sudo nano /etc/graphite/local_settings.py
sudo vi /etc/graphite/local_settings.py

Set SECRET_KEY dengan password yang panjang, unik, dan aman, misalnya

SECRET_KEY = '123456'
SECRET_KEY = 'UNSAFE_DEFAULT'
SECRET_KEY = 'a_salty_string'

Set TIME_ZONE

TIME_ZONE = 'Asia/Jakarta'

Set USE_REMOTE_USER_AUTHENTICATION

USE_REMOTE_USER_AUTHENTICATION = True

Set DATABASES

DATABASES = {
    'default': {
        'NAME': 'graphite',
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'USER': 'graphite',
        'PASSWORD': 'graphite',
        'HOST': '127.0.0.1',
        'PORT': 
    }
}

Save konfigurasi



Sync Database

Ketik

sudo graphite-manage syncdb

Akan keluar dan perlu di isi

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'root'): 
Email address: onno@indo.net.id
Password: 
Password (again):


Konfigurasi Carbon

Carbon adalah Graphite storage backend.

Edit

sudo nano /etc/default/graphite-carbon
sudo vi /etc/default/graphite-carbon

Pastikan

CARBON_CACHE_ENABLED=true

Save file.

Edit

sudo nano /etc/carbon/carbon.conf
sudo vi /etc/carbon/carbon.conf

Aktifkan log rotation, dengan

ENABLE_LOGROTATION = True

Save file.



Konfigurasi Storage Schemas

Edit

sudo nano /etc/carbon/storage-schemas.conf
sudo vi /etc/carbon/storage-schemas.conf

Di dalamnya, akan ada entry seperti berikut,

[carbon]
pattern = ^carbon\.
retentions = 60:90d

[default_1min_for_1day]
pattern = .*
retentions = 60s:1d

Bisa juga di tambahkan

[test]
pattern = ^test\.
retentions = 10s:10m,1m:1h,10m:1d

yang akan menyimpan setiap 10 detik, selama 10 menit dst.

Save.


Metoda Agregasi Storage

Copy contoh konfigurasi

sudo cp /usr/share/doc/graphite-carbon/examples/storage-aggregation.conf.example /etc/carbon/storage-aggregation.conf

Edit

sudo nano /etc/carbon/storage-aggregation.conf
sudo vi /etc/carbon/storage-aggregation.conf

This looks a bit similar to the last file. You will find entries that look like this:

[min]
pattern = \.min$
xFilesFactor = 0.1
aggregationMethod = min


Nama section dan pattern sama dengan storage-schemas file.

Save file.

Start Carbon Cache

sudo service carbon-cache start



Instalasi dan Konfigurasi Apache

Install apache

sudo apt-get install apache2 libapache2-mod-wsgi

Disable virtual host file

sudo a2dissite 000-default

Copy Graphite Apache virtual host file ke site directory

sudo cp /usr/share/graphite-web/apache2-graphite.conf /etc/apache2/sites-available

Enable virtual host file

sudo a2ensite apache2-graphite

Reload apache,

sudo service apache2 reload


Atau dalam satu klik


sudo apt-get install apache2 libapache2-mod-wsgi
sudo a2dissite 000-default
sudo cp /usr/share/graphite-web/apache2-graphite.conf /etc/apache2/sites-available
sudo a2ensite apache2-graphite
sudo service apache2 reload




Cek Web

Browse ke

http://server_domain_name_or_IP
http://192.168.0.100


Kondisi server dapat dilihat di

Graphite > carbon > agents > .... > cache


Coba kirim data

Data dikirim menggunakan TCP. Cara paling sederhana menggunakan nc

echo "test.count 3 `date +%s`" | nc -q0 192.168.0.100 2003

Format data yang dikirim kita-kira

test.count 3 1456194469

Data dikirim secara realtime.

Referensi