Northbound metering REST API examples

Applications

Sample request 

Get all applications with persisted metering data currently on disk:

GET /sdn/v2.0/metrics/apps

Sample response 

 {
   "apps":[
      {
         "app_id":"com.hp.sdn.cloud",
         "app_name":"HP VAN SDN Cloud Controller"
      },
      {
         "app_id":"com.hp.sdn",
         "app_name":"HP VAN SDN Controller"
      }
   ]
}

Metrics

Sample request 

Get all metrics registered by an application:

GET /sdn/v2.0/metrics/apps/{app_id}

parameters:

  • app_id ... mandatory; if none specified, returns errors

  • name ... optional; if none specified, returns all metrics

  • primary_tag... optional; if none specified, the wild card is considered, if specified returns only the metrics with the specified primary tag

  • secondary_tag... optional; If none is specified, the wild card is considered ,if specified returns only the metrics with the specified secondary tag

Sample response 

{
   "metrics":[
      {
         "name":"Metric A",
         "type":"COUNTER",
         "uid":"65f1a180-ab5e-4b41-8c9f-b1597a4d1200",
         "primary_tag":"computenode1",
         "secondary_tag":"router1",
         "primary_tag":"router1",
         "secondary_tag":"port1",
         "jmx":true,
         "persistence":true,
         "summary_interval":"ONE"
      },
      {
         "name":"Metric B",
         "type":"ROLLING_COUNTER",
         "uid":"65f1a180-ab5e-4b41-8c9f-b1597a4d1201",
         "primary_tag":"computenode2",
         "secondary_tag":"router1",
         "description":"My second metric.",
         "jmx":true,
         "persistence":true,
         "summary_interval":"FIVE"
      },
      {
         "name":"Metric C",
         "type":"GAUGE",
         "uid":"65f1a180-ab5e-4b41-8c9f-b1597a4d1202",
         "primary_tag":"computenode2",
         "secondary_tag":"router2",
         "description":"My third metric.",
         "jmx":true,
         "persistence":true,
         "summary_interval":"FIFTEEN"
      },
      {
         "name":"Metric D",
         "type":"RATIO_GAUGE",
         "uid":"65f1a180-ab5e-4b41-8c9f-b1597a4d1203",
         "primary_tag":"computenode1",
         "secondary_tag":"router3",
         "description":"My fourth metric.",
         "jmx":true,
         "persistence":true,
         "summary_interval":"ONE"
      },
      {
         "name":"Interpacket arrival times",
         "type":"HISTOGRAM",
         "uid":"65f1a180-ab5e-4b41-8c9f-b1597a4d1204",
         "primary_tag":"computenode2",
         "secondary_tag":"router3",
         "description":"My fifth metric.",
         "jmx":true,
         "persistence":true,
         "summary_interval":"ONE"
      },
      {
         "name":"metric F",
         "type":"METER",
         "uid":"65f1a180-ab5e-4b41-8c9f-b1597a4d1205",
         "primary_tag":"computenode2",
         "secondary_tag":"router4",
         "description":"My sixth metric.",
         "jmx":true,
         "persistence":true,
         "summary_interval":"ONE"
      },
      {
         "name":"Packet processing throughput",
         "type":"TIMER",
         "uid":"65f1a180-ab5e-4b41-8c9f-b1597a4d1204",
         "primary_tag":"computenode1",
         "secondary_tag":"router4",
         "description":"My seventh metric.",
         "jmx":false,
         "persistence":false,
         "summary_interval":"ONE"
      }
   ]
}

Metric details

Sample request 

Get specific metric registered by an application:

GET /sdn/v2.0/metrics/{uid}

Sample response 

{
   "metric":{
      "app_id":"com.hp.sdn",
      "name":"Metric A",
      "type":"COUNTER",
      "uid":"65f1a180-ab5e-4b41-8c9f-b1597a4d1200",
      "primary_tag":"65f1a180-ab5e-4b41-8c9f-b1597a4d1d7a",
      "description":"My first metric.",
      "summary_interval":"ONE",
      "jmx":"true",
      "persistence":"true"
   }
}

Metric values

Sample request 

Get the values of a metric registered by an application:

GET /sdn/v2.0/metrics/{uid}/values

parameters:

  • start ... The start date of a requested time period in format YYYY-MM-dd-hh:mm, optional; if both the start and the end are not specified, the the last recording of the metric value will be reported. If no value is specified for the start parameter but an end time is specified, the start will be date of the first instance of the metric within age_out time

  • end ... The end date of a requested time period in format YYYY-MM-dd-hh:mm, optional; if empty, the end will be the date of the REST call.

  • interval ... The time period to summarize the data, optional without both start and end but required if either or both specified; The intervals supported are: 1, 5, 15, 30, 60, "day", "all". The intervals are defined as the number of minutes, where "day" is 24 hours and "all" is the summarized value over the lifetime of the metric data.

Sample response 

{
   "metric_values":{
      "type":"COUNTER",
      "uid":"95ac45f3-75d2-49ff-a815-d6b780dc4e98",
      "datapoint_count":1,
      "datapoints":[
         {
            "count":"43",
            "milliseconds_span":"58",
            "update_time":"Mon Aug 19 15:02:41 PDT 2013"
         }
      ]
   }
}

Metric Primary values

Sample request 

Get the primary values of metrics registered by an application:

GET /sdn/v2.0/metrics apps/{app_id}/primaries

Sample response 

{
   "primaries":[
      "router1",
      "router2"
   ]
}

Metric Secondary values

Sample request 

Get the secondary values of metrics registered by an application:

GET /sdn/v2.0/metrics apps/{app_id}/secondaries

Sample response 

{
   "secondaries":[
      "port1",
      "port2"
   ]
}

Metric Names

Sample request 

Get the metric names of metrics registered by an application:

GET /sdn/v2.0/metrics apps/{app_id}/names

Sample response 

{
   "names":[
      "rc_30000",
      "rc_30001",
      "rc_40001",
      "rc_40000"
   ]
}