Blog Post

Tech Talk
4 MIN READ

LogicMonitor, Groovy, Python and APIs Ohhh my

PenYa's avatar
12 months ago

You just started your new job and they have LogicMonitor as their observability tool, that’s great!  One huge step up from other organizations you’ve worked with.  The last guy that worked on the platform did a pretty good job of keeping up with the platform but you see some improvements that would really help with the organization of the portal.  You want  to create multiple folder structures.  The first group of nested folders will be based on the equipment location the second will be based on the equipment task.  This will allow you to provide additional people access to the portal but limit their visibility into only the things that are in their location or their job function.  Yup sounds great, your coworkers like it and more importantly your manager approves.  Now how are you going to assign 700 pieces of equipment at 30 different sites to the correct folder with the correct permissions?  Oh yeah you got a secret weapon, APIs! 

The goal of this and subsequent posts is to try to demystify APIs.  What are they?  How are they used?  More importantly, how do they benefit you and of course your organization.  This will be the first installment of community posts discussing APIs and how they are used to perform tasks within the LogicMonitor portal.

If you are like I was and just dipping your toes into APIs and have started looking at videos on youtube or reading about the power of APIs you might be a bit overwhelmed.  That’s perfectly fine, it’s totally understandable!  APIs are a new tool that will help you perform repetitive tasks within LogicMonitor or any other application that provides APIs.  Since LogicMonitor is a SaaS application you don’t have a database where you can perform queries or other actions.  So queries and other tasks are replaced with the use of APIs. As you might have learned growing up, knowing what something is can make it less scary.  

So, what does API mean?  API is an acronym for Application Programming Interface.  See not that scary, yeah right.  I can tell you that the vast majority of people that use APIs on a regular basis have no idea what the acronym stands for.  What really is an API?  An API, more specifically a REST API, is an instruction that you can use with an application to do something.  The word DO is the key here, better said DO is the verb.  The verbs that are used for API calls are as follows:

  • GET allows you to get some information from the application
  • POST allows you create something within the application
  • DELETE allows you to delete something within the application
  • PUT allows you to update something within the application
  • PATCH allows you to update something within the application

What’s that that I’m hearing through time and network space?  Yup I’m hearing WHOA WHOA WHOA 

  • PUT allows you to update something within the application
  • PATCH allows you to update something within the application

Both have the same function?  Why have two verbs that do the same thing?  Well even though both perform a similar function each does it in a  different manner.  

  • PUT replaces the entire item that you are updating with new data
  • PATCH only replaces a portion of the item you are updating

I will go into more detail for each verb in future installments of this series.

If you are still with me. Really? I haven’t scared, bored or frustrated you with my ramblings yet?   Ok so you are with me, cool.  Why should you use up some of the storage in your brain to learn about APIs?  APIs will simplify your life while using not only LogicMonitor but any application that provides you API access.

Here are a couple more real world examples of how APIs can be leveraged to automate tasks within LogicMonitor

A customer has several hundred stores across the United States.  The customer wants the stores placed in nested folders 

Store folder - contains all devices at the store

District folder - multiple stores make up a district

State folder - All districts within a state

Region folder - Multiple states make a region

Trying to create this kind of structure manually would take days and be prone to errors.  You can create the nested group structure by leveraging APIs with your favorite scripting language, I prefer Python, and a CSV file containing store information.  While creating the group structure you can also add any necessary custom properties.

Another real world example of leveraging APIs

A customer has a very large user list within LogicMonitor, almost 800 users.  These users can change roles and/or have their access suspended.  Going through all 800 users to set roles, change user groups and update the account status can be daunting and honestly a brain melting  task that you probably wouldn’t wish even on the guy that stole that prime parking spot from you at the mall during christmas shopping season.

In comes super API and with a bit of Python coding you can perform this whole task automagically.  PLUS, since this task was performed using a script you will be able to do this task repeatedly without breaking a sweat.

In my next installment I will show how to start using APIs.  

Since it’s an unspoken rule that all guides need to provide links to relevant information, here are my hopefully useful links.

  • LogicMonitor Swagger A listing of all actions that can be performed using the LogicMonitor API.  

  • Learning Python If you are new to coding I recommend Python since it is OS agnostic and has a massive user base and information. 

  • Learning Groovy Here you thought groovy was just a word from the 60s and 70s, Au contraire mon frère.  Groovy is the primary scripting language used within LogicMonitor.  We will go deeper into this Groovy language later on.

LogicMonitor  How can we do anything without including a link to the best observability platform around.

Published 12 months ago
Version 1.0