Forum Discussion

Kelemvor's avatar
Kelemvor
Icon for Expert rankExpert
9 days ago

Any way to automate tasks via alerts?

Hi,

I know LM doesn't support taking any action when there's an alert.  However, I'm wondering if anyone has any neat ideas on how to accomplish something by way of some other automation program.  Maybe Power Automate?

Here's what I'm thinking.

I have a module that monitors a service to see if it's running or not.  If it's not, it generates an alert.  This seems like the most basic thing to automate because all I'd want to do is run the start-service command to start it back up.  So, I'm wondering if I can have the alert send an email to a certain address.  That address could then watch for a certain email to arrive.  It could then parse out the servername and service name and put that into a start-service -computername xxx -name yyy.

Has anyone looked into doing anything like that and did you have any success?

Thanks.

  • Could you just include the logic to restart the service in the existing datasource?

    I've done something similar with a datasource collection. Checks to see if the service is running,  tracks restarts, checks to see how long the service is up (didn't want to issue a restart if the service is starting due to a reboot), etc.  

    Regarding your direct question, I think you could automate it with Alert rules and Integrations (custom email delivery or custom HTTP delivery). 

    I'm sure others will have stronger suggestions. 

    • Kelemvor's avatar
      Kelemvor
      Icon for Expert rankExpert

      I've always been told that LM doesn't have the ability to take any action based on an alert.  If there's a way to have LM issue a Start Service command, when it sees that one has stopped, I'd love to know how to do that.

      • befuddled's avatar
        befuddled
        Icon for Neophyte rankNeophyte

        In which scenario?

        The first I was talking about is taking the action in the datasource. For example, you have a Powershell datasource that checks to see if a windows service is running and if it's not, it restarts the service. I see your point that it isn't really based on an alert, but it's still doable and I've used it in basic situations to pretty good success. You could create an alert about restarting the service if you wanted to track restarts. If you go this route, I'd recommend you check server uptime (you don't want to re-start the service if the server was just rebooted and it hasn't been up long enough for the service to start). 

        The second would be to create an alert rule and an integration (specific alerts send to a specific integration). The integration is either a http or email delivery. You'd need to code the endpoint for the integration to take an action based on the alert. For example, a lambda function in AWS. 

        Hope this helps. I'm sure you'll get other good (probably better) feedback. 

        Cheers!

  • Look at StackStorm integration? webhook to there and then write actions based on the alert context?

    Or even something like a generic webhook to say a self hosted n8n instance again do things based on the context