Logic.Monitor (PowerShell) module
If you're a LogicMonitor user looking to streamline your workflows and automate repetitive tasks, you'll be pleased to know that there's is a PowerShell module available to help you do just that. As a longtime Windows administrator, I've relied on PowerShell as my go-to tool for automating and managing my infrastructure. I've found that the ability to automate tasks through PowerShell not only saves time, but also reduces errors and ensures consistency across the environment. Developed by myself as a personal side project, this module provides a range of cmdlets that can be used to interact with the LogicMonitor API, making it easier than ever to manage your monitoring setup directly from the command line. Whether you're looking to retrieve information about your monitored devices, update alert thresholds, or perform other administrative tasks, this module has you covered. In this post, we'll take a closer look at the features and capabilities of this module, and show you how to get started with using it in your own automation scripts. This project is published in the PowerShell Gallery at https://www.powershellgallery.com/packages/Logic.Monitor/. Installation From PowerShell Gallery: Install-Module -Name "Logic.Monitor" Upgrading: #New releases are published often, to ensure you have the latest version you can run: Update-Module -Name "Logic.Monitor" General Usage: Before you can use on module commands you will need to be connected to a LM portal. To connect your LM portal use the Connect-LMAccount command: Connect-LMAccount -AccessId "lm_access_id" -AccessKey "lm_access_key" -AccountName "lm_portal_prefix_name" Once connected you can then run an appropriate command, a full list of commands available can be found using: Get-Command -Module "Logic.Monitor" To disconnect from an account simply run the Disconnect-LMAccount command: Disconnect-LMAccount Examples: Most Get commands can pull info by id or name to allow for easier retrieval without needing to know the specific resource id. The name parameters in get commands can also accept wildcard values. Get list of devices: #Get all devices Get-LMDevice #Get device via id Get-LMDevice -Id 1 #Get device via hostname Get-LMDevice -Name device.example.com #Get device via displayname/wildcard Get-LMDevice -DisplayName "corp*" Modify a device: #Change device Name,DisplayName,Descrition,Link and set collector assignment Set-LMDevice -Id 1 -DisplayName "New Device Name" -NewName "device.example.com" -Description "Critical Device" -Link "http://device.example.com" -PreferredCollectorId 1 #Add/Update custom properties to a resource and disable alerting Set-LMDevice -Id 1 -Properties @{propname1="value1";propname2="value2"} -DisableAlerting $true ***Using the Name parameter to target a resource during a Set/Remove command will perform an initial get request for you automatically to retrieve the required id. When performing a large amount of changes using id is the preferred method to avoid excessive lookups and avoid any potential API throttling. Remove a device: #Remove device by hostname Remove-LMDevice -Name "device.example.com" -HardDelete $false Send a LM Log Message: Send-LMLogMessage -Message "Hello World!" -resourceMapping @{"system.displayname"="LM-COLL"} -Metadata @{"extra-data"="value";"extra-data2"="value2"} Add a new user to LogicMonitor: New-LMUser -RoleNames @("administrator") -Password "changeme" -FirstName John -LastName Doe -Email jdoe@example.com -Username jdoe@example.com -ForcePasswordChange $true -Phone "5558675309" There are over ~150 cmdlets exposed as part of this module and more are being added each week as I receive feedback internally and from customers. For more details and other examples/code snippets or to contribute you can visit the github repo where this is hosted. Source Repository:https://github.com/stevevillardi/Logic.Monitor Additional Code Examples:https://github.com/stevevillardi/Logic.Monitor/blob/main/EXAMPLES.md Note: This is very much a personal project and not an official LogicMonitor integration. If the concept of a native PowerShell module interest you, I would recommend putting in a feedback request so that the demand can be tracked.2.3KViews54likes29CommentsGetting Graph Sharing Token via REST API
Hello, I am new member of LogicMonior. I have created new dashboard and done aboutadding device graph into dashboard via API, it work! but now, I want to generate “Widget Embedded URL”and also get“Sharing Token” via REST API, after created graph on Dashboard. Is it possible to do that? Thank you very much for all recommendation and commentSolved151Views24likes14CommentsLogicMonitor.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.67Views17likes4CommentsDevice DataSource Instance datapoint historical data using RestAPI v3
I am having problems getting the RestAPI to return any data regardless the combination of paths, query params, time filters I try using. What am I doing wrong? Here’s my ultimate URL I’ve built for this effort: $ddsiis a successfully retrieved object (DeviceDataSourceInstance) Start and End are from these: [int]$start = get-date (get-date).addMonths(-3) -uformat %s [int]$end = get-date (get-date).addMonths(-3).AddMinutes(5) -uformat %s /device/devices/$($ddsi.deviceid)/devicedatasources/$($ddsi.devicedatasourceid)/data?size=500&offset=0&start=$start&end=$end&datapoints=Capacity,PercentUsed All of the pieces and parts seem to line up with examples I’ve found here and in the LM Docs…it doesn’t error out, but returns nothing. Goal is to get volume capacity metrics from 3 months ago. Where am I going awry here? Everything works up until I add the /data at the end.195Views15likes25CommentsGetting 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! David39Views15likes0Comments[Feature request] Custom PowerShell script: increase timeout
Hello, I was advised to go here after chatting with support. I have run into an issue where our custom PowerShell script runs into the hardcoded 120 second timeout. We're initially testing it first via the Test button. The error after exactly 120 seconds is: “"Test script failed - no response was received from the Collector"”. The script runs okay in PowerShell 5.1, but it averages around 2,6 minutes. We have already cut the runtime down from around 4 minutes to 2,6 minutes and that's the best we can do. It starts generating “Write-Host” data within 50 seconds for each object. We are pulling data from public API endpoints and perform some logic for 2 large arrays. The script will run against a dedicated collector. Issue is in the sandbox as well as in the production environment.Solved109Views14likes7CommentsFeature Request: Website Properties
Two requests: 1. Website Inherited Properties Please could the website entity have an “inheritedProperties” field added, much like resources do. This will not require any additional UI, but saves a lot of API round trips. 2. Website Custom Properties Please could the website entity have an “customProperties” field added, much like resources do. This WILL require additional UI on the Website Create/Edit Dialog. Happy if this is UIv4 only.26Views13likes4CommentsResource Path API Request
Hi please find the resource path for API request {{url}}/device/devices/659/devicedatasources/77499/instances/64341678/data in the above path , we can get device ID 659 & instances id 64341678 from LM UI under info section. where can we getdevicedatasources id? Could you please Help56Views12likes4CommentsUsing Postman to create multiple Websites via API & CSV?
Hi, I’m testing out creating websites (or resources) via the API. I have a standard Post working in Postman just fine. However, when I then try to do the same thing via a CSV file in the Runner section, I’m getting 401 Authorization errors. When I look at the data that’s being sent, it looks the same as what’s sent when I run it manually. Is there something special I need to do when running a Post command via the Runner vs the manual Send command? Thanks.Solved535Views12likes40CommentsWhy can't Administrators create API Tokens?
It makes no sense that Administrators cannot themselves create API Tokens (e.g for new API-only users in a read-only role). I have to either: Ask someone to demote my account (e.g. to the “manager” role) Create the API Token Ask them to promote my account back to the administrator role OR Create myself a second identity (which is contrary to our security policy). OR Create an API Token creation tool to bypass this nonsense.168Views11likes9Comments