-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphite.html
177 lines (155 loc) · 9.04 KB
/
graphite.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>Graphite+StatsD 服务Metrics监控 — Feng's blog 1.0 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/custom.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="如何构建一个All In One的Python Package" href="build-all-in-one-package-for-python-application.html" />
<link rel="prev" title="SystemTap" href="systemtap.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="graphite-statsd-fu-wu-metrics-jian-kong">
<h1>Graphite+StatsD 服务Metrics监控<a class="headerlink" href="#graphite-statsd-fu-wu-metrics-jian-kong" title="Permalink to this headline">¶</a></h1>
<section id="graphite">
<h2>Graphite<a class="headerlink" href="#graphite" title="Permalink to this headline">¶</a></h2>
<p>Graphite是一个database + 图形展示工具,我们可以将服务的各种指标数据发送给Graphite,Graphite的Web页面中会以曲线的形式展现这些数据,方便我们观察对比服务的运行状况。</p>
<p>下面是Graphite的架构图:</p>
<img alt="_images/graphite-architecher.png" src="_images/graphite-architecher.png" />
<section id="ru-he-feed-in-shu-ju">
<h3>如何Feed in数据<a class="headerlink" href="#ru-he-feed-in-shu-ju" title="Permalink to this headline">¶</a></h3>
<p>纯文本协议</p>
<p>Shell:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>echo "local.random.diceroll 4 `date +%s`" | nc -q0 ${SERVER} ${PORT}
</pre></div>
</div>
<p>Python:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">socket</span>
<span class="n">sock</span> <span class="o">=</span> <span class="n">socket</span><span class="o">.</span><span class="n">socket</span><span class="p">(</span><span class="n">socket</span><span class="o">.</span><span class="n">AF_INET</span><span class="p">,</span> <span class="n">socket</span><span class="o">.</span><span class="n">AF_DGRAM</span><span class="p">)</span>
<span class="n">sock</span><span class="o">.</span><span class="n">sendto</span><span class="p">(</span><span class="s1">'runtime.py.yq30.instances 200 1324567980'</span><span class="p">,</span> <span class="p">(</span><span class="n">ip</span><span class="p">,</span> <span class="n">port</span><span class="p">))</span>
</pre></div>
</div>
<p>数据Feed in地址:udp://metrics.sae.sina.com.cn:2006</p>
</section>
<section id="shu-ju-zhan-shi-ye-mian">
<h3>数据展示页面<a class="headerlink" href="#shu-ju-zhan-shi-ye-mian" title="Permalink to this headline">¶</a></h3>
<p>数据展示页面:<a class="reference external" href="http://metrics.sae.sina.com.cn">http://metrics.sae.sina.com.cn</a></p>
<img alt="_images/graphite-ui.png" src="_images/graphite-ui.png" />
</section>
<section id="functions">
<h3>Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h3>
<p>grahpite中所有的曲线数据都是可以使用函数进行操作的</p>
<img alt="_images/graphite-composer-1.png" src="_images/graphite-composer-1.png" />
<p>你也可以对这些生成的函数进行手工编辑:</p>
<img alt="_images/graphite-composer-2.png" src="_images/graphite-composer-2.png" />
<p>Read more: <a class="reference external" href="http://graphite.readthedocs.org/en/1.0/functions.html">http://graphite.readthedocs.org/en/1.0/functions.html</a></p>
</section>
<section id="zhi-zuo-dashboard">
<h3>制作Dashboard<a class="headerlink" href="#zhi-zuo-dashboard" title="Permalink to this headline">¶</a></h3>
<p>效果图:</p>
<img alt="_images/dashboard.png" src="_images/dashboard.png" />
<p>点击graphite页面页面右上角的Dashboard链接,进入Dashboard页面,你可以直接在上面的面板中选择需要的曲线加入到dashboard中,所有的曲线都可以拖曳编辑。</p>
<p>当然你也可以直接打开dashboard的edit页面,按照下面两图手工编辑曲线的生成参数(生成复杂曲线的时候很有用)。</p>
<img alt="_images/dashboard-menu-1.png" src="_images/dashboard-menu-1.png" />
<img alt="_images/dashboard-edit.png" src="_images/dashboard-edit.png" />
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span>
<span class="p">{</span>
<span class="s2">"target"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"runtime.py.yq30.instances"</span><span class="p">,</span>
<span class="s2">"runtime.py.yq34.instances"</span>
<span class="p">],</span>
<span class="s2">"title"</span><span class="p">:</span> <span class="s2">"Instances"</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="s2">"title"</span><span class="p">:</span> <span class="s2">"5xx Ratio"</span><span class="p">,</span>
<span class="s2">"target"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"divideSeries(runtime.py.yq30.http.5xx,runtime.py.yq30.http.requests)"</span><span class="p">,</span>
<span class="s2">"divideSeries(runtime.py.yq34.http.5xx,runtime.py.yq34.http.requests)"</span>
<span class="p">]</span>
<span class="p">}</span>
<span class="p">]</span>
</pre></div>
</div>
<p>这个json数组里的每一个元素定义了一张图,target定义了在图上要显示哪几条曲线,title是图的标题。</p>
<p>target可以是单个曲线,也可以是多个曲线使用function进行的变换后的曲线。比如上面的例子中,第二张图就展示了yq30和yq34两台机器上的http 5xx出现比例的曲线(5xx出现的次数除上总请求数)。</p>
</section>
</section>
<section id="statsd">
<h2>StatsD<a class="headerlink" href="#statsd" title="Permalink to this headline">¶</a></h2>
</section>
</section>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Graphite+StatsD 服务Metrics监控</a><ul>
<li><a class="reference internal" href="#graphite">Graphite</a><ul>
<li><a class="reference internal" href="#ru-he-feed-in-shu-ju">如何Feed in数据</a></li>
<li><a class="reference internal" href="#shu-ju-zhan-shi-ye-mian">数据展示页面</a></li>
<li><a class="reference internal" href="#functions">Functions</a></li>
<li><a class="reference internal" href="#zhi-zuo-dashboard">制作Dashboard</a></li>
</ul>
</li>
<li><a class="reference internal" href="#statsd">StatsD</a></li>
</ul>
</li>
</ul>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/graphite.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="https://cn.bing.com/search" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>
$('#searchbox').show(0);
document.getElementsByClassName('search')[0].addEventListener('submit', function(event) {
event.preventDefault();
var form = event.target;
var input = form.querySelector('input[name="q"]');
var value = input.value;
var q = 'ensearch=1&q=site%3Achanfung032.github.io++' + value;
var url = form.action + '?' + q;
window.location.href = url;
});
</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
©2017, chanfung032.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 4.1.2</a>
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="_sources/graphite.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>