Come join our live training webinar every other Wednesday at 11am PST and hear LogicMonitor experts explain best practices and answer common questions. We understand these are uncertain times, and we are here to help!
You can use LogicMonitor’s REST API to programmatically get information about the dashboards in your account. Specifically, you can get a list of dashboards or information on a specific dashboard.
As with all of our API calls, authentication is required.
HTTP Method: GET
Resource URI: /dashboard/dashboards
Request Parameters: By default, a list of 50 dashboards will be returned. You can include sort, filter, fields, size and offset parameters in your request to control what data is included in the response and how it is formatted.
The following Node.js script requests all dashboards in the account api.logicmonitor.com.
// Account Info var accessId = '48v2wRzfK94y53sq5EuF'; var accessKey = 'H_D9i(f5~B^U36^K6i42=^nS~e75gy382ki8{)P+'; 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) } });
Resource URI: /dashboard/dashboards/{id}
The following Node.js script requests dashboard 34 for account api.logicmonitor.com.
// Account Info var accessId = '48v2wRzfK94y53sq5EuF'; var accessKey = 'H_D9i(f5~B^U36^K6i42=^nS~e75gy382ki8{)P+'; 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) } });
In This Article