Run a Report

Last updated on 26 February, 2021

With LogicMonitor’s REST API you can programmatically run a report & query existing report execution tasks for large reports.

Note: As with all of our API calls, authentication is required.

Run a Report

HTTP Method:POST

URI: /functions

Request Parameters:

Property

Description

Required?

Type

Example

type This value needs to be generateReport Yes String “type”:”generateReport”
reportId The Id of the report you’d like to run Yes Integer “reportId”:27
receiveEmails A comma separated list of email addresses that should be notified once the report has been generated. A link to the report will be included in the notification email, but not in the API response if this query parameter is specificed. No String “receiveEmails”:”[email protected]

Example Request

The following Python script will run the report with id 27 in the api.logicmonitor.com account.

#!/bin/env python

import requests
import json
import hashlib
import base64
import time
import hmac

#Account Info
AccessId ='YQQ75w6Mxx9zWIeAMq5H'
AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8'
Company = 'api'

#Request Info
httpVerb ='POST'
resourcePath = '/functions'
data = '{"type":"generateReport","reportId":27}'

#Construct URL 
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath 

#Get current time in milliseconds
epoch = str(int(time.time() * 1000))

#Concatenate Request details
requestVars = httpVerb + epoch + data + resourcePath

#Construct signature
hmac1 = hmac.new(AccessKey.encode(),msg=requestVars.encode(),digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(hmac1.encode())

#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}

#Make request
response = requests.post(url, data=data, headers=headers)

#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Python 3

Get a URL for an existing Report execution task

HTTP Method:GET

URI: /report/reports/REPORT_ID/tasks/TASK_ID

Where REPORT_ID is the id of the report, and TASK_ID is the id of the task you’re wanting to get a report URL for (returned when you run the report).

Example Request

The following Python script will request the URL for task 6041259673900733970 for report 1 in the api.logicmonitor.com account.

#!/bin/env python

import requests
import json
import hashlib
import base64
import time
import hmac

#Account Info
AccessId ='YQQ75w6Mxx9zWIeAMq5H'
AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8'
Company = 'api'

#Request Info
httpVerb ='GET'
resourcePath = '/report/reports/1/tasks/6041259673900733970'
queryParams = ''
data=''

#Construct URL 
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath + queryParams

#Get current time in milliseconds
epoch = str(int(time.time() * 1000))

#Concatenate Request details
requestVars = httpVerb + epoch + data + resourcePath

#Construct signature
hmac1 = hmac.new(AccessKey.encode(),msg=requestVars.encode(),digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(hmac1.encode())

#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}

#Make request
response = requests.get(url, data=data, headers=headers)

#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Python 3
In This Article