Add a Report

Last updated on 29 June, 2022

With LogicMonitor’s REST API you can programmatically add a new report definition to your LogicMonitor account.  If you are looking for information on how to run a report, see this page instead.

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

Note that the following report types are not being released now, but are expected to be released in the next release or two:

  • Audit Log Report
  • Alert Forecasting Report

HTTP Method: POST

URI: /report/reports

You may POST the following parameters in your request:

Property

Description

Required?

Type

Example

name The name of the report Yes String “name”:”Collector Task Trends”
description The report description No String “description”:”My Report Description”
type Alert | Alert SLA | Alert trends | Alert threshold | Host inventory | Host metric trends | Host CPU | Interface Bandwidth | Website Service Overview | Service Level Agreement | Netflow device metric Yes String “type”:”Host metric trends”
groupId The Id of the group the report is in, where Id=0 is the root report group No. Defaults to 0. Integer “groupId”:0
format HTML | PDF | CSV. The format of the report No. Defaults to HTML. String “format”:”HTML”
delivery none | email. Whether or not the report is configured to be delivered via email No. Defaults to “none” String “delivery”:”email”
recipients If the report is configured to be delivered via email, this object provides the recipients that the report will be delivered to. Each recipient needs to include:

  • type: options are admin | arbitrary, where admin refers to a user in the account and arbitrary refers to an email address not associated with a user account
  • method: this should always be email
  • addr: this should be a username if type=admin, or an email address if type=arbitrary
  • comment: any comments that should be delivered with the report
Only if delivery=email JSON Object “recipients”:[{“type”:”admin”,”method”:”email”,”addr”:”sarah”,”comment”:””},{“type”:”admin”,”method”:”email”,”addr”:”Bill”,”comment”:””},{“type”:”arbitrary”,”method”:”email”,”addr”:”[email protected]”,”comment”:””}]
schedule A cron schedule that indicates when the report will be delivered via email. Only if delivery=email String “schedule”:”45 9 * * *”

Alerts Report Parameters

You must additionally POST the following parameters for all reports of type Alert:

Property

Description

Required?

Type

Example

dateRange The Time Range configured for the report. Options include: Last 2 hours | Last 24 hours | Last calendar day | Last 7 days | Last 14 days | Last 30 days | Last calendar month | Last 365 days | Any custom date range in this format: YYYY-MM-dd hh:mm TO YYYY-MM-dd hh:mm No. Defaults to Last 2 hours. String “dateRange”:”Last 24 hours”
groupFullPath The group filter used to determine which alerts will appear in the report. Glob expressions supported. No. Defaults to all groups. String “groupFullPath”:”*”
deviceDisplayName The device filter used to determine which alerts will appear in the report. Glob expressions supported. No. Defaults to all devices. String “deviceDisplayName”:”*”
dataSourceInstanceName The instance filter used to determine which alerts will appear in the report. Glob expressions supported. No. Defaults to all instances. String “dataSourceInstanceName”:”*”
dataPoint The group filter used to determine which alerts will appear in the report. Glob expression supported. No. Defaults to all dataPoints. String “dataPoint”:”*”
level all | error | critical

  • all: alerts of all severity levels will be displayed if they match the filter criteria
  • error: only error and critical alerts that match the filter criteria will be displayed
  • critical: only critical alerts that match the filter criteria will be displayed
No. Defaults to all. String “level”:”all”
sortedBy count | host | dataPoint | level | startOn | ackedOn. How displayed alerts will be sorted in the report. Note that if summaryOnly is set to true, you are limited to sortedBy= count | host | dataPoint. If summaryOnly is set to false, you cannot set sortedBy = count. No. Defaults to host. String “sortedBy”:”count”
includePreexist
  • true: alerts that started prior to the specified dateRange but that meet all other criteria will be displayed in the report
  • false: only alerts that started during the specified dateRange will be displayed in the report
No. Defaults to true. Boolean “includePreexist”:false
activeOnly
  • true: only alerts that are still alerting (i.e. haven’t yet cleared) will be displayed in the report
  • false: active alerts and cleared alerts will both be displayed in the report
No. Defaults to false. Boolean “activeOnly”:false
summaryOnly
  • true: a column will be added to the report detailing the number of times each alert occurred
  • false: the number of times each alert occurred will not be displayed in the report
