2
<p>The instance reporting module tracks and records statistics of instance
3
usage. It tracks instance running time, instance type, disk IO usage,
6
<p>This module gathers usage statistics by receiving events every <i>n</i>
7
seconds for each instance then recording a series of snapshots of total
8
usage for each instance to the database. It does not necessarily record a
9
snapshot for every event received; generally it aggregates several events
10
and then writes a single snapshot per instance every few hours; the
11
interval can be adjusted via a runtime property.
13
<p>When a report is generated, this module aggregates database snapshots
14
into a series of statistics which are returned as a list of <i>Report Lines</i>
15
to be displayed in a visual report. The statistics are aggregated by the
16
<i>InstanceUsageLog</i> class, which proceeds using the following algorithm.
17
First it scans through all snapshots relevant to the report, starting with
18
the snapshot immediately before the report beginning and ending at the
19
snapshot immediately after the report end. Then it constructs an
20
<i>InstanceDataAccumulator</i> object for each instance and feeds in
21
every snapshot for the relevant instance to that accumulator. The accumulator
22
keeps track of the first and last snapshots for that instance and subtracts
23
the first usage from the last, including timestamp, extrapolating those values
24
according to the partial periods at the beginning and end of the report. At
25
this point, we have aggregate statistics for each instance. Then, we
26
<i>summarize</i> that data based upon the criteria which the user selected
27
for his report (by account, by availability zone, etc), which means
28
that we add up all usage of all instances within the given account or
29
availability zone etc. Then we return the <i>ReportLines</i> to be displayed