Graphite

260 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
260
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Graphite

  1. 1. When In Doubt, Graph It Out
  2. 2. Agenda»Why should we graph data?»Overview of Graphite»Shell script example»Java example»Additional tools
  3. 3. Why should we graph stuff?
  4. 4. Alternatives to Graphite
  5. 5. Log filesDEBUG [01-Mar-12 10:36:03] [pool-10-thread-2] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1201584957-8316815-0_mbsDEBUG [01-Mar-12 10:36:03] [pool-10-thread-1] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1306883462-9748970-0-o_mesDEBUG [01-Mar-12 10:36:03] [pool-10-thread-3] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1284651005-4763277-0-8-bmx_mesDEBUG [01-Mar-12 10:36:03] [pool-10-thread-2] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1196567997-8624786d-0_mesDEBUG [01-Mar-12 10:36:03] [pool-10-thread-3] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1284649502-3873052-80503-bmx_mesDEBUG [01-Mar-12 10:36:03] [pool-10-thread-2] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1211339455-1237643d-0_mpsDEBUG [01-Mar-12 10:36:03] [pool-10-thread-1] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1300850840-2087124-0-p_mbsDEBUG [01-Mar-12 10:36:03] [pool-10-thread-1] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1294954750-9188506-0-p_mesDEBUG [01-Mar-12 10:36:03] [pool-10-thread-2] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1196873161-5673618d-0_mpsDEBUG [01-Mar-12 10:36:03] [pool-10-thread-2] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1257526947-2361816-0_mpsDEBUG [01-Mar-12 10:36:03] [pool-10-thread-2] com.pronto.sem.job.BidUpdateRunnable :Processed Row[1700]DEBUG [01-Mar-12 10:36:03] [pool-11-thread-1] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1296091717-9634933-0-md_ysDEBUG [01-Mar-12 10:36:03] [pool-11-thread-3] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1292018269-8694964-0-md_ysDEBUG [01-Mar-12 10:36:04] [pool-10-thread-2] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1189412336-672954-0_mesDEBUG [01-Mar-12 10:36:04] [pool-10-thread-1] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1196829650-9210295d-0-p_mesDEBUG [01-Mar-12 10:36:04] [pool-11-thread-2] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1299102528-4698537-0-md_ysDEBUG [01-Mar-12 10:36:04] [pool-10-thread-1] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1295153899-6527254-0-p_mesDEBUG [01-Mar-12 10:36:04] [pool-10-thread-2] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1257523345-7680668-0_mbsDEBUG [01-Mar-12 10:36:04] [pool-10-thread-3] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1191889434-6754217-0_mpsDEBUG [01-Mar-12 10:36:04] [pool-10-thread-1] com.pronto.sem.manager.impl.BidManagerImpl :Updated keyword bid for: 1292858452-5997889-0-p_mps
  6. 6. Cacti (http://report01/dashboard/)
  7. 7. Enough talk.What is this Graphite you speak of?
  8. 8. http://graphite101/
  9. 9. How do we get data into Graphite?»telnet to port 2003»Enter 3 valuesmetric.name value unixtime
  10. 10. Example in bash#!/bin/bash# Set this hostnameHOSTNAME=`/bin/hostname --short`# Set Graphite hostGRAPHITE=graphite101GRAPHITE_PORT=2003# Get epochDATE=`/bin/date +%s`# Collect some dataMY_DATA=`/usr/sbin/lsof -u tomcat | /usr/bin/wc -l`# Send data to Graphiteecho "stats.${HOSTNAME}.file_handle.count ${MY_DATA} ${DATE}" | /usr/bin/nc $GRAPHITE $GRAPHITE_PORT
  11. 11. Example in Javaimport java.io.OutputStreamWriter;import java.io.Writer;import java.net.Socket;public class GraphiteLogger { private static String GRAPHITE_HOST = "graphite101"; private static int GRAPHITE_PORT = 2003; public static void logToGraphite(String metric, int value) throws Exception { Long timeInSeconds = System.currentTimeMillis() / 1000; Socket socket = new Socket(GRAPHITE_HOST, GRAPHITE_PORT); try { Writer writer = new OutputStreamWriter(socket.getOutputStream()); writer.write(metric + " " + value + " " + timeInSeconds + "n"); writer.flush(); writer.close(); } finally { socket.close(); } } public static void main(String[]args) throws Exception { GraphiteLogger.logToGraphite("stats.test.example.count", 100); }}
  12. 12. Where is data stored?/opt/graphite/storage/whisper
  13. 13. Other tools
  14. 14. logster
  15. 15. StatsD
  16. 16. graphitejs
  17. 17. graphios
  18. 18. jmxtrans
  19. 19. For more informationhttp://graphite.readthedocs.org/en/1.0/index.html

×