No. Defaults to false. Boolean “summaryOnly”:true
ackFilter all | acked | nonacked

  • all: both acknowledged and non-acknowledged alerts that meet the report criteria will be displayed
  • acked: only acknowledged alerts that meet the report criteria will be displayed
  • nonacked: only non-acknowledged alerts that meet the report criteria will be displayed
No. Defaults to all. String “ackFilter”:”all”
sdtFilter all | sdt | nonsdt

  • all: alerts that are in SDT and that aren’t in SDT that meet the report criteria will be displayed
  • sdt: only alerts that are in SDT and that meet the report criteria will be displayed
  • nonsdt: only alerts that aren’t in SDT and that meet the report criteria will be displayed
No. Defaults to all. String “sdtFilter”:”all”
timing overlap | start – Any alerts active during the specified dateRange will be displayed in the report if time=overlap. If time=start, only alerts that started during the specified dateRange will be displayed in the report. No. Defaults to “overlap”. String “timing”:”overlap”
dataSource All alerts displayed in the report must have been triggered for the Datasources specified in this filter. No. Defaults to all. String “dataSource”:”*”
rule All alerts displayed in the report must have been routed to the Rules specified in this filter. No. Defaults to all. String “rule”:”*”
chain All alerts displayed in the report must have been routed to the Escalation Chains specified in this filter. No. Defaults to all. String “chain”:”*”
columns The columns that will be displayed in the report. You should specify the columns in the order in which you’d like them to be displayed. All column names need to be included in this object, but each column should have an associated isHidden field that indicates whether it is displayed or not. NOTE that if summaryOnly is set to true you can only include these columns:

  • Alerts
  • Group
  • Device
  • Instance
  • Datapoint

If summaryOnly is set to false you can include these columns:

  • Severity
  • Group
  • Device
  • Instance
  • Datapoint
  • Thresholds
  • Value
  • Began
  • End
  • Rule
  • Chain
  • Acked
  • Acked By
  • Acked On
  • Notes
  • In SDT
No. Defaults to all displayed. JSON Object “columns”:[{“name”:”Severity”,”isHidden”:false},{“name”:”Group”,”isHidden”:false},{“name”:”Device”,”isHidden”:false},{“name”:”Instance”,”isHidden”:false},{“name”:”Datapoint”,”isHidden”:false},{“name”:”Thresholds”,”isHidden”:false},{“name”:”Value”,”isHidden”:false},{“name”:”Began”,”isHidden”:false},{“name”:”End”,”isHidden”:false},{“name”:”Rule”,”isHidden”:false},{“name”:”Chain”,”isHidden”:false},{“name”:”Acked”,”isHidden”:false},{“name”:”Acked By”,”isHidden”:false},{“name”:”Acked On”,”isHidden”:false},{“name”:”Notes”,”isHidden”:false},{“name”:”In SDT”,”isHidden”:false}]

Alert SLA Report Parameters

You must additionally POST the following parameters for all reports of type Alert SLA:

Property

Description

Required?

Type

Example

dateRange The Time Range configured for the report: Last 2 hours | Last 24 hours | Last calendar day | Last 7 days | Last 14 days | Last 30 days | Last calendar month | Last 365 days | Any custom date range in this format: YYYY-MM-dd hh:mm TO YYYY-MM-dd hh:mm No. Defaults to Last 2 hours. String “dateRange”:”Last 14 days”
hostsVal The devices OR groups (use full path) selected for the report, where multiple entities are separated by commas. Note that glob is supported. Yes String “hostsVal”:”Production/Server,AWS”
hostsValType host | group. The type of entities specified in the hostsVal field. Yes String “hostsValType”:”host”
dataSource The datasource instance selected for the report, in the format DatasourceName-InstanceName (If it is a single instance datasource you can just leave it at DatasourceName) Yes String “dataSource”:”HTTP_Page-C:”
dataPoint The datapoints selected for the report, where multiple datapoints are separated by commas No. Defaults to all. String “dataPoint”:”ResponseTime,Status”
alertLevel Warn | Error | Critical. The minimum severity of the alert statuses you’d like to evaluate for the specified devices and device groups. No. Defaults to warn String “alertLevel”:”Warn”
alertRule The name of the Alert Rule that the datapoint alert you’re evaluating will be routed to. Note that if you do not select the correct alert rule, no matching alerts will be displayed No. String “alertRule”:”Prod Server Error/Critical”

Alert Threshold Report Parameters

You must additionally POST the following parameters for all reports of type Alert threshold:

