RPC API Developer's Guide

RPC API: Get Data

Note that LogicMonitor does have an available REST API equivalent for this API call.

The LogicMonitor API allows users to download the historical data of a datasource applied to a device.  With the getData RPC API call you can get data for a specific datasource or datasource instance.

Notes:

 

getData

Retrieve data for a device-datasource or a specific device-datasource instance

URL:
curl "https://accountName.logicmonitor.com/santaba/rpc/getData?c=accountName&u=user&p=password&host=displayName&[dataSourceInstance|dataSource]=entityName&period=timePeriod&start=startTime&end=endTime&dataPoint0=datapointName&dataPoint1=datapointName"
 

Request Parameters: You can include the following as query parameters in getData requests:

Parameter

Type

Description

host String Required. The display name of the host.
dataSourceInstance String Required if dataSource is not specified. The unique name of the DataSource Instance for which you want to receive data.
dataSource String Required if dataSourceInstance is not specified. The unique name of the DataSource for which you want to receive data.

Note: Data will be returned for each DataSource Instance associated with the DataSource.

period String Optional. The time period for which you want to receive data. Valid inputs include nhours, ndays, nweeks, nmonths, or nyears (e.g. 2hours).

Note: The start,end parameter takes precedence over this value when both are specified. If you do not specify a period value or start,end values, a single data value will be returned corresponding to the current time, unless the host is unreachable. If the host that you are attempting to retrieve data from is unreachable and there is no data for the current time, you will receive an error unless you specify one of a period value and start/end values.

start, end Long Optional. The start and end times between which you want to receive data, in epoch seconds format. Both a start time and an end time must be specified.

Note: This parameter takes precedence over the period parameter when both are specified. If you do not specify a period value or start,end values, a single data value will be returned corresponding to the current time, unless the host is unreachable. If the host that you are attempting to retrieve data from is unreachable and there is no data for the current time, you will receive an error unless you specify one of a period value and start/end values.

dataPoint{0-n} String Optional. The unique name(s) of the datapoint(s) for which you want to receive data.

Note: If this parameter is not specified and a dataSourceInstance is specified, data for all datapoints for the specified dataSourceInstance will be returned. If this parameter is not specified and a dataSource is specified, data for all datapoints for each dataSourceInstance of the specified dataSource will be returned.

graphId Integer Optional. The unique Id of the datasource instance graph to get data from. Data corresponding to the graph lines will be returned.

Note: This parameter takes precedence over any dataPoints specified if the graph lines do not represent the specified dataPoints.

To get a graphId in the UI: navigate to the graph, & select graph definition from the drop down menu - the id is in the URL. In the new UI it is displayed in the URL as g:##. In the old UI it is displayed in the URL as gId:##.

graph String Optional. The unique name of the datasource instance graph to get data from. This value is interchangeable with the graphId. Data corresponding to the graph lines will be returned.

Note: This parameter takes precedence over any dataPoints specified if the graph lines do not represent the specified dataPoints.

aggregate String Optional. average | min | max | last
The operation that should be applied to the data.
overviewGraph String Optional. The name of the overview graph to get data from. The dataSource corresponding to the overview graph must be specified.

 

All outputs will be in the format: { [status], [data], [errmsg] }, where status is the status of the response, errmsg is the error message associated with the response, and the data object includes the following:

Value

Description

values This JSON object contains an object for each datasource instance that data is returned for. Each datasource instance object contains multiple data objects, one for each data timestamp
datapoints This JSON object contains the names of the datapoints for which data is included in the values object

 

Example 1

The following request returns the most recent value of each datapoint for the only instance of the CPU datasource on device 172.31.36.150:

Request:
 curl "https://apiAccount.logicmonitor.com/santaba/rpc/getData?c=apiAccount&u=apiUser&p=example&host=172.31.36.150&dataSource=NetSNMPCPUwithCores"
  Response:{ "status": 200, "data": { "values": {"NetSNMPCPUwithCores-Core Count: 1": [[ 1447712880, "2015-11-16 14:28:00 PST", 0.010000000000000002, 1, 0.11755223990195032, 99.12999999999998, 0.02416666666666667, 0.0575, 0.035, 0.05, 0, 0.010000000000000002 ]]}, "tzoffset": -28800000, "dataPoints": [ "5MinLoadPerCore", "cores", "CPUBusyPercent", "CpuRawIdle", "CpuRawSystem", "CpuRawUser", "CpuRawWait", "LoadAverage15min", "LoadAverage1min", "LoadAverage5min" ] }, "errmsg": "OK" }  

Example 2

The following request returns the values of the CPUBusyPercent and CpuRawIdle datapoints for the only instance of the CPU datasource on device 172.31.36.150 for the past hour:

Request:
curl "https://apiAccount.logicmonitor.com/santaba/rpc/getData?c=apiAccount&u=ApiUser&p=example&host=172.31.36.150&dataSource=NetSNMPCPUwithCores&dataPoint0=CPUBusypercent&dataPoint1=CpuRawIdle&start=1447707600&end=1447711200"
  Response:
{
  "status": 200,
  "data": {
    "values": {"NetSNMPCPUwithCores-Core Count: 1": [
      [
        1447707573,
        "2015-11-16 12:59:33 PST",
        0.13,
        99.08
      ],
      [
        1447707633,
        "2015-11-16 13:00:33 PST",
        0.13,
        99.08
      ],
      [
        1447707693,
        "2015-11-16 13:01:33 PST",
        0.18,
        99.05
      ],
      [
        1447707753,
        "2015-11-16 13:02:33 PST",
        0.06,
        99.12
      ],.........
      ...........
      ...........
      [
        1447711113,
        "2015-11-16 13:58:33 PST",
        0.18,
        99.03
      ],
      [
        1447711173,
        "2015-11-16 13:59:33 PST",
        0.12,
        99.13
      ],
      [
        1447711233,
        "2015-11-16 14:00:33 PST",
        0.12,
        99.13
      ]
    ]},
    "tzoffset": -28800000,
    "dataPoints": [
      "CPUBusyPercent",
      "CpuRawIdle"
    ]
  },
  "errmsg": "OK"
}