How IT administrators can streamline operations using the LogicMonitor API

Proactively manage modern hybrid environments with predictive insights, intelligent automation, and full-stack observability.
Explore solutionsExplore our resource library for IT pros. Get expert guides, observability strategies, and real-world insights to power smarter, AI-driven operations.
Explore resourcesOur observability platform proactively delivers the insights and automation CIOs need to accelerate innovation.
About LogicMonitorAccess the latest news, ebooks, and webinars.
In today’s fast-paced IT ecosystem, agility and efficiency are not just goals but necessities. So why waste an hour (or more) manually onboarding individual devices when you can leverage the LogicMonitor API to automate the onboarding process for an entire site in just minutes from a simple CSV file?
In this article, we’re going to review how LogicMonitor administrators can maximize efficiency and transform their IT operations using LogicMonitor’s REST API and Powershell. We will cover the following use cases:
Designed to empower developers and IT administrators alike, LogicMonitor’s API serves as the backbone for automating and streamlining operations, offering a level of flexibility and power that can significantly enhance how LogicMonitor administrators manage their organization’s infrastructure.
To make integration as smooth as possible, we provide comprehensive SDKs for both Python and Go, ensuring you have the tools to tailor our platform to your specific requirements. Because over 75% of our customers leverage Windows-based collectors, Senior Sales Engineer, Steven Villardi, has taken LogicMonitor’s adaptability a step further by developing the Logic.Monitor PowerShell module.
This open-source module leverages the REST API to offer LogicMonitor administrators a seamless and familiar way to enhance their operational efficiency, embodying our commitment to meet and exceed the demands of modern IT management.
LogicMonitor’s latest customer-facing API is REST API v3. Two forms of authentication are supported by REST API v3: token-based LMv1 token and Bearer token authentication.
Before exploring some use cases and examples, we’ll need to ensure we have the Logic.Monitor PowerShell module installed from the PowerShell Gallery. To do so, simply follow the steps outlined below.
Install-Module -Name "Logic.Monitor"
Update-Module -Name "Logic.Monitor"
Before you can use any module commands, you must be connected to a LogicMonitor portal. To connect your portal, type in the Connect-LMAccount command.
#Using LMv1 Token
Connect-LMAccount -AccessId "lm_access_id" -AccessKey "lm_access_key" -AccountName "lm_portal_prefix_name"
#Using Bearer Token
Connect-LMAccount -BearerToken "lm_bearer_token" -AccountName "lm_portal_prefix_name"
Once connected, you can then run an appropriate command. A full list of available commands is found using:
Get-Command -Module "Logic.Monitor"
To disconnect from an account, simply run the Disconnect-LMAccount command.
Disconnect-LMAccount
One of a LogicMonitor administrator’s fundamental responsibilities is device lifecycle management. Rather than onboard or offboard each device individually, LogicMonitor administrators can take advantage of LogicMonitor’s REST API.
By employing the Logic.Monitor PowerShell module, administrators can complete device onboarding and offboarding processes in minutes while executing any requisite device updates, significantly reducing their administrative burden.
New-LMDevice -Name 192.168.1.1 -DisplayName device.example.com -Description "My new device" -PreferredCollectorId 8 -HostGroupIds @(1,2,3) -Properties @{"snmp.community"="public";location="NYC"}
Set-LMDevice -Name device.example.com -Description "My updated description" -PreferredCollectorId 15 -Properties @{location="AMER"} -DisableAlerting $true
Remove-LMDevice -Name device.example.com -HardDelete $true
Invoke-LMActiveDiscovery -Name device.example.com
In addition to device management, LogicMonitor administrators are also responsible for managing Role-Based Access Control (RBAC) settings and user accounts. The LogicMonitor API offers comprehensive management features for both user accounts and their associated role permissions.
New-LMUser -RoleNames @("administrator") -Password "changeme" -FirstName John -LastName Doe -Email [email protected] -Username [email protected] -ForcePasswordChange $true -Phone "5558675309"
Set-LMUser -Status suspended -Username [email protected]
New-LMRole -Name log_ingest -Description "Ability to ingest logs" -LogsPermission manage -ResourcePermission view
Frequently, LogicMonitor administrators must retrieve device information, search audit logs, extract metric data, and more. The Logic.Monitor REST API provides numerous endpoints, enabling customers to access their device and portal data and facilitating integration with third-party systems.
Get-LMAuditLogs -SearchString "[email protected]" -StartDate $(Get-Date).AddDays(-7) -EndDate $(Get-Date)
Get-LMDevice -Filter "name -eq '127.0.0.1' -and currentCollectorId -eq 8 -and disableAlerting -eq '$false'"
Get-LMDeviceData -DeviceName "127.0.0.1" -DatasourceName Ping -InstanceName Ping -StartDate $(Get-Date).AddDays(-7) -EndDate $(Get-Date)
With access to over 188 cmdlets within the Logic.Monitor module, LogicMonitor administrators can incorporate multiple commands into a single function/script to automate the onboarding process for an entire site in just minutes from a simple CSV file. The ability to enforce Standard Operating Procedures (SOPs) related to LogicMonitor administration guarantees that monitoring is accurately set up and activated for essential resources within your organization. Below is an example set of functions for auto-creating devices and device groups from a simple CSV file:
As we wrap up our exploration of the Logic.Monitor PowerShell Module, we invite you to take the leap into building and innovating with the LogicMonitor REST API. Your ideas and feedback are crucial for growth, so if you have any suggestions or would like to contribute to this open-source project, don’t hesitate to open an issue/enhancement request on GitHub.
Let’s harness this insight into LogicMonitor’s API as a catalyst for innovation and automation. Together, we can extend the capabilities of LogicMonitor’s platform and redefine what’s possible in hybrid observability.
Blogs
See only what you need, right when you need it. Immediate actionable alerts with our dynamic topology and out-of-the-box AIOps capabilities.