31
Graph Everything

Graph Everything

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Graph Everything

Graph Everything

Page 2: Graph Everything

Kunal Kerkar

@tsudot

Page 3: Graph Everything

We  enable  Phone  Calls  and  SMS  Apps  to  be  built  with  a  few  lines  of  code.

a = {‘from’: ‘555-1234’, # calling party, ‘to’ : ‘919611111111, # called party, ’answer_url‘ : ‘http://example.com/answer’}

plivo.make_call(a)

Page 4: Graph Everything

Points to be discussed

1.  Data  at  Plivo2.  Graphite3.  Carbon  Daemons4.  Configuring  Carbon5.  Whisper  Database6.  The  render  URL  API,  Graphene

Page 5: Graph Everything

Components

Tank

Page 6: Graph Everything
Page 7: Graph Everything

zgrep  ‘inbound  calls’  20120823-­‐plivo.tar.gz  |  wc  -­‐l

Page 8: Graph Everything

•Track  calls/SMS  made  every  hour•Number  of  recharges,  sign  ups•Endpoints  registered•WebRTC  vs  Softphones•Server  metrics

What we wanted to do?

Page 9: Graph Everything

Graphite

Page 10: Graph Everything

•  Enterprise-­‐scale  monitoring  tool•  Written  by  Chris  Davis  at  Orbitz  in  2006    •  Opensourced  in  2008

Graphite

Page 11: Graph Everything

1.Store  numeric  time-­‐series  data2.Render  graphs  of  this  data  on  demand

What does it do?

Page 12: Graph Everything

1.carbon  -­‐  a  Twisted  daemon  that  listens  for  time-­‐series  data

2.whisper  -­‐  a  simple  database  library  for  storing  time-­‐series  data

3.graphite  webapp  -­‐  A  django  webapp  that  renders  graphs  on-­‐demand  using  cairo

Architecture : in a nutshell

Page 13: Graph Everything

•  1  daemon,  carbon-­‐cache.py  •  Listen  for  time-­‐series  data  •  Use  a  common  set  of  protocols  

Carbon Daemons

Page 14: Graph Everything

•  Accepts  metrics  •  Writes  them  to  disk    

carbon.confport  (2003/2004/7002)  protocols  (newline  delimited,  pickle)transports  (TCP/UDP)  

storage-­‐schemas.confDefines  a  retention  policy  for  incoming  metrics  based  on  regex  patterns.

carbon-cache.py

Page 15: Graph Everything

•A  name,  specified  inside  square  brackets•A  regex,  specified  after  “pattern=”•A  retention  rate  line,  specified  after  “retentions=”

storage-schemas.conf

[plivoOutboundCalls]pattern=plivoOutboundCalls$retentions=10s:14d

Page 16: Graph Everything

[plivoOutboundCalls]pattern=plivoOutboundCalls$retentions=10s:14d

• [plivo_outbound_calls] is the name of this rule

• Will match any metric that ends with plivoOutboundCalls. plivo.server.proxy.p1.plivoOutboundCallsplivo.server.proxy.p1.plivoOutboundCalls.tsudot  

• The retention line says that each datapoint represents 10 seconds, and we want to keep enough datapoints so that they add up to 14 days of data.

example

Page 17: Graph Everything

Helps  is  achieving•  replication•  sharding

Relay  Methods  •  rules•  consistent-­‐hashing

carbon-relay.py

Page 18: Graph Everything

•  Plaintext•  Pickle•  AMQP

Feeding in your data

Page 19: Graph Everything

<metric  path>  <metric  value>  <metric  timestamp>

PORT=2003SERVER=gr.plivo.comecho  "plivo.OutboundCalls  4  `date  +%s`"  |  nc  ${SERVER}  ${PORT};

plaintext protocol

Page 20: Graph Everything

•Efficient  than  the  plaintext  protocol•Supports  sending  batches  of  metrics

payload  =  pickle.dumps(listOfMetricTuples)header  =  struct.pack("!L",  len(payload))message  =  header  +  payload

pickle protocol

Page 21: Graph Everything

•Fixed  sized  database•Fast,  reliable  storage  of  numeric  data•Long  term  retention

Whisper

Page 22: Graph Everything

•Collapse  multiple  data  points•Uses  avg  by  default•Other  methods  -­‐  sum,last,max,min

Whisper : aggregation

Page 23: Graph Everything

•Each  datapoint  is  stored  with  timestamp•Archives  overlap  time  periods•All  time-­‐slots  take  up  space

Whisper : efficiency

Page 24: Graph Everything

Graphite at Plivopip install graphite-web

Page 25: Graph Everything

/render?

from=-24hours

&until=now

&target=api1.process_gunicorn._cpu_

&target=api2.process_gunicorn._cpu_

The Render URL API

Page 26: Graph Everything

The Render URL API cpu usage metrics

Page 27: Graph Everything

The Render URL API “json output anyone?”

/render?

from=-24hours

&until=now

&target=django.users._registered_

&target=django.users._webrtc_

&format=json

Page 28: Graph Everything

Graphenedescription  =  {    "Total  Notifications":  {        source:  "http://localhost:4567/",        GaugeLabel:  {            parent:  "#hero-­‐one",            title:  "Notifications  Served",            type:  "max"        }    },    "Poll  Time":  {        source:  "http://localhost:4567/",        GaugeGadget:  {            parent:  "#hero-­‐one",            title:  "P1"        }    },    "<just  an  informative  label>":  {        source:  "<graphite  graph  url,  add  &format=json  to  querystring>",        "<widget  type>":  {            parent:  "<which  will  be  placed  in  this  element>",            title:  "<title>"            //  ...  many  other  view  opts  ...        }    }}

Page 29: Graph Everything
Page 30: Graph Everything

Summary

Page 31: Graph Everything

Thanks!