Accessing the LogicMonitor REST API with Postman and LMv1 API Token Authentication
Introduction Postmanis widely used for interacting with various REST APIs such as LogicMonitor's. However, there is no out-of-the-box support for the LMv1 authentication method which we recommend as a best practice. This document describes how to configure Postman to use LMv1 authentication when interacting with our REST API. Overview Postman'spre-request script functionalityprovides the ability to generate the necessary Authorization header for LMv1 authentication. As the name suggests, the pre-request script runs immediately before the request is made to the API endpoint. We set the pre-request script at the collection level in Postman so that it will run automatically for every request that is part of the collection. The script requires three input parameters: a LogicMonitor API token (or ID), its associated key, and the full request URL. These parameters are made available to the script by creating a Postman environment and setting the values as environment variables. If you need to access multiple LogicMonitor accounts (portals), create a separate environment for each to store the applicable API and URL information. Since all API requests to a given account use the same base URL (https://<account>.logicmonitor.com/santaba/rest) it is convenient to store this as an environment variable. The output of the script is the value of the Authorization header. The script writes the header value to an environment variable which is then inserted as the Authorization header value in the request. Instructions 1. Download and installPostman. 2. Launch Postman andcreate a new collectionthat will be used for all LogicMonitor API requests. 3. In the create collection dialog, select the "Pre-request Scripts" section and paste in the following code. // Get API credentials from environment variablesvar api_id = pm.environment.get('api_id');var api_key = pm.environment.get('api_key'); // Get the HTTP method from the requestvar http_verb = request.method; // Extract the resource path from the request URLvar resource_path = request.url.replace(/(^{{url}})([^\?]+)(\?.*)?/, '$2'); // Get the current time in epoch formatvar epoch = (new Date()).getTime(); // If the request includes a payload, included it in the request variablesvar request_vars = (http_verb == 'GET'||http_verb == 'DELETE') ?http_verb + epoch + resource_path : http_verb + epoch + request.data + resource_path; // Generate the signature and build the Auth headervar signature = btoa(CryptoJS.HmacSHA256(request_vars,api_key).toString());var auth = "LMv1 " + api_id + ":" + signature + ":" + epoch; // Write the Auth header to the environment variablepm.environment.set('auth', auth); 4. Create anew environment. Create the environment variables shown below. You do not need to provide a value for the "auth" variable since this will be set by the pre-request script. Be sure to use the api_id, api_key, and url values appropriate for your LogicMonitor account. 5. Create arequestand add it to the collection with the pre-request script. A sample request is shown below with the necessary parameters configured. 1. Set the environment for the request, 2. Set the HTTP method for the request. 3. Use{{url}} to pull the base URL from the environment variable. Add the resource path and any request parameters your API request may require. 4. Add the Authorization header and set the value to{{auth}}to pull the the value from the environment variable. 5. POST, PUT, and PATCH requests only: if your request includes JSON data, be sure to select the Body tab and add it. 6. Press Send to send the request. The response will appear below the request in Postman. Troubleshooting You receive the response "HTTP Status 401 - Unauthorized" Confirm the following: • The proper environment has been specified for the request. • The necessary environment variables have been set and their values are correct. Note that the script relies on the specific variable names used in this document: "api_id", "api_key", "url", and "auth". • The request is a member of the collection configured with the pre-request script. Postman reports "Could not get any response" or "There was an error in evaluating the Pre-request Script: TypeError: Cannot read property 'sigBytes' of undefined" Make sure you have set the proper environment for the request and all necessary environment variables and values are present.3.6KViews43likes42CommentsExperience the new API v3
As you all know, we have implemented all the latest enhancements in LogicMonitor REST API v3 ONLY. Some of the key features that work only with API v3 are: Advance filtering to get accurate result Bearer token for authentication Delta feature on device\devices endpoint (coming soon…) To start using all these features, we strongly recommend you to upgrade to LogicMonitor API v3 as the base version in your environment. For more details, refer to the following support articles: REST API v3 Swagger doc: https://www.logicmonitor.com/support/v3-swagger-documentation REST API v3 Advanced filtering: https://www.logicmonitor.com/support/rest-api-advanced-filters Bearer token with REST API v3: https://www.logicmonitor.com/support/bearer-token409Views33likes7CommentsLogicMonitor.Api C# API nuget 1.191 Released
All that strongly-typed goodness can be found in the usual place: Web:https://www.nuget.org/packages/LogicMonitor.Api/ Visual Studio / VS Code: manage nuget packages for your project/solution and search for "LogicMonitor" Adding LogicMonitor.Api to your project It's THIS easy to print an inventory of all regular Resources (paging is handled automatically): Taking inventory in 25 lines or fewer We will answer your questions on this forum! Please include the word "C#" or "nuget" in your subject line.67Views17likes4CommentsAPI Filtering
Hi all I’m hoping someone might be able to steer me in the right direction! I’m trying to put together a filter to pull back devices that have: system.azure.tag.environment = production system.azure.tag.environment = prod or have no system.azure.tag.environment at all I’ve put this together so far: systemProperties:"{\"name\":\"system.azure.tag.environment\",\"value\":\"Production\"}"| "{\"name\":\"system.azure.tag.environment\",\"value\":\"Prod\"}"| "{\"name\":\"system.azure.tag.environment\",\"value\":::empty}" Which is accepted but it only pulls back devices where environment=Production or Prod. I think the issues with :::empty is that it only works if the system property system.azure.tag.environment exists, which it won’t if it’s not set to anything. I was hoping I might be able to do something like this, but this isn’t accepted…. systemProperties:"{\"name\":\"system.azure.tag.environment\",\"value\":\"Production\"}"| "{\"name\":\"system.azure.tag.environment\",\"value\":\"Prod\"}" || systemProperties!~"{\"name\":\"system.azure.tag.environment\",\"value\":\"*\"}" Any ideas?124Views17likes6CommentsNeed help on PaloAlto_FW_RunningConfigXML API configsource
Currently, the sole option is to collect/view the configuration xml when a change occurs. So,IsthereawayinLMtogenerateareportusingthePaloAlto_FW_RunningConfigXMLAPIconfigsource? or Is it possible to collect the configuration backup at any specific time interval? Thanks in advance :)70Views16likes2CommentsLM Community Newsletter - August 2023
LM Community Spotlight LM Customer of the Month Matt Whitney Meet Matt Whitney! LM Community customer of the month! Matt is a TechOps Administrator at CDI and acts as an LM subject matter expert for CDI's customers and internal engineers. If there is something CDI needs done that is not provided out-of-the-box by LM, Matt can script out custom solutions, such as LogicModules for custom monitoring or API-based reporting. What do you love most about being a member of the LM community? One great thing about the community is that you can see the different ways other people use the product. If I am trying to do something out-of-the-box in LM (custom monitoring/automations/etc) then the forums are the first place I look to get ideas and see how others have solved for similar things. Also if I notice an issue/bug there is likely already discussion about it in the forums, if not then the forums are a great place to get visibility on issues! LM Employee of the Month Patrick Rouse Meet Patrick Rouse!LM Community Employee of the month! Patrick is a Sr. Product Manager joined LogicMonitor January 2022. Patrick is responsible for IT Infrastructure Monitoring (Modules), and passionate about cloud-managed networking. What do you love most about being a member of the LM community? “I love hearing feedback (good or bad) and ideas from our customers!” Top Content Exciting news regarding the LogicMonitor Inner Circle! Read about our new Customer Engagement Platform Summer Launch Modernizing Monitoring: LogicMonitor’s Latest Innovations Product Discussions New VMware modules dropped Accessing the LogicMonitor REST API with Postman and LMv1 API Token Authentication Tech Talk LogicMonitor Collector Ports to be used while monitoring end-user devices LM News Introducing Enhanced Dashboards and Settings in the New UI Open Beta Process New UI eLearning Courses Available in LM Academy Dashboards UIv4 is available starting August 23! New Settings Beta! New Resources UI Datapoint Analysis now available! API v3 usage & migration Enhanced API v3 Experience with Delta on device\device endpoint Experience the new API v3 LogicBots Bytesize Humor Meet Bob! He is a Rhodes Scholar and regularly enjoys wine tasting, truffle hunting, and holidays in Spain. He restores vintage cars for fun and strangely, his shirts don't wrinkle. He hikes the PCT Annually during his unplugged, and catches up on the Hard Core History podcast. Bob’s is such a fungi, he lovesTruffle hunting with his friend Lagotto! 174Views15likes1CommentGetting specific datapoints using the REST API
In this post: https://community.logicmonitor.com/archive-13/getting-datapoint-data-via-rest-api-1249 … @Sarah Terry provides information on how to get data for just specific datapoints, reducing load on the API, minimizing network traffic and reducing deserialization load on the client. While this is VERY useful, it is not currently possible to do this for graph data. An example of such a call would be: {{logicmonitor_url}}/device/devicedatasourceinstances/229505122/graphs/-1/data?datapoints=sentpkts …which brings back the default graph data (all datapoints), though this would also work for a specific graph. The advantage of this approach to data fetch is that it permits the retrieval of virtual datapoints. In order to achieve the same benefits, we (Panoramic Data) request that the same datapoint filtering is added to the {{logicmonitor_url}}/device/devicedatasourceinstances/{instanceId}/graphs/{graphId}/data endpoint. Of lesser importance would be other graph API endpoints (e.g. the website graph API endpoint) Thanks in advance! David39Views15likes0CommentsLM API v3 Python boilerplates
In light of the coming sunset of v1 and v2 of LM API, I decided to start updating some of my own scripts. I ran successful tests ofthese python boilerplates with v3:https://github.com/krshearman/LMAPI_v3 I hope it helps someone get started using LM API v3!154Views15likes5CommentsCan the API get the alert rule associated to a datapoint on a DS instance?
I have been hunting through the swagger docs, and I can’t seem to find a way to get the alert rule or alert routing being applied to a specific datapoint on a specific datasource instance. I’ve looked for routing, tuning, etc and I’m not seeing anything. I want to write a script that looks through every resource, snags the Host Status instance specific to that object, looks at the idleInterval datapoint, and then shows me the Alert Routing information. We found an old alert rule that was set up wrong and accidentally was letting idleInterval alerts slip through. So I want to write a script that shows me what they all are. I can drill down to the specific host status instance on the resource, but nothing actually shows me the alert routing, that I can find. There is an alertsettings and a config call one can make against the datasource, but they dont show the actual routing. Is there an API call I’ve overlooked? Or is this something you can’t pull back via API? Thanks!Solved74Views14likes5CommentsProvisioning LDAP Application in Sailpoint IIQ
I am new to Sailpoint. I have onboarded LDAP Application, aggregated and next I want to provision a delimited file data to LDAP application. I followed the step this way --> Manage User --> Selected User --> Manage Access --> filter --> Entitlement Application --> LDAP --> Selected and proceeded further. And I get the error every time76Views14likes2Comments