provider-accounting
Component description
Contrail package contrail-provider-accounting provides HTTP API to retrieve monitoring data, e.g. metrics historical values, calculate various aggregate values of selected metrics on given time interval, calculate derived metrics values.
Configuration Files
accounting.cfg
Location: /etc/contrail/provider/accounting/accounting.cfg
# Contrail-provider-accounting configuration
#------------------------------------------------------------------------------------------
# Database settings
mongodb.host=localhost
mongodb.port=27017
mongodb.database=monitoring
mongodb.rawCollection=rawData
mongodb.compressedCollection=compressedData
HTTP API
The accounting API provides following methods:
- retrieving aggregate metrics data
- retrieving metrics historical data
- calculating derived metrics value
Retrieving aggregate metrics data
Description
Calculates aggregate value of given metric for given time period, host(s) and aggregate function. Aggregate value can be calculated for a single host or a set of hosts.
For the specified metric historical data is retrieved from the database and on that data the aggregate function is applied.
Usage
Path parameters:
- group: group of the metric
- metric: name of the metric
- aggregate: aggregate function (min, max, mean)
POST parameters:
- source: host or vm
- sid: array of ids
- startTime: start of the time period in ISO 8601 date format. If startTime is not given the beginning metric historical data is assumed.
- endTime: end of the time period in ISO 8601 date format. If endTime is not given the current time is assumed.
Supported aggregate functions
min
Finds the minimum value of the given metric on the given time period. Returns value, timestamp and sid where the minimum occurred.
max
Finds the maximum value of the given metric on the given time period. Returns value, timestamp and sid where the maximum occurred.
mean
Calculates arithmetic mean and standard deviation of the metric values on the given time period.
Example
Request:
{
"source":"host",
"sid":["node001.test.com"],
"startTime":"2012-06-01T00:00:00.000+0200",
"endTime":"2012-06-02T00:00:00.000+0200"
}
Response:
"mean" : 0.31125,
"stddev" : 0.19751186673210297
}
Retrieving metrics historical data
Description
Returns historical data of the given metric on the given time period. Data is returned as JSON array of (time, value) objects.
Usage
Path parameters:
- group: group of the metric
- metric: name of the metric
POST parameters:
- source: host or vm
- sid: array of ids
- startTime: start of the time period in ISO 8601 date format. If startTime is not given the beginning of metric historical data is assumed.
- endTime: end of the time period in ISO 8601 date format. If endTime is not given the current time is assumed.
Example
Request:
{
"source":"host",
"sid":"node001.test.com",
"startTime":"2012-06-01T10:00:00.000+0200",
"endTime":"2012-06-01T12:00:00.000+0200"
}
Response:
"time" : "2012-06-01T10:00:00+0200",
"load_one" : 0.27
}, {
"time" : "2012-06-01T10:01:00+0200",
"load_one" : 0.55
},
...
]
Calculating derived metrics value
Description
Calculates value of the specified derived metric on the given time period.
Usage
Path parameters:
- group: group of the metric
- metric: name of the metric
POST parameters:
- source: host or vm
- sid: id of the host/vm or array of ids if supported by the metric
- startTime: start of the time period in ISO 8601 date format. If startTime is not given the beginning of metric historical data is assumed.
- endTime: end of the time period in ISO 8601 date format. If endTime is not given the current time is assumed.
Example
Request:
{
"source":"host",
"sid":"host001.test.com",
"startTime":"2012-06-01T00:00:00.000+0200",
"endTime":"2012-06-02T00:00:00.000+0200"
}
Response:
"uptime" : 85120,
"NAtime" : 0,
"availability" : 0.985185,
"downtime" : 1280
}
Supported metrics
Availability
Host
Availability of a host is calculated as a ratio of host's uptime and sum of host's uptime and downtime:
Unknown macro: formula. Click on this message for details.
First the historical data for the metric 'available' (group=common) is retrieved from the database by calling storage-manager API for the specified time period. The 'available' metric tells the up/down status of a host at certain time points. The accounting component iterates the historical data and calculates the sum of all up and down intervals length. Availability is then calculated by dividing total uptime by sum of total uptime and downtime. Intervals for which no monitoring data is available (value of available metric is N/A) are not taken into account.
Set of hosts
Availability of a set of hosts is calculated as a arithmetic average of availability of individual hosts:
Unknown macro: formula. Click on this message for details.