Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Add opCharts TopN API

...

A cookie is created and sent with the response.  This must be saved and passed with all requests below.  

TopN

TopN data is created after every NMIS collect cycle and represents the top users of each resource type.  By default there are 6 topn documents created: cpuLoad, 

GET topn (fetch list of topn documents)

GET /omk/opCharts/topn/

Retrieves the topn documents available to opCharts.  No parameters are accepted.

Successful Response

Returns an array of hashes containing the id's of the TopN documents along with the url they can be accessed from. 

Code Block
[
  {
    "url": "/omk/opCharts/topn/cpuLoad",
    "topn_id": "cpuLoad"
  },
  {
    "url": "/omk/opCharts/topn/ifInErrorRates",
    "topn_id": "ifInErrorRates"
  },
  {
    "url": "/omk/opCharts/topn/ifOutDiscardRates",
    "topn_id": "ifOutDiscardRates"
  },
  {
    "url": "/omk/opCharts/topn/ifOutUtil",
    "topn_id": "ifOutUtil"
  },
  {
    "url": "/omk/opCharts/topn/ifInUtil",
    "topn_id": "ifInUtil"
  },
  {
    "url": "/omk/opCharts/topn/MemoryUsed",
    "topn_id": "MemoryUsed"
  }
]

GET topn document (fetch TopN document)

GET /omk/opCharts/topn/[topn_id][?count=X]

Retrieves the topn document.  Parameter topn_id is required and specifies the type of topn document to retrieve (which is generally a Resource). Also takes a query parameter named count which will limit the results to TopX.

Successful Response

Returns an array of hashes, each hash holds the current value of the resource, the last 12 data points (1h of 5 min data) of the resource along with various other info about the specific resource.  The array is in order from #1 topn user to #N topn resource. 

Code Block
[
  {
    "chart": "resource_id",
    "display_suffix": "",
    "value": 32.02,
    "data": [
      16.2295279333333,
      58.91759035,
      35.2548943,
      12.14511871,
      34.8192241666667,
      22.7064218466667,
      24.85018748,
      48.7659871666667,
      28.0707958966667,
      11.7892433066667,
      38.6264594666667,
      32.42676128
    ],
    "node": "cupid",
    "element": "cpuLoad",
    "index": "0",
    "resource_id": "systemStats",
    "property": "ssCpuRawIdle"
  },
  {
    "chart": "resource_id",
    "display_suffix": "%",
    "value": "13.02",
    "data": [
      12.04003358,
      10.0483504933333,
      10,
      10,
      10,
      10,
      12.87057157,
      13,
      13,
      13.9743139933333,
      14,
      11.07988942
    ],
    "node": "meatball",
    "element": "cpuLoad",
    "index": "0",
    "resource_id": "nodehealth",
    "property": "cpu"
  },
<snip>
]

Nodes

Nodes are gathered from the NMIS installation on the existing server.  Each node has a list of resources.  Each resource can either be indexed or non-indexed.  If non-indexed each resource contains a list of datasets (which are individual data points over time, eg. avgbusy5).  If indexed, the resource contains an array, each element in that array contains datasets.

...

Retrieves the nodes available to opCharts.  No parameters are accepted.

Successful Response

Returns an array of strings containing the node names 

...

Retrieves all resources for the specified node.  A resource is required when requesting specific datasets or indexed datasets.

Successful Response

Returns an array of resource objects. Each resource object has a value it can be identified by(which can be used in later requests) and a url that the resource value can be appended to in order to fetch information about this resource and it's name which can be displayed to users.

...

Retrieves all datasets for the specified node & resource.

Successful Response

An array of dataset objects. Each dataset object lists it's resource, the value it can be identified by, a url that the value can be appended to (if not ending in .json), tokens used for searching and it's name which can be used for displaying to users.

...

Retrieve all indexes available from a resource.  This is only required if the dataset you wish to load is indexed.

Successful Response

Returns a hash, with the name of the resource.  A datum array of index objects, these hold the data you are likely looking for.  The value attribute holds the identifier for this object.  Name is the attribute which can be displayed to users.  The "active" property tells you if this index is being collected.

...

Code Block
{
  "requestData": {
    "model": "nmis_rrd",
    "model_view": "graph",
    "data_source": "local_nmis",
    "parameters": {      
      "start_date_raw": 1401346748,
      "end_date_raw": 1401951548,
      "node": "asgard",
      "graph_type": "nodehealth",
      "field": "avgBusy5",
      "resource_index": "",      
      "index_graph_type": "",
      "axis": "0"      
    },
    "options": {      
    }   
  }
}

Successful Response

A successful response will be a hash with 2 objects.  The requestObject that was submitted along with a responseObject : 

...