public class RrdMetricsRetriever extends Object implements MetricsRetriever
The supported formats include:
Aggregate reports, which include the data for all metrics, over a specified time range are also supported in XLS (Excel) and PPT (PowerPoint) format. For example, if there are 10 metrics that are having data collected, then an aggregate report in XLS would be a spreadsheet with a separate worksheet for each of the 10 metrics. Similarly, this aggregate report in PPT format would consist of a slide per metric, where each slide contains the metric's graph and total count (if applicable).
Modifier and Type | Class and Description |
---|---|
static class |
RrdMetricsRetriever.SUMMARY_INTERVALS |
Modifier and Type | Field and Description |
---|---|
static int |
EXCEL_MAX_COLUMNS |
static String |
SUMMARY_TIMESTAMP |
Constructor and Description |
---|
RrdMetricsRetriever() |
RrdMetricsRetriever(double metricsMaxThreshold) |
Modifier and Type | Method and Description |
---|---|
static String |
convertCamelCase(String input)
Convert string, if it is in camelCase, to individual words with each word starting with a
capital letter
|
String |
createCsvData(String rrdFilename,
long startTime,
long endTime)
Retrieves the metric's data as a CSV (Comma Separated Values) formatted string from the
specified RRD file over the specified time range.
|
byte[] |
createGraph(String metricName,
String rrdFilename,
long startTime,
long endTime)
Retrieves the PNG-formatted graph of the metric's data from the specified RRD file over the
specified time range.
|
byte[] |
createGraph(String metricName,
String rrdFilename,
long startTime,
long endTime,
String verticalAxisLabel,
String title)
Retrieves the PNG-formatted graph of the metric's data from the specified RRD file over the
specified time range, using the input y-axis label and title on the graph that is generated.
|
String |
createJsonData(String metricName,
String rrdFilename,
long startTime,
long endTime)
Retrieves the metric's data as a JSON formatted string from the specified RRD file over the
specified time range.
|
OutputStream |
createPptData(String metricName,
String rrdFilename,
long startTime,
long endTime)
Retrieves the metric's data as a PPT (PowerPoint) formatted stream from the specified RRD file
over the specified time range.
|
OutputStream |
createPptReport(List<String> metricNames,
String metricsDir,
long startTime,
long endTime)
Returns a PPT (PowerPoint) formatted stream over the specified time range that contains one
slide for each metric.
|
OutputStream |
createXlsData(String metricName,
String rrdFilename,
long startTime,
long endTime)
Retrieves the metric's data as an XLS (Excel spreadsheet) formatted stream from the specified
RRD file over the specified time range.
|
OutputStream |
createXlsReport(List<String> metricNames,
String metricsDir,
long startTime,
long endTime,
String summaryInterval)
Returns an XLS (Excel spreadsheet) formatted stream over the specified time range that contains
one worksheet for each metric.
|
String |
createXmlData(String metricName,
String rrdFilename,
long startTime,
long endTime)
Retrieves the metric's data as an XML formatted string from the specified RRD file over the
specified time range.
|
MetricData |
getMetricData(String rrdFilename,
long startTime,
long endTime)
Retrieves the RRD stored data for the specified metric over the specified time range.
|
void |
setMetricsMaxThreshold(double metricsMaxThreshold) |
public static final String SUMMARY_TIMESTAMP
public static final int EXCEL_MAX_COLUMNS
public RrdMetricsRetriever()
public RrdMetricsRetriever(double metricsMaxThreshold)
public static String convertCamelCase(String input)
public byte[] createGraph(String metricName, String rrdFilename, long startTime, long endTime) throws IOException, MetricsGraphException
MetricsRetriever
createGraph
in interface MetricsRetriever
metricName
- name of the metric to be graphedrrdFilename
- name of the RRD file to retrieve the metric's data fromstartTime
- start time, in seconds since Unix epoch, to retrieve metric's dataendTime
- end time, in seconds since Unix epoch, to retrieve metric's dataIOException
MetricsGraphException
public byte[] createGraph(String metricName, String rrdFilename, long startTime, long endTime, String verticalAxisLabel, String title) throws IOException, MetricsGraphException
MetricsRetriever
createGraph
in interface MetricsRetriever
metricName
- name of the metric to be graphedrrdFilename
- name of the RRD file to retrieve the metric's data fromstartTime
- start time, in seconds since Unix epoch, to retrieve metric's dataendTime
- end time, in seconds since Unix epoch, to retrieve metric's dataverticalAxisLabel
- label to use for the vertical (y) axistitle
- the title to use for the graphIOException
MetricsGraphException
public String createCsvData(String rrdFilename, long startTime, long endTime) throws IOException, MetricsGraphException
MetricsRetriever
createCsvData
in interface MetricsRetriever
rrdFilename
- name of the RRD file to retrieve the metric's data fromstartTime
- start time, in seconds since Unix epoch, to retrieve metric's dataendTime
- end time, in seconds since Unix epoch, to retrieve metric's dataIOException
MetricsGraphException
public String createXmlData(String metricName, String rrdFilename, long startTime, long endTime) throws IOException, MetricsGraphException
MetricsRetriever
The format of this XML string will be:
<metricName>
<title>metricName for startTime to endTime</title>
<data>
<sample>
<timestamp>MMM DD YYY hh:mm:ss</timestamp>
<value>12345</value>
</sample>
<sample>
...
</sample>
<totalCount>99999</totalCount>
</data>
</metricName>
Note that createXmlData
in interface MetricsRetriever
metricName
- name of the metric to retrieve data forrrdFilename
- name of the RRD file to retrieve the metric's data fromstartTime
- start time, in seconds since Unix epoch, to retrieve metric's dataendTime
- end time, in seconds since Unix epoch, to retrieve metric's dataIOException
MetricsGraphException
public OutputStream createXlsData(String metricName, String rrdFilename, long startTime, long endTime) throws IOException, MetricsGraphException
MetricsRetriever
createXlsData
in interface MetricsRetriever
metricName
- name of the metric to retrieve data forrrdFilename
- name of the RRD file to retrieve the metric's data fromstartTime
- start time, in seconds since Unix epoch, to retrieve metric's dataendTime
- end time, in seconds since Unix epoch, to retrieve metric's dataIOException
MetricsGraphException
public OutputStream createPptData(String metricName, String rrdFilename, long startTime, long endTime) throws IOException, MetricsGraphException
MetricsRetriever
createPptData
in interface MetricsRetriever
metricName
- name of the metric to retrieve data forrrdFilename
- name of the RRD file to retrieve the metric's data fromstartTime
- start time, in seconds since Unix epoch, to retrieve metric's dataendTime
- end time, in seconds since Unix epoch, to retrieve metric's dataIOException
MetricsGraphException
public OutputStream createPptReport(List<String> metricNames, String metricsDir, long startTime, long endTime) throws IOException, MetricsGraphException
MetricsRetriever
createPptReport
in interface MetricsRetriever
metricNames
- names of the metrics to retrieve data formetricsDir
- directory containing all of the metrics' RRD files, typically
startTime
- start time, in seconds since Unix epoch, to retrieve metric's dataendTime
- end time, in seconds since Unix epoch, to retrieve metric's dataIOException
MetricsGraphException
public String createJsonData(String metricName, String rrdFilename, long startTime, long endTime) throws IOException, MetricsGraphException
MetricsRetriever
The format of this JSON string will be (data values in this sample are notional):
{
"title":"catalogQueries for Apr 10 2013 10:18:05 to Apr 10 2013 10:33:05",
"totalCount":5348,
"data":[
{
"timestamp":"Apr 10 2013 10:18:00",
"value":351
},
{
"timestamp":"Apr 10 2013 10:19:00",
"value":358
},
]
}
Note that createJsonData
in interface MetricsRetriever
metricName
- name of the metric to retrieve data forrrdFilename
- name of the RRD file to retrieve the metric's data fromstartTime
- start time, in seconds since Unix epoch, to retrieve metric's dataendTime
- end time, in seconds since Unix epoch, to retrieve metric's dataIOException
MetricsGraphException
public OutputStream createXlsReport(List<String> metricNames, String metricsDir, long startTime, long endTime, String summaryInterval) throws IOException, MetricsGraphException
MetricsRetriever
createXlsReport
in interface MetricsRetriever
metricNames
- names of the metrics to retrieve data formetricsDir
- directory containing all of the metrics' RRD files, typically
startTime
- start time, in seconds since Unix epoch, to retrieve metric's dataendTime
- end time, in seconds since Unix epoch, to retrieve metric's datasummaryInterval
- unit of time to group metrics byIOException
MetricsGraphException
public MetricData getMetricData(String rrdFilename, long startTime, long endTime) throws IOException, MetricsGraphException
rrdFilename
- the name of the RRD file containing the metric's datastartTime
- start time, in seconds since Unix epoch, to fetch metric's dataendTime
- end time, in seconds since Unix epoch, to fetch metric's dataIOException
MetricsGraphException
public void setMetricsMaxThreshold(double metricsMaxThreshold)
This work is licensed under a Creative Commons Attribution 4.0 International License.