Property

Description

Required?

Type

Example

groupFullPath The full path of the group whose member devices you are going to include in the report. Glob expressions supported. No. Defaults to all. String “groupFullPath”:”Production/Servers”
deviceDisplayName The display name of the device(s) to be included in the report. Glob expressions supported. No. Defaults to all. String “deviceDisplayName”:”ip-172-31-33-214.us-west-2.compute.internal”
dataSourceInstanceName The name of the datasource instance to be included in the report, where the syntax should be dataSourceDisplayName-InstanceName. If you’re referencing a single instance datasource, you can just specify dataSourceDisplayName. Glob expressions supported. No. Defaults to all. String “dataSourceInstanceName”:”*”
dataPoint The datapoint to be included in the report. Glob expressions supported. No. Defaults to all. String “dataPoint”:”*”
sortedBy host | datasource | datapoint

  • host: displayed thresholds will be sorted by device
  • datasource: displayed thresholds will be sorted by datasource instance
  • datapoint: displayed thresholds will be sorted by datapoint (metric)
No. Defaults to host. String “sortedBy” : “datasource”
excludeGlobal
  • true: only variations from the global thresholds will be displayed
  • false: all thresholds will be displayed, including global thresholds an custom group and instance level thresholds
No. Defaults to true. Boolean “excludeGlobal”:true

Alert Trends Report Parameters

You must additionally POST the following parameters for all reports of type Alert trends:

Property

Description

Required?

Type

Example

dateRange The Time Range configured for the report: Last 2 hours | Last 24 hours | Last calendar day | Last 7 days | Last 14 days | Last 30 days | Last calendar month | Last 365 days | Any custom date range in this format: YYYY-MM-dd hh:mm TO YYYY-MM-dd hh:mm No. Defaults to Last 2 hours. String “dateRange”:”Last 7 days”
metrics The devices and groups that will be included in the report, where each device/group should be represented with two fields: itemType and itemVal. Glob is supported. Yes JSON Object “metrics”:[{“itemType”:”host”,”itemVal”:”ip-172-31-33-214.us-west-2.compute.internal”},{“itemType”:”group”,”itemVal”:”Website”},{“itemType”:”host”,”itemVal”:”ip-172-31-37-162.us-west-2.compute.interal”}]

Device Inventory Report Parameters

You must additionally POST the following parameters for all reports of type Host inventory:

Property

Description

Required?

Type

Example

hostsVal The devices OR groups (full path) selected for the report, where multiple entities are separated by commas Yes String “hostsVal”:”AWS/EC2″
hostsValType host | group. The type of entities specified in the hostsVal field. Yes String “hostsValType”:”group”
sortedBy Specify a property that is included in the ‘properties’ list that should be used to sort the devices/groups displayed in the report Yes String “sortedBy”:”system.aws.publicIpAddress”
properties The properties that should be displayed in the report Yes JSON Object “properties”:[“system.aws.publicIpAddress”,”system.aws.resourceid”,”system.aws.region”,”system.aws.stateName”]

Device Metric Report Parameters

You must additionally POST the following parameters for all reports of type Host metric trends:

Property

Description

Required?

Type

Example

dateRange The Time Range configured for the report: Last 2 hours | Last 24 hours | Last calendar day | Last 7 days | Last 14 days | Last 30 days | Last calendar month | Last 365 days | Any custom date range in this format: YYYY-MM-dd hh:mm TO YYYY-MM-dd hh:mm No. Defaults to Last 24 hours. String “dateRange”:”Last 14 days”
hostsVal The name of the devices OR groups selected for the report, where multiple entities are separated by commas. Glob expressions are supported. Yes String “hostsVal”:”ip-172-31-33-214.us-west-2.compute.internal,ip-172-31-37-162.us-west-2.compute.interal”
hostsValType host | group. The type of entities specified in the hostsVal field. Yes String “hostsValType”:”host”
sortedBy host | instance | metric

  • host: Information displayed in the report will be sorted by device
  • instance: Information displayed in the report will be sorted by instance
  • metric: Information displayed in the report will be sorted by datapoint (metric)
No. Defaults to host. String “sortedBy”:”host”
rowFormat 0 | 1 | 2 | 3

  • 0: Text only – metrics will be displayed in a tabular format.
  • 1: One graph per device – metrics will be displayed in a tabular format and one graph will be displayed per device.
  • 2: One graph per instance – metrics will be displayed in a tabular format and one graph will be displayed per instance.
  • 3: One graph per datapoint – metrics will be displayed in a tabular format and one graph will be displayed per datapoint.
