Graphite

From 탱이의 잡동사니
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Overview

Graphite 내용 정리.

Basic

Graphite 는 다음 두 가지 일을 한다.

  • Store number time-series data.
  • Render graphs of this data on demand.

Graphite 는 크게 다음 세가지 컴포넌트들로 이루어진다.

  • Carbon - a Twisted daemon that listens for time-series data.
  • Whisper - a simple database library for storing time-series data(similar in design to RRD)
  • Graphite webapp - A Django webapp that renders graphs on-demand using Cairo.

Installation

docker 를 이용해서 편리하게 설치가 가능하다. <source lang=bash> $ docker run -d\

--name graphite\
--restart=always\
-p 80:80\
-p 2003-2004:2003-2004\
-p 2023-2024:2023-2024\
-p 8125:8125/udp\
-p 8126:8126\
graphiteapp/graphite-statsd

</source>

Carbon

carbon-cache.py

carbon-cache.py 는 메트릭 정보들을 수집하고 디스크에 저장하는 역할을 한다. 데이터를 일단 램(RAM)에 저장을 했다가 일정한 간격으로 디스크에 저장한다.

만약 수집되는 메트릭(정보)의 규모가 점점 더 커진다면 하나의 carbon-cache.py 로는 충분하지 않을 수도 있다. 이런 경우, 단순히 carbon-aggregator.py 혹은 carbon-relay.py 뒷단에 여러개의 carbon-cache.py 를 실행하면 된다.

carbon-relay.py

carbon-relay.py 는 크게 두 가지 목적으로 사용된다.

  • replication
  • sharding

carbon-aggregator.py

carbon-aggregator.py 는 carbon-cache.py 앞단에서 동작하며, 버퍼 역할을 한다.

carbon-aggregator-cache.py

carbon-aggregator.py 과 carbon-cache.py 이 조합된 형태이다.

Feeding in your data

크게 세가지 방식으로 데이터를 전송할 수 있다.

  • Plaintext
  • Pickle
  • AMQP

데이터 전송 방식을 결정하는 건 전적으로 어떤 데이터를 보내느냐에 따라 달라진다.

  • There are some tools and APIs which can help you get your data into Carbon.
  • For a singular script, or for test data, the plaintext protocol is the most straightforward method.
  • For a sending large amounts of data, you will want to batch this data up and send it to Carbon's pickle receiver.
  • Finally, Carbon can listen to a message bus, via AMQP.

Existing tools and APIs

The plaintext protocol

plaintext 로 데이터를 전송하기 위해서는 반드시 다음과 같은 구성으로 전송되어야 한다.

metric_path value timestamp\n
  • metric_path : The metric namespace that you want to populate.
  • value : The value that you want to assign to the metric at this time.
  • timestamp : The number of seconds since unix epoch time.

Unix 에서는 nc 프로그램을 이용해서 간단히 데이터를 Carbon 으로 전송할 수 있다. <source lang=bash> $ echo "local.random.diceroll 4 `date +%s`" | nc 127.0.0.1 2003 </source>

The pickle protocol

pickle protocol 은 plaintext protocol 에 비해서 더 효과적이고 한번에 여러개의 정보를 보낼 수 있다.

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

Using AMQP

carbon.conf 파일에서 AMQP_NAME_IN_BODY 설정이 True 로 되어있다면, plaintext protocol 과 같은 포멧으로 데이터를 전송해야 한다("local.random.diceroll 4 date +%s"). 만약 AMQP_METRIC_NAME_IN_BODY 설정이 False 로 되어있다면, "local.random.diceroll" 부분을 생략해서 데이터를 전송해야 한다.

Getting your data into graphite

See also