Getting Dashboard Details
Last updated on 07 October, 2024You can use LogicMonitor REST API v3 to get dashboard details. You must authenticate yourself before making the API request.
Getting List of Dashboards
URI: GET /dashboard/dashboards
Parameter | Type | Description |
fields | String | The response is filtered to include only the specified fields for each object. You can provide a list of properties separated by a comma. Example – /dashboard/dashboards?fields=id,description |
size | Integer | Indicates the number of result to display. A maximum of 1000 results can be requested in a GET request. By default, a list of 50 dashboards is returned if a value is not provided for this parameter. Example – /dashboard/dashboards?size=10 |
offset | Integer | Indicates the number of results to offset the displayed results. Example – /dashboard/dashboards?offset=5 |
filter | String | The response is filtered according to the operator and specified value that is, filter=property:value
Operators include:
/dashboard/dashboards?filter=groupName~Server Dashboard* |
The following Node.js script requests all dashboards in the account api.logicmonitor.com.
//Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
//Note: The below is provided for illustration purposes only.
var readlineSync = require('readline-sync');
var accessId = readlineSync.question('Enter your AccessId: ', { hideEchoBack: true });
var accessKey = readlineSync.question('Enter your AccessKey: ', { hideEchoBack: true });
var company = 'api'
// Request Details
var httpVerb = "GET";
var epoch = (new Date).getTime();
var resourcePath = "/dashboard/dashboards";
// Construct signature
var requestVars = httpVerb + epoch + resourcePath;
var crypto = require("crypto");
var hex = crypto.createHmac("sha256", accessKey).update(requestVars).digest("hex");
var signature = new Buffer(hex).toString('base64');
// Construct auth header
var auth = "LMv1 " + accessId + ":" + signature + ":" + epoch;
// Configure request options
var request = require('request');
var options =
{
"method" : httpVerb,
"uri" : "https://" + company + ".logicmonitor.com/santaba/rest" + resourcePath,
"headers": {
'ContentType' : 'application/json',
'Authorization': auth
},
"qs": {
'fields': 'id,name',
'filter': 'name~ip'
}
};
// Make request
request(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
// Print out the response body
console.log(body)
}
});
Getting Details of Specific Dashboard
URI: GET /dashboard/dashboards/{id}
Parameter | Type | Description |
id | Integer | (Mandatory) The ID of the dashboard whose details you want to get. |
template | Boolean | If set as true , then return the dashboard template either in json format or return the file . By default, it is set as false . |
format | String | The format is used only if the template is set as true . Supported formats are json or file . The default format is json . |
fields | String | The response is filtered to include only the specified fields for each object. You can provide a list of properties separated by a comma. Example – /dashboard/dashboards/id?fields=name,description |
The following Node.js script requests dashboard 34 for account api.logicmonitor.com.
//Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
//Note: The below is provided for illustration purposes only.
var readlineSync = require('readline-sync');
var accessId = readlineSync.question('Enter your AccessId: ', { hideEchoBack: true });
var accessKey = readlineSync.question('Enter your AccessKey: ', { hideEchoBack: true });
var company = 'api'
// Request Details
var httpVerb = "GET";
var epoch = (new Date).getTime();
var resourcePath = "/dashboard/dashboards/34";
// Construct signature
var requestVars = httpVerb + epoch + resourcePath;
var crypto = require("crypto");
var hex = crypto.createHmac("sha256", accessKey).update(requestVars).digest("hex");
var signature = new Buffer(hex).toString('base64');
// Construct auth header
var auth = "LMv1 " + accessId + ":" + signature + ":" + epoch;
// Configure request options
var request = require('request');
var options =
{
"method" : httpVerb,
"uri" : "https://" + company + ".logicmonitor.com/santaba/rest" + resourcePath,
"headers": {
'ContentType' : 'application/json',
'Authorization': auth
},
"qs": {
'fields': 'id,name',
'filter': 'name~ip'
}
};
// Make request
request(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
// Print out the response body
console.log(body)
}
});
Getting List of Widgets based on Dashboard ID
URI: GET /dashboard/dashboards/{id}/widgets
The query parameters fields
, size
, offset
, and filter
should also be included while making the GET
call /dashboard/dashboards/{id}/widgets
. Please refer the table in the section Getting list of Dashboards for details about the query parameters.
An additional parameter id
which is specific to GET
call /dashboard/dashboards/{id}/widgets
has been described in the following table.
Parameter | Type | Description |
id | Integer | (Mandatory) The ID of the dashboard to get the widget list specific to the dashboard. |