No. Defaults to 0. Integer “rowFormat”:1
limitedNum 0 | 10

  • 0: Metrics will be displayed for all selected devices or groups
  • 10: Metrics will only be displayed for the top ten device or groups
No. Defaults to 0. Integer “limitedNum”:0
metrics The datapoint that will be included in the report, where each datapoint is specified by three fields: dataSourceFullName (no glob), instances (glob is okay) and metric (not glob) Yes JSON Object “metrics”:[{“dataSourceFullName”:”Data Collecting Task (Collector Data Collecting Task)”,”instances”:”script”,”metric”:”SuccessExecuteTime”}]
columns The columns that will be displayed in the report. You should specify the columns in the order in which you’d like them to be displayed. All column names need to be included in this object, but each column should have an associated isHidden field that indicates whether it is displayed or not. No. Defaults to displaying all columns. JSON Object “columns”:[{“name”:”Device”,”isHidden”:true},{“name”:”Instance”,”isHidden”:false},{“name”:”Datapoint”,”isHidden”:false},{“name”:”Start”,”isHidden”:true},{“name”:”End”,”isHidden”:true},{“name”:”Min”,”isHidden”:false},{“name”:”Max”,”isHidden”:false},{“name”:”Average”,”isHidden”:false},{“name”:”Change(%)”,”isHidden”:false}]

Interface Bandwidth Report Parameters

You must additionally POST the following parameters for all reports of type Interfaces Bandwidth:

Property

Description

Required?

Type

Example

dateRange The Time Range configured for the report. Last 2 hours | Last 24 hours | Last calendar day | Last 7 days | Last 14 days | Last 30 days | Last calendar month | Last 365 days | Any custom date range in this format: YYYY-MM-dd hh:mm TO YYYY-MM-dd hh:mm No. Defaults to Last 2 hours. String “dateRange”:”Last 14 days”
hostsVal The devices OR groups selected for the report, where multiple entities are separated by commas Yes String “hostsVal”:”ip-172-31-33-214.us-west-2.compute.internal,ip-172-31-37-162.us-west-2.compute.interal”
hostsValType host | group. The type of entities specified in the hostsVal field. Yes String “hostsValType”:”host”
rowFormat 0 | 1

  • 0: Text only – metrics will be displayed in a tabular format.
  • 1: One graph per instance – metrics will be displayed in a tabular format and one graph will be displayed per instance.
No. Defaults to 0. Integer “rowFormat”:1

Netflow Report Parameters

You must additionally POST the following parameters for all reports of type Netflow device metric:

Property

Description

Required?

Type

Example

hostsVal The devices OR groups (full path) selected for the report, where multiple entities are separated by commas. Glob is accepted. Yes String “hostsVal”:”ip-172-31-33-214.us-west-2.compute.internal”
dateRange The Time Range configured for the report: Last 2 hours | Last 24 hours | Last calendar day | Last 7 days | Last 14 days | Last 30 days | Last calendar month | Last 365 days | Any custom date range in this format: YYYY-MM-dd hh:mm TO YYYY-MM-dd hh:mm No. Defaults to Last 2 hours. String “dateRange”:”Last 2 hours”

Server CPU Report Parameters

You must additionally POST the following parameters for all reports of type Host CPU:

Property

Description

Required?

Type

Example

dateRange The Time Range configured for the report: Last 2 hours | Last 24 hours | Last calendar day | Last 7 days | Last 14 days | Last 30 days | Last calendar month | Last 365 days | Any custom date range in this format: YYYY-MM-dd hh:mm TO YYYY-MM-dd hh:mm No. Defaults to Last 2 hours. String “dateRange”:”Last 2 hours”
hostsVal The devices or groups selected for the report, where multiple devices or groups are separated by commas Yes String “hostsVal”:”ip-172-31-33-214.us-west-2.compute.internal,ip-172-31-37-162.us-west-2.compute.interal”
top10Only true | false

  • false: CPU metrics will be displayed for all selected devices
  • true: CPU metrics will only be displayed for the top ten devices
No. Defaults to false. Boolean “top10Only”:false
displayGraphs true | false. Whether or not CPU graphs should be displayed at the end of the report No. Defaults to false. Boolean “displayGraphs”:true

