support for dashed lines in graphs
[rrdtool.git] / doc / rrdgraph_examples.pod
1 =head1 NAME
2
3 rrdgraph_examples - Examples for rrdtool graph
4
5 =head1 SYNOPSIS
6
7 B<rrdtool graph /home/httpd/html/test.png --img-format PNG>
8
9 followed by any of the examples below
10
11 =head1 DESCRIPTION
12
13 For your convenience some of the commands are explained here
14 by using detailed examples. They are not always cut-and-paste
15 ready because comments are intermixed with the examples.
16
17 =head1 EXAMPLES
18
19 =head2 Data with multiple resolutions
20
21     --end now --start end-120000s --width 400
22     DEF:ds0a=/home/rrdtool/data/router1.rrd:ds0:AVERAGE
23     DEF:ds0b=/home/rrdtool/data/router1.rrd:ds0:AVERAGE:step=1800
24     DEF:ds0c=/home/rrdtool/data/router1.rrd:ds0:AVERAGE:step=7200
25     LINE1:ds0a#0000FF:"default resolution\l"
26     LINE1:ds0b#00CCFF:"resolution 1800 seconds per interval\l"
27     LINE1:ds0c#FF00FF:"resolution 7200 seconds per interval\l"
28
29 =head2 Nicely formatted legend section
30
31     DEF:ds0=/home/rrdtool/data/router1.rrd:ds0:AVERAGE
32     DEF:ds1=/home/rrdtool/data/router1.rrd:ds1:AVERAGE
33     VDEF:ds0max=ds0,MAXIMUM
34     VDEF:ds0avg=ds0,AVERAGE
35     VDEF:ds0min=ds0,MINIMUM
36     VDEF:ds0pct=ds0,95,PERCENT
37     VDEF:ds1max=ds1,MAXIMUM
38     VDEF:ds1avg=ds1,AVERAGE
39     VDEF:ds1min=ds1,MINIMUM
40     VDEF:ds1pct=ds1,95,PERCENT
41
42 Note: consolidation occurs here.
43
44     CDEF:ds0bits=ds0,8,*
45     CDEF:ds1bits=ds1,8,*
46
47 Note: 10 spaces to move text to the right
48
49     COMMENT:"          "
50
51 Note: the column titles have to be as wide as the columns
52
53     COMMENT:"Maximum    "
54     COMMENT:"Average    "
55     COMMENT:"Minimum    "
56
57     COMMENT:"95th percentile\l"
58     AREA:ds0bits#00C000:"Inbound "
59     GPRINT:ds0max:"%6.2lf %Sbps"
60     GPRINT:ds0avg:"%6.2lf %Sbps"
61     GPRINT:ds0min:"%6.2lf %Sbps"
62     GPRINT:ds0pct:"%6.2lf %Sbps\l"
63     LINE1:ds1bits#0000FF:"Outbound"
64     GPRINT:ds1max:"%6.2lf %Sbps"
65     GPRINT:ds1avg:"%6.2lf %Sbps"
66     GPRINT:ds1min:"%6.2lf %Sbps"
67     GPRINT:ds1pct:"%6.2lf %Sbps\l"
68
69 =head2 Offsetting a line on the y-axis
70
71 Depending on your needs you can do this in two ways:
72
73 =over
74
75 =item *
76
77 Offset the data, then graph this
78
79     DEF:mydata=my.rrd:ds:AVERAGE
80
81 Note: this will also influence any other command that uses "data"
82
83     CDEF:data=mydata,100,+
84     LINE1:data#FF0000:"Data with offset"
85
86 =item *
87
88 Graph the original data, with an offset
89
90     DEF:mydata=my.rrd:ds:AVERAGE
91
92 Note: no color in the first line so it is not visible
93
94     LINE1:100
95
96 Note: the second line gets stacked on top of the first one
97
98     LINE1:data#FF0000:"Data with offset":STACK
99
100 =back
101
102 =head2 Drawing dashed lines
103
104 Also works for HRULE and VRULE
105
106 =over
107
108 =item *
109
110 default style: - - - - -
111     LINE1:data#FF0000:"dashed line":DASHED
112
113 =item *
114
115 more fancy style with offset: - -  --- -  --- -
116     LINE1:data#FF0000:"another dashed line":DASHED:dashes=15,5,5,10:dash-offset=10
117
118 =head2 Time ranges
119
120     Last four weeks: --start end-4w --end 00:00
121     January 2001:    --start 20010101 --end start+31d
122     January 2001:    --start 20010101 --end 20010201
123     Last hour:       --start end-1h
124     Last 24 hours:   <nothing at all>
125     Yesterday:       --end 00:00
126
127 =head2 Viewing the current and previous week together
128
129     --end now --start end-1w
130     DEF:thisweek=router.rrd:ds0:AVERAGE
131     DEF:lastweek=router.rrd:ds0:AVERAGE:end=now-1w:start=end-1w
132
133 Shift the data forward by one week (604800 seconds)
134
135     SHIFT:lastweek:604800
136     [ more of the usual VDEF and CDEF stuff if you like ]
137     AREA:lastweek#0000FF:Last\ week
138     LINE1:thisweek#FF0000:This\ week
139
140 =head2 Aberrant Behaviour Detection
141
142 If the specialized function B<RRAs> exist for aberrant behavior detection, they
143 can be used to generate the graph of a time series with confidence bands and
144 failures.
145
146    rrdtool graph example.png \
147           DEF:obs=monitor.rrd:ifOutOctets:AVERAGE \
148           DEF:pred=monitor.rrd:ifOutOctets:HWPREDICT \
149           DEF:dev=monitor.rrd:ifOutOctets:DEVPREDICT \
150           DEF:fail=monitor.rrd:ifOutOctets:FAILURES \
151           TICK:fail#ffffa0:1.0:"Failures\: Average bits out" \
152           CDEF:scaledobs=obs,8,* \
153           CDEF:upper=pred,dev,2,*,+ \
154           CDEF:lower=pred,dev,2,*,- \
155           CDEF:scaledupper=upper,8,* \
156           CDEF:scaledlower=lower,8,* \
157           LINE2:scaledobs#0000ff:"Average bits out" \
158           LINE1:scaledupper#ff0000:"Upper Confidence Bound: Average bits out" \
159           LINE1:scaledlower#ff0000:"Lower Confidence Bound: Average bits out"
160
161 This example generates a graph of the data series in blue (LINE2 with the scaledobs
162 virtual data source), confidence bounds in red (scaledupper and scaledlower virtual
163 data sources), and potential failures (i.e. potential aberrant aberrant behavior)
164 marked by vertical yellow lines (the fail data source).
165
166 The raw data comes from an AVERAGE B<RRA>, the finest resolution of the observed
167 time series (one consolidated data point per primary data point). The predicted
168 (or smoothed) values are stored in the HWPREDICT B<RRA>. The predicted deviations
169 (think standard deviation) values are stored in the DEVPREDICT B<RRA>. Finally,
170 the FAILURES B<RRA> contains indicators, with 1 denoting a potential failure.
171
172 All of the data is rescaled to bits (instead of Octets) by multiplying by 8.
173 The confidence bounds are computed by an offset of 2 deviations both above
174 and below the predicted values (the CDEFs upper and lower). Vertical lines
175 indicated potential failures are graphed via the TICK graph element, which
176 converts non-zero values in an B<RRA> into tick marks. Here an axis-fraction
177 argument of 1.0 means the tick marks span the entire y-axis, and hence become
178 vertical lines on the graph.
179
180 The choice of 2 deviations (a scaling factor) matches the default used internally
181 by the FAILURES B<RRA>. If the internal value is changed (see L<rrdtune>), this
182 graphing command should be changed to be consistent.
183
184 =head3 A note on data reduction:
185
186 The B<rrdtool> I<graph> command is designed to plot data at a specified temporal
187 resolution, regardless of the actually resolution of the data in the RRD file.
188 This can present a problem for the specialized consolidation functions which
189 maintain a one-to-one mapping between primary data points and consolidated
190 data points. If a graph insists on viewing the contents of these B<RRAs> on a
191 coarser temporal scale, the I<graph> command tries to do something intelligent,
192 but the confidence bands and failures no longer have the same meaning and may
193 be misleading.
194
195
196 =head1 SEE ALSO
197
198 L<rrdgraph> gives an overview of how B<rrdtool graph> works.
199 L<rrdgraph_data> describes B<DEF>,B<CDEF> and B<VDEF> in detail.
200 L<rrdgraph_rpn> describes the B<RPN> language used in the B<xDEF> statements.
201 L<rrdgraph_graph> page describes all the graph and print functions.
202
203 Make sure to read L<rrdgraph_examples> for tipsE<amp>tricks.
204
205 =head1 AUTHOR
206
207 Program by Tobias Oetiker E<lt>tobi@oetiker.chE<gt>
208
209 This manual page by Alex van den Bogaerdt E<lt>alex@ergens.op.het.netE<gt>