Download - Grafana Review

Transcript

시작하기

Billy Goo 2015.01.28

Grafana는?

연속적으로 발생하는 데이터를 그래프로 보여주는 대시보드

서버의 모니터링 도구로 활용 가능

어떤 데이터를 보여주는가?

특정한 네임스페이스에 시간과 데이터를

계속해서 쌓아가는 특수한 데이터 저장소에 있는 데이터를 가져다 보여준다.

Graphite

http://graphite.readthedocs.org/en/latest/

http://influxdb.com/

OpenTSDB

http://opentsdb.net/

어떻게 데이터를 보여주는가?

Graphite

InfluxDB

OpenTSDB

Server

Grafana

시계열 DB

Grafana Interface

Grafana - Graphing

Grafana - Annotations

Annotations provide a way to mark points on the graph with rich events.

Grafana – Time range controls

Grafana – Search features

Grafana + Graphite

구조Grafana 설치Graphite 설치Elasticsearch 설치

Graphite

Grafana와 Graphite 연계 구조

client

client

Elasticsearch

Dashboard 저장/검색

Graphite의 간단 구조

Graphite 구조

세 가지 Component로 다음 구성된다.

• Carbon : 백엔드 데몬 프로세스로클라이언트로 부터 데이터를 수집한다.

• Whisper : Carbon에서 넘겨받은 데이터를 파일시스템에 저장하거나 읽어온다.

• Webapp : 저장된 데이터를 웹으로 보여주나 기능이 별로라서 그라파나를 대신

사용한다.

http://www.aosabook.org/en/graphite.html

Graphite 데이터

Component와 같은 개수인 3가지 데이터를 사용한다.

네임스페이스, 값, 타임스탬프

예를 들어 CPU 사용량을 기록하고 싶다. 그럼 위와 같이 3가지 데이터를 매 분마다 저장하도록 한다.

Graphite 저장되는 데이터는??

http://www.aosabook.org/en/graphite.html

일단 3가지 Component를 이용해 3가지 데이터를 저장한다는 것만 기억

Grafana/Graphite 설치

설치 환경 : Ubuntu 12.04

필수 프로그램 설치

# Install all prerequisites

apt-get -y install software-properties-common

add-apt-repository -y ppa:chris-lea/node.js

apt-get -y update

apt-get -y install python-django-tagging python-simplejson python-memcache python-ldap \

python-cairo python-pysqlite2 python-support python-pip gunicorn \

supervisor nginx-light nodejs git wget curl openjdk-7-jre \

build-essential python-dev

Grafana/Graphite 설치

Elasticsearch, graphite 설치

# Install Elasticsearch

cd ~ && wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.2.deb

cd ~ && dpkg -i elasticsearch-1.3.2.deb && rm elasticsearch-1.3.2.deb

# Install Whisper, Carbon and Graphite-Web

pip install Twisted==11.1.0

pip install Django==1.5

pip install whisper==0.9.12

pip install --install-option="--prefix=/var/lib/graphite" --install-option="--install-

lib=/var/lib/graphite/lib" carbon==0.9.12

pip install --install-option="--prefix=/var/lib/graphite" --install-option="--install-

lib=/var/lib/graphite/webapp" graphite-web==0.9.12

Grafana/Graphite 설치

Grafana 설치

# install npm

apt-get install npm

# Install & Patch Grafana

mkdir /src/grafana

git clone https://github.com/grafana/grafana.git /src/grafana

cd /src/grafana

git checkout v1.7.0

npm install

npm install -g grunt-cli

grunt build

Grafana/Graphite 설치

Configuration

아래 설정과 관련된 config파일들은 다음 사이트에서 다운로드 할 수 있다.

https://github.com/kamon-io/docker-grafana-graphite

# Configure Elasticsearch

cp ./elasticsearch/run /usr/local/bin/run_elasticsearch

chown -R elasticsearch:elasticsearch /var/lib/elasticsearch

mkdir -p /tmp/elasticsearch && chown elasticsearch:elasticsearch /tmp/elasticsearch

Grafana/Graphite 설치

Configuration

# Configure Whisper, Carbon and Graphite-Web

cp ./graphite/initial_data.json /var/lib/graphite/webapp/graphite/initial_data.json

cp ./graphite/local_settings.py /var/lib/graphite/webapp/graphite/local_settings.py

cp ./graphite/carbon.conf /var/lib/graphite/conf/carbon.conf

cp ./graphite/storage-schemas.conf /var/lib/graphite/conf/storage-schemas.conf

cp ./graphite/storage-aggregation.conf /var/lib/graphite/conf/storage-aggregation.conf

mkdir -p /var/lib/graphite/storage/whisper

touch /var/lib/graphite/storage/graphite.db /var/lib/graphite/storage/index

chown -R www-data /var/lib/graphite/storage

chmod 0775 /var/lib/graphite/storage /var/lib/graphite/storage/whisper

chmod 0664 /var/lib/graphite/storage/graphite.db

cd /var/lib/graphite/webapp/graphite && python manage.py syncdb --noinput

Grafana/Graphite 설치

Configuration

프로그램 시작

# Configure Grafana

cp ./grafana/config.js /src/grafana/dist/config.js

cp ./grafana/default-dashboard.json /src/grafana/dist/app/dashboards/default.json

# Configure nginx and supervisord

cp ./nginx/nginx.conf /etc/nginx/nginx.conf

cp ./supervisord.conf /etc/supervisor/conf.d/supervisord.conf

# run graphite

cd /var/lib/graphite/webapp/graphite; python manage.py runserver 0.0.0.0:8000

# run grafana/elasticsearch

/usr/bin/supervisord

Graphite & Grafana 연계설정

Config 파일의 datasource에 설정 추가

/src/grafana/dist/config.js

Graphite에 데이터 넣기

• 평문 전송: <metric path> <metric value> <metric timestamp> 구조로 텍스트를 nc 프로그램을 이

용해 데이터를 전송한다. 평문 전송시 2003포트이용

• Pickle 프로토콜 : python로 구현된 pickle 프로토콜을 이용할 수 있다. 이 경우 데이터를 모았다가 배

치로 한꺼번에 전송할 수 있다. Pickle 프로토콜 사용시 2004 포트를 이용.

$ echo "test.billy.xx 5 `date +%s`" | nc 127.0.0.1 2003;

[(path, (timestamp, value)), ...]

샘플 소스: https://github.com/graphite-project/carbon/blob/master/examples/example-pickle-client.py

graphite 가이드: http://graphite.readthedocs.org/en/0.9.12/feeding-carbon.html

Graphite에 데이터 넣기


Top Related