SLA Report Parameters

You must additionally POST the following parameters for all reports of type Service Level Agreement:

Property

Description

Required?

Type

Example

dateRange The Time Range configured for the report: Last 2 hours | Last 24 hours | Last calendar day | Last 7 days | Last 14 days | Last 30 days | Last calendar month | Last 365 days | Any custom date range in this format: YYYY-MM-dd hh:mm TO YYYY-MM-dd hh:mm No. Defaults to last 2 hours. String “dateRange”:”Last 30 days”
metrics The datapoints and corresponding SLA thresholds that will be included in the report, where each metric can include seven fields: groupName, deviceName, dataSourceFullName, dataSourceId, instances, metric and threshold. Threshold should comprise of an operator and a number separated by a space, where valid operators are >, <, !=, =, >= and <=. Yes JSON Object “metrics”:[{“groupName”:”*”,”deviceName”:”*”,”dataSourceId”:368,”instances”:”*”,”metric”:”UptimeMinutes”,”threshold”:”> 0″}]
dayInOneWeek The days of the week that the SLA report should take into account, where multiple values are separated by commas and * refers to all days of the week Yes String “dayInOneWeek”:”*”
periodInOneDay The hours of each selected day that the SLA report should take into account, where * refers to all hours Yes String “periodInOneDay”:”*”
displaySummary If true, the SLA summary (total %) will be displayed No. Defaults to false. Boolean “displaySummary”:false
unmonitoredTime 0|1|2 – How the time we have no data for the device should be counted, where 1 = ignore no data (subtract from total time), 2 = count as violation (subtract from uptime), 3 = count as available (add to uptime) No. Defaults to false. Integer “unmonitoredTime”:1
displayWithAvailability If true, only devices with less than 100% availability will be displayed in the report. No. Defaults to false. Boolean “displayWithAvailability”:false
columns The columns to be included in the report No. Defaults to all. JSON Object “columns”:[{“name”:”Device”,”isHidden”:false},{“name”:”Datasource”,”isHidden”:false},{“name”:”Instance”,”isHidden”:false},{“name”:”Datapoint”,”isHidden”:false},{“name”:”Threshold”,”isHidden”:false},{“name”:”Available”,”isHidden”:false},{“name”:”Unavailable”,”isHidden”:false}]

Website Service Overview Report Parameters

You must additionally POST the following parameters for all reports of type Website Service Overview:

Property

Description

Required?

Type

Example

servicesVal The services OR service groups (full path) selected for the report, where multiple entities are separated by commas Yes String “servicesVal”:”CName_check”
servicesValType service | group. The type of entities specified in the servicesVal field. Yes String “servicesValType”:”service”
dateRange The Time Range configured for the report: Last 2 hours | Last 24 hours | Last calendar day | Last 7 days | Last 14 days | Last 30 days | Last calendar month | Last 365 days | Any custom date range in this format: YYYY-MM-dd hh:mm TO YYYY-MM-dd hh:mm No. Defaults to Last 2 hours. String “dateRange”:”Last 2 hours”
displayType 1 | 2

  • 1: Display overall locations
  • 2: Display overall and individual locations
No. Defaults to 1. Integer “displayType”:1
includeTypes The information that should be included in the report. Options include 1: availability, 2: alerts, 3: graphs Yes JSON Object “includeTypes”:[1,2,3]

Examples

Example Request 1: Add an Alert Report

The following Python 3 script will add an Alert report to api.logicmonitor.com:

#!/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 = '/report/reports'
data = '{"type":"Alert","name":"MyAlertReport","format":"HTML","description":"My Report Description","delivery":"none","groupFullPath":"Website","level":"error","activeOnly":true,"columns":[{"name":"Severity","isHidden":true},{"name":"Group","isHidden":true}]}'

#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

print requestVars

#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)

Example Request 2: Alert SLA Report

The following Python 3 script will add an Alert SLA report to api.logicmonitor.com:

#!/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 = '/report/reports'
data = '{"type":"Alert SLA","name":"MyAlertSLAReport","format":"HTML","description":"My Report Description","delivery":"none","hostsVal":"Website","hostsValType":"group","dataSource":"NetSNMPCPUwithCores","alertRule":"Prod Server Error/Critical","alertLeve":"Error"}'

#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

print requestVars

#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)

Example Request 3: Alert Threshold Report

