• 0

Access Raw Data via API

Go to solution Solved by Sarah Terry,



I'm wanting to access the ping data of a device.  I've not found an example in the v1 API document that shows how to do this. I've tried the below but haven't found what I expect, i.e. a long list of ping + time + result.


$resourcePath = '/device/devices/465103/devicedatasources/376/data'

$epochseconds = Get-Date (Get-Date).ToUniversalTime() -UFormat %s

$fields =  '?start=' + $epochseconds

$url = 'https://' + $company + '.logicmonitor.com/santaba/rest' + $resourcePath + $fields




Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

I can see from 

$resourcePath = '/setting/datasources'
$fields = '?filter=displayName:Ping'

That the dataSourceId I am interested in is id = 21

                      "id":  21,
                      "description":  "",
                      "group":  "",
                      "appliesTo":  "isDevice()",
                      "technology":  "",
                      "tags":  "ping,network",
                      "name":  "Ping",
                      "displayName":  "Ping",
                      "version":  1515163055,
                      "auditVersion":  0,
                      "hasMultiInstances":  false,
                      "collectInterval":  60,
                      "collectMethod":  "ping",


But when I look at the machine I am interested in, I do not find that id attached, yet in the UI the Ping graph is being filled in.


Link to post
Share on other sites
  • 0
  • LogicMonitor Staff

@gwengrafana there is an example on this page that shows how to get raw data via the API: https://www.logicmonitor.com/support/rest-api-developers-guide/v1/data/get-data/

Getting data for Ping is the same as getting data for any other DataSource, so that example does apply. Your approach looks correct, but make sure you're using the correct Id - you need the deviceDataSource Id, *not* the DataSource Id. /settings/datasources endpoint will only return the Ids of the DataSources in your account, but what you want is the Id of the instantiated Ping DataSource for a given device. If you instead request /device/devices/ID/devicedatasources, you should see Ping in that list with the deviceDataSource id, which can be used in the get data request.

Link to post
Share on other sites
  • 0

Thanks, $resourcePath = '/device/devices/465103/devicedatasources' gives me

                      "id":  8252658,
                      "deviceId":  465103,
                      "dataSourceId":  376,


$resourcePath = '/device/devices/465103/devicedatasources'

$fields = '?filter=dataSourceId:376'

Gives me a slimdowned version of the results. But I am failing to understand deviceDataSourceId as 

$resourcePath =  '/device/devices/465103/devicedatasources/376/instances


$resourcePath =  '/device/devices/465103/devicedatasources/8252658/instances

returns nothing. 



Link to post
Share on other sites
  • 0

Ak okay, so data rather than instances. Thank you, this gives with some data back although seems to have no values but I guess that may be a different issue.


    "dataSourceName":  "PingMulti",
    "dataPoints":  [
    "instances":  {


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.