PingDirectory

Google Chart Tools Datasource protocol

Google’s Chart Tools Datasource protocol can present metrics data.

The Google Visualization API query language (the tq request parameter) is not supported. The PingDataMetrics server supports JSON, HTML, CSV, and TSV data formats as outlined by the Datasource protocol.

URL

/api/v1/metrics/{metricId}/datatable

Method

GET

Formats

JSON, HTML, CSV, and TSV

Query Parameters

tqx=out:html

HTML formatted output

tqx=out:csv

CSV formatted output

tqx=out:tsv-excel

TSV formatted output

tz

Specifies the timezone to be used when displaying dates. The Google Visualization API assumes that the times returned are in local time. The PingDataMetrics server stores and returns all timestamps in GMT. This parameter specifies how the PingDataMetrics server presents the time. Usually, the client will pass the user’s local timezone in IANA Time Zone Database format, such as "US/Central."

All Common query parameters apply to this resource.

Example

The following example gets the average response time metric for the last 5 minutes with 30 second (5 * 60 / 10) resolution and pivoted by op-type and then instance in CSV format:

curl \
  -X GET \
  https://<metricsServerHost>:8080/api/v1/metrics/response-time/datatable?
tqx=out:csv&maxIntervals=10
  &pivot=op-type&pivot=instance&tz=US/Central

Response Code

200 0K

Response Body

When only one time interval is requested, the first pivoted dimension values form the first column. For queries that request more than one time interval, the start of each time interval forms the first column. Combinations of subsequent pivoted dimension values and/or histogram buckets are included as additional columns. All date and time values are under the GMT time zone.

"Time","server35 AVERAGE Milliseconds","server3 AVERAGE Milliseconds"
"2012-08-04T14:38:00Z","0","0"
"2012-08-04T14:39:00Z","0","0"
"2012-08-04T14:40:00Z","0","0"
"2012-08-04T14:41:00Z","0","0"
"2012-08-04T14:42:00Z","0","0"

Example

The following sample illustrates using Google chart tools.

<html>
  <head>
    <!--Load the AJAX API-->
    <script type="text/javascript"
src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">

    // Load the Visualization API and the line chart package.
  google.load('visualization', '1.0', {'packages':['corechart']});
    // Set a callback to run when the Google Visualization API is loaded.
  google.setOnLoadCallback(drawChart);

function drawChart() {
    var query = new google.visualization.Query
      ('https://<MetricsHost>:8080/
      api/v1/metrics/response-time/datatable?maxIntervals=10
      &pivot=optype&pivot=instance');
    query.send(handleQueryResponse);
   }
  function handleQueryResponse(response) {
    if (response.isError()) {
      alert('Error in query: ' + response.getMessage() + ' '
        + response.getDetailedMessage());
      return;
   }
  var data = response.getDataTable();

  var visualization = new
  google.visualization.LineChart(document.getElementById('chart_div'));
    visualization.draw(data, null);
   }
  </script>
 </head>
 <body>
  <!--Div that will hold the chart-->
  <div id="chart_div"></div>
  </body>
</html>