The following Python 3 script will add an Alert Threshold report to api.logicmonitor.com:

#!/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 = '/report/reports'
data = '{"type":"Alert threshold","name":"MyAlertThresholdReport","format":"HTML","description":"My Report Description","delivery":"none","groupFullPath":"Website","deviceDisplayName":"ip-172-31-37-162.us-west-2.compute.interal", "dataSourceInstanceName":"HTTP-80"}'

#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

print requestVars

#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)

Example Request 5: Device Inventory Report

The following Python 3 script will add a Device Inventory report to api.logicmonitor.com:

#!/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 = '/report/reports'
data = '{"type":"Host inventory","name":"MyDeviceInventoryReport","format":"HTML","description":"My Report Description","delivery":"none","hostsVal":"*","hostsValType":"host","properties":["system.aws.publicIpAddress","system.aws.resourceid","system.aws.region","system.aws.stateName"],"sortedBy":"system.aws.resourceid"}'

#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

print requestVars

#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)

Example Request 7: Interface Bandwidth Report

The following Python 3 script will add an Interface Bandwidth report to api.logicmonitor.com:

#!/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 = '/report/reports'
data = '{"type":"Interfaces Bandwidth","name":"MyIBReport","format":"HTML","description":"My Report Description","delivery":"none","hostsValType":"host","hostsVal":"ip-172-31-33-214.us-west-2.compute.internal,ip-172-31-37-162.us-west-2.compute.interal","rowFormat":0}'

#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

print requestVars

#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)

Example Request 8: Netflow Report

The following Python 3 script will add a Netflow report to api.logicmonitor.com:

#!/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 = '/report/reports'
data = '{"type":"Netflow device metric","name":"MyNetflowReport","format":"HTML","description":"My Report Description","delivery":"none","hostsVal":"ip-172-31-33-214.us-west-2.compute.internal,ip-172-31-37-162.us-west-2.compute.interal"}'

#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

print requestVars

#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)

Example Request 9: Server CPU Report

The following Python 3 script will add a Server CPU report to api.logicmonitor.com:

#!/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 = '/report/reports'
data = '{"type":"Host CPU","name":"MyServerCPUReport","format":"HTML","description":"My Report Description","delivery":"none","hostsVal":"ip-172-31-33-214.us-west-2.compute.internal,ip-172-31-37-162.us-west-2.compute.interal","displayGraphs":true}'

#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

print requestVars

#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)

Example Request 10: SLA Report

The following Python 3 script will add an SLA report to api.logicmonitor.com:

#!/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 = '/report/reports'
data = '{"type":"Service Level Agreement","name":"MySLAReport","format":"HTML","description":"My Report Description",periodInOneDay":"*","dayInOneWeek":"*","metrics":[{"groupName":"*","deviceName":"ip-172-31-33-214.us-west-2.compute.internal","dataSourceId":368,"instances":"*","metric":"UptimeMinutes","threshold":"> 0"}]}'

#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

print requestVars

#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)

Example Request 11: Website Service Overview Report

The following Python 3 script will add a Website Service Overview report to api.logicmonitor.com

#!/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 = '/report/reports'
data = '{"type":"Website Service Overview","name":"MyWebsiteReport","format":"HTML","description":"My Report Description","delivery":"none","servicesValType":"service","servicesVal":"CName_check","includeTypes":[1,2,3],"displayType":1}'

#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

print requestVars

#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)

Example Response

The following is an example response for one of the above example requests:

Response Status: 200
Response Body: {
  "status" : 200,
  "errmsg" : "OK",
  "data" : {
    "id" : 195,
    "name" : "MyWebsiteReport",
    "description" : "My Report Description",
    "type" : "Website Service Overview",
    "groupId" : 0,
    "format" : "HTML",
    "delivery" : "none",
    "recipients" : [ ],
    "schedule" : "",
    "lastmodifyUserId" : 131,
    "lastmodifyUserName" : "sarah",
    "enableViewAsOtherUser" : false,
    "userPermission" : "write",
    "lastGenerateOn" : 0,
    "lastGenerateSize" : 0,
    "lastGeneratePages" : 0,
    "customReportTypeId" : 0,
    "reportLinkNum" : 0,
    "servicesVal" : "CName_check",
    "servicesValType" : "service",
    "dateRange" : "last 2 hours",
    "displayType" : 1,
    "includeTypes" : [ 1, 2, 3 ]
  }
}
In This Article