Can I monitor a JSON file? Example included.
Hi, We have a script that runs and creates an output like the file attached. We need to be able to parse this file and look at the “replication” and “counts_match” fields and alert if we don’t find certain criteria. Can LM do that? I think that LM can only access files directly if they are on a collector, so we’d make sure this file ends up there. Thanks. I guess I can’t attach a file so here’s what it looks like: { "replication": [ { "db_name": "db1 ", "replication": "running ", "local_count": "12054251", "remote_count": "8951389", "counts_match": "false" }, { "db_name": "db2 ", "replication": "running ", "local_count": "0", "remote_count": "0", "counts_match": "true" }, { "db_name": "db3 ", "replication": "running ", "local_count": "0", "remote_count": "0", "counts_match": "true" }, { "db_name": "db4 ", "replication": "running ", "local_count": "97", "remote_count": "97", "counts_match": "true" }, { "db_name": "db5 ", "replication": "running ", "local_count": "0", "remote_count": "0", "counts_match": "true" } ] }Solved350Views12likes5CommentsJSON Path capability in a Webpage DataSource
I think the answer to this is gonna be “You need to script it, dummy”, but figured I’d check anyway... I'm working on a new DataSource that pulls/interprets JSON data from a peudo-custom system via HTTP. The system has a status page that lists the status of various components using JSON elements that have this general format: ParameterName&ParameterType Initial idea was that I could use the Webpage collector since it supports JSON/BSON parsing. Issue I’m running into is that the values on most of these JSON elements are string (i.e. “true”/”false”). I set up a DataPoint that can extract that value by putting in the JSON Path like so: $.[##WILDVALUE##].[ParameterName&ParameterType] ...and I can see that I’m getting the “true”/”false” values back when I do a Poll Now. But - as we know - LM won’t deal with strings natively. Workaround I came up with was to get length of the string since true/false are different lenghts. According to sources online, JSON Path should support a calculation of string length. I've also verified that I can do this by pasting my data and my JSON Path expression: $.[ComponentName].[ParameterName&ParameterType].length ...into https://jsonpath.com/ In this parser, the .length function works as expected, and returns the length of the JSON value. However, in LogicMonitor, I'm just getting this (example failure): NAN after processing with json (postProcessParam: $.[ComponentName].[ParameterName&ParameterType].length, reference=, useValue=body) Anyone know if there is a way to make this JSON Path length function work?Solved333Views4likes3CommentsCan a website check look for multiple occurrences of a JSON item?
Hi, Normally I have a website that looks through JSON and picks out a pair like Status = Complete. However, I now have a JSON result that includes multiple statuses in one file. I need to be able to parse through all the occurrences of “state” and verify that all of them are either “running” or “completed”. Is there any way to do this through the LM gui? I was told I might have to use a Groovy script, but I don’t know what that is or how it works (not a programmer). If anyone can guide me towards a solution for this, that’d be great. Thanks!45Views2likes0Comments