-
Notifications
You must be signed in to change notification settings - Fork 909
/
statsd_admin.xml
251 lines (236 loc) · 8.01 KB
/
statsd_admin.xml
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
<!-- Include general documentation entities -->
<!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
%docentities;
]>
<!-- Module User's Guide -->
<chapter xmlns:xi="http://www.w3.org/2001/XInclude">
<title>&adminguide;</title>
<section>
<title>Overview</title>
<para>
The module provides the ability to send commands to statsd
(you can use InfluxDB too) with different types of information.
It provides native integration with statsd (https://github.com/etsy/statsd/)
and graphite (http://graphite.wikidot.com/).
</para>
<para>
The module does not have any special dependency, it does a direct
socket connection to Graphite.
</para>
</section>
<section>
<title>Parameters</title>
<section id="statsd.p.ip">
<title><varname>ip</varname>(string)</title>
<para>
Statsd server IP address.
</para>
<para>
Defaults to 127.0.0.1
</para>
<example>
<title>Set ip parameter</title>
<programlisting format="linespecific">
...
modparam("statsd", "ip", "127.0.0.1")
...
</programlisting>
</example>
</section>
<section id="statsd.p.port">
<title><varname>port</varname>(string)</title>
<para>
Statsd server port number
</para>
<para>
Defaults to 8125
</para>
<example>
<title>Set port parameter</title>
<programlisting format="linespecific">
...
modparam("statsd", "port", "8125")
...
</programlisting>
</example>
</section>
</section>
<section>
<title>Functions</title>
<section id="statsd.f.statsd_set">
<title>
<function moreinfo="none">statsd_set(key, value)</function>
</title>
<para>
Sets count the number of unique values passed to a key.
</para>
<para>
If this method is called multiple times with the same userid in the same sample period, that userid will only be counted once.
</para>
<para>
This function can be used in ALL ROUTES.
</para>
<example>
<title><function>statsd_set</function> usage</title>
<programlisting format="linespecific">
...
failure_route[tryagain] {
...
statsd_set("customerFailure", 1);
...
}
...
</programlisting>
</example>
</section>
<section id="statsd.f.statsd_gauge">
<title>
<function moreinfo="none">statsd_gauge(key, value)</function>
</title>
<para>
Gauges are a constant data type. They are not subject to averaging
and they don't change unless you change them. That is, once you set
a gauge value, it will be a flat line on the graph until you change it again.
</para>
<para>
Gauges are useful for things that are already averaged, or don't need to reset periodically
</para>
<para>
This function can be used in ALL ROUTES.
</para>
<para>
The statsd server collects gauges under the stats.gauges prefix.
</para>
<example>
<title><function>statsd_gauge</function> usage</title>
<programlisting format="linespecific">
...
route [gauge_method]{
statsd_gauge("method"+$rm, "+1");
statsd_gauge("customer_credit"+$var(customer),"$var(customer_credit)");
}
...
</programlisting>
</example>
</section>
<section id="statsd.f.statsd_histogram">
<title>
<function moreinfo="none">statsd_histogram(key, value)</function>
</title>
<para>
The histograms are a measure of time, but they are calculated at the server side.
As the data exported by the client is the same, this is just an alias for the Timer type.
</para>
<para>
This function can be used in ALL ROUTES.
</para>
<para>
The statsd server collects histograms under the stats.histograms prefix.
</para>
<example>
<title><function>statsd_histogram</function> usage</title>
<programlisting format="linespecific">
...
statsd_histogram("latency", 1000);
...
</programlisting>
</example>
</section>
<section id="statsd.f.statsd_start">
<title>
<function moreinfo="none">statsd_start(key)</function>
</title>
<para>
statsd_start set an avp with the key name, and when
statsd_stop(key) is used, the module will send statsd the difference in
milliseconds. This is useful to know the time of a SQL query, or how much time your replies take.
</para>
<para>
This function can be used in all routes.
</para>
<para>
The statsd server collects all timers under the stats.timers prefix
and will calculate the lower bound, mean, 90th percentile, upper bound, and count of each
timer for each period (by the time it can be seen in graphite, that's usually per minute).
</para>
<example>
<title><function>statsd_start</function> usage</title>
<programlisting format="linespecific">
...
statsd_start("long_mysql_query");
sql_query("ca", "select sleep(0.2)", "ra");
statsd_stop("long_mysql_query");
...
</programlisting>
</example>
</section>
<section id="statsd.f.statsd_stop">
<title>
<function moreinfo="none">statsd_stop(key)</function>
</title>
<para>
statsd_stop(key) get the avp string with the key and calculate the
difference from the start time. When finished the milliseconds used will be sent to statsd.
</para>
<para>
This function can be used in all routes.
</para>
<example>
<title><function>statsd_stop</function> usage</title>
<programlisting format="linespecific">
...
statsd_start("long_mysql_query");
sql_query("ca", "select sleep(0.2)", "ra");
statsd_stop("long_mysql_query");
...
</programlisting>
</example>
</section>
<section id="statsd.f.statsd_incr">
<title>
<function moreinfo="none">statsd_incr(key)</function>
</title>
<para>
Increment a statsd counter
</para>
<para>
This function can be used in all routes.
</para>
<example>
<title><function>statsd_incr</function> usage</title>
<programlisting format="linespecific">
...
if(geoip_match("$si", "src")){
statsd_incr("country."+$(gip(src=>cc)));
}
...
</programlisting>
</example>
</section>
<section id="statsd.f.statsd_decr">
<title>
<function moreinfo="none">statsd_decr(key)</function>
</title>
<para>
Decrement a counter
</para>
<para>
This function can be used in all routes.
</para>
<example>
<title><function>statsd_decr</function> usage</title>
<programlisting format="linespecific">
...
if (t_check_status("408")) {
statsd_decr("kamailio.successfulCalls");
statsd_incr("kamailio.reply.timeout");
}
...
</programlisting>
</example>
</section>
</section>
</chapter>