Forum Discussion
I've gotten close, to the point that I can add a propertysource that will run a groovyscript to write an auto property with the sys_id at the time the propertysource is added. But I don't see a way of having it automatically update on a schedule.
I'm now thinking that an EventSource might be the best way of going after this, but I'll need to dig into what it expects as a return value and how to modify the groovyscript to fit.
(the groovyscript actually does a https API call back to LM since I couldn't figure any other way of accessing the API from the groovyscript in the platform, which I find odd)
As I understand it, you don't really have any control over when a Property Source runs. It is a convenient way to get a property onto a device though...
Do you need to store the sysid against the device? Just thinking that might get complicated, especially if a device has more than one active alert for whatever reason.
You could create a dummy device in LogicMonitor, make sure the device is assigned to a collector, put some LM API and Service Now API credentials in properties on that device. This dummy device just serves as something to associate a custom data source off so you can get code to run on a collector.
Then write a data source that applies just to that dummy object. Have it query the LM API for all alerts created between 1 hour and 2 hours ago and their sysids. Then loop through those alerts and call the Service Now API to create Incident Tasks you need. You could even use the Collector Cache to store the alerts IDs that you've already processed so you don't create duplicate Incident Tasks.
You could have the data source return just a single value 0=good, 1=there was an error. Then do an alert on that so you know if your script is failing.
- Jason_Clemons26 days ago
Neophyte
Well, I started looking at PropertySouce since, unless I'm mistaken, DataSource requires a numeric, yeah? I couldn't really wrap my head around setting up an EventSource which I suspect would be technically most appropriate though.
- Dave_Lee24 days ago
Advisor
You're right, a data source can only be used to return a numeric to LogicMonitor itself, but essentially a script based data source just runs whatever code you put in it and should then return some numeric values to logicmonitor for the metrics it is designed to capture.
Admittedly, it's a bit of a weird way to use a data source but, given you can have it run whatever code you like, you could write code that pulls Alerts from the LM API and happened in the last run then have it call the Service Now API to raise Incident Tasks. It could then return a value to LogicMonitor to confirm it ran successfully or not.
- Jason_Clemons23 days ago
Neophyte
Well, I've successfully developed out an EventSource that will write an event that has both the internal alert ID and the sys_id for Servicenow in the message, however, it's repeating the alert every minute. I think I need to find a way to check the current events to see if the same payload exists and exit.