@Path(value="/") public class MetricsEndpoint extends Object
This endpoint provides a URL to retrieve the list of metrics collected by DDF, including their associated URLs to access pre-defined time ranges of each metric's historical data, e.g., for the past 15 minutes, 1 hour, 4 hours, 12 hours, 24 hours, 3 days, 1 week, 1 month, and 1 year. Each of these hyperlinks will return a byte array containing a PNG graph of the metric's historical data for the given time range.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_METRICS_DIR |
Constructor and Description |
---|
MetricsEndpoint() |
Modifier and Type | Method and Description |
---|---|
protected void |
generateMetricsUrls(Map<String,Map<String,Map<String,String>>> metrics,
String metricsName,
javax.ws.rs.core.UriInfo uriInfo)
Generates the URLs for each time range, e.g., 15m, 1h, etc.
|
javax.ws.rs.core.Response |
getMetricsData(String metricName,
String outputFormat,
String startDate,
String endDate,
String dateOffset,
String yAxisLabel,
String title,
javax.ws.rs.core.UriInfo uriInfo)
Retrieve data for the specified metric over the given time range.
|
javax.ws.rs.core.Response |
getMetricsList(javax.ws.rs.core.UriInfo uriInfo)
Get list of available metrics and the associated URLs to their historical data.
|
javax.ws.rs.core.Response |
getMetricsReport(String outputFormat,
String startDate,
String endDate,
String dateOffset,
String summaryInterval,
javax.ws.rs.core.UriInfo uriInfo)
Retrieve data for the all metrics over the given time range.
|
protected long |
parseDate(String date)
Parse date in ISO8601 format into seconds since Unix epoch.
|
void |
setMetricsMaxThreshold(double metricsMaxThreshold) |
public static final String DEFAULT_METRICS_DIR
@GET @Path(value="/{metricName}.{outputFormat}") public javax.ws.rs.core.Response getMetricsData(@PathParam(value="metricName") String metricName, @PathParam(value="outputFormat") String outputFormat, @QueryParam(value="startDate") String startDate, @QueryParam(value="endDate") String endDate, @QueryParam(value="dateOffset") String dateOffset, @QueryParam(value="yAxisLabel") String yAxisLabel, @QueryParam(value="title") String title, @Context javax.ws.rs.core.UriInfo uriInfo) throws MetricsEndpointException
Note that the time range can be specified as either a start and end date (in RFC3339 format, i.e., YYYY-MM-DD'T'hh:mm:ssZ), or as an offset in seconds from the current time. These 2 time range mechanisms cannot be combined, e.g., you cannot specify an end date and an offset to be applied from that end date.
By default, the metric's name will be used for the y-axis label on the PNG graph, and the metric name and time range will be used for the graph's title. Both of these can be optionally specified with the yAxisLabel and title parameters. These 2 parameters do not apply for the other formats.
metricName
- Name of the metric being graphed, e.g., queryCountoutputFormat
- output format of the metric, e.g. csvstartDate
- Specifies the start of the time range of the search on the metric's data
(RFC-3339 - Date and Time format, i.e. YYYY-MM-DDTHH:mm:ssZ). Cannot be used with
dateOffset parameter.endDate
- Specifies the end of the time range of the search on the metric's data (RFC-3339
- Date and Time format, i.e. YYYY-MM-DDTHH:mm:ssZ). Cannot be used with dateOffset
parameter.dateOffset
- Specifies an offset, backwards from the current time, to search on the
modified time field for entries. Defined in seconds. Cannot be used with startDate and
endDate parameters.yAxisLabel
- (optional) the label to apply to the graph's y-axistitle
- (optional) the title to be applied to the graphuriInfo
- MetricsEndpointException
@GET @Path(value="/") @Produces(value="application/json") public javax.ws.rs.core.Response getMetricsList(@Context javax.ws.rs.core.UriInfo uriInfo)
uriInfo
- @GET @Path(value="/report.{outputFormat}") public javax.ws.rs.core.Response getMetricsReport(@PathParam(value="outputFormat") String outputFormat, @QueryParam(value="startDate") String startDate, @QueryParam(value="endDate") String endDate, @QueryParam(value="dateOffset") String dateOffset, @QueryParam(value="summaryInterval") String summaryInterval, @Context javax.ws.rs.core.UriInfo uriInfo) throws MetricsEndpointException
The XLS-formatted report will be one spreadsheet (workbook) with a worksheet per metric. The PPT-formatted report will be one PowerPoint slide deck with a slide per metric. Each slide will contain the metric's PNG graph.
If a summary interval is requested, the XSL report will instead contain a single table, with the summarized values for each interval and metric. Cannot be used with PPT format.
Note that the time range can be specified as either a start and end date (in RFC3339 format, i.e., YYYY-MM-DD'T'hh:mm:ssZ), or as an offset in seconds from the current time. These 2 time range mechanisms cannot be combined, e.g., you cannot specify an end date and an offset to be applied from that end date.
By default, the metric's name will be used for the y-axis label, and the metric name and time range will be used for the graph's title for the report in PPT format.
startDate
- Specifies the start of the time range of the search on the metric's data
(RFC-3339 - Date and Time format, i.e. YYYY-MM-DDTHH:mm:ssZ). Cannot be used with
dateOffset parameter.endDate
- Specifies the end of the time range of the search on the metric's data (RFC-3339
- Date and Time format, i.e. YYYY-MM-DDTHH:mm:ssZ). Cannot be used with dateOffset
parameter.dateOffset
- Specifies an offset, backwards from the current time, to search on the
modified time field for entries. Defined in seconds. Cannot be used with startDate or
endDate parameters.summaryInterval
- One of RrdMetricsRetriever.SUMMARY_INTERVALS
uriInfo
- MetricsEndpointException
protected long parseDate(String date)
date
- protected void generateMetricsUrls(Map<String,Map<String,Map<String,String>>> metrics, String metricsName, javax.ws.rs.core.UriInfo uriInfo)
The metric's URL info will be put in the metrics
Maps passed in to this method. The
structure of these nested Maps are: Map1<String1, Map2<String2, Map3<String3,String4>>>
(Numbers added to end of Map and String types so that each position could be referred to)
where:
metrics
- nested Maps that will be populated with the metric's URL infometricsName
- name of the metric to generate URLs foruriInfo
- used to extract the base URL and append the metric's path to itpublic void setMetricsMaxThreshold(double metricsMaxThreshold)
This work is licensed under a Creative Commons Attribution 4.0 International License.