Sitescope Regular Expression "AND" in Content Check? (504 Views)
Reply
Advisor
Joshua_Polier
Posts: 38
Registered: ‎02-23-2011
Message 1 of 5 (504 Views)

Sitescope Regular Expression "AND" in Content Check?

Hello all,

 

I am attempting to configure a URL Content Monitor that will search for two values and return those values as threshold options.  A sample of the text it will be searching for on the page is:

 

{"version":"3.0.0","gauges":{"concurrent.task.engine.ConcurrentTaskEngine.localWorkThreadPoolGauge":{"value":0},
"concurrent.task.engine.ConcurrentTaskEngine.workThreadPoolGauge":{"value":1},
"concurrent.task.shared.LocalWorkQueueHelper.localWorkQueueSizeGauge":{"value":0},
"concurrent.task.shared.WorkQueueHelper.inCompleteTasksGauge":{"value":0},
"concurrent.task.shared.WorkQueueHelper.workQueueSizeGauge":{"value":0}},
"counters":{"concurrent.task.engine.ConcurrentTaskEngine.Work_Processed_This_Hour":{"count":1896},"

 

In this case I am looking to return the values for both localWorkQueueSizeGauge":{"value":0 AND workQueueSizeGauge":{"value":0

 

I would like to save these as value1 and value2 but unfortunately, after the first one is found, it will complete without finding the second value. The expression I'm currently working with is shown below.  I'm aware that "|" is an either/or operator but I'm trying to figure if there is a different operator or way of obtaining both values?

 

/localWorkQueueSizeGauge\"\:\{\"value\"\:(\d*)|workQueueSizeGauge\"\:\{\"value\"\:(\d*)/

 

Any assistance would be greatly appreciated.

 

Thank you,

 

Joshua

Please use plain text.
Respected Contributor
dcsbeemer
Posts: 296
Registered: ‎07-19-2011
Message 2 of 5 (466 Views)

Re: Sitescope Regular Expression "AND" in Content Check?

[ Edited ]

Hi Joshua_Polier

 

 

You can give this a go:

 

/localWorkQueueSizeGauge\"\:\{\"value\"\:([0-9]+)\}[A-z0-9,.:"{}\n]+workQueueSizeGauge\"\:\{\"value\"\:([0-9]+)\}/

 

 

The tricky thing is that you have to take the new line character "\n" into account since the values are not on the same line. You may need to specify "Multi Line Match" as well, but I reckon give the pattern match a try without it first and see if it works.

Please use plain text.
Advisor
Joshua_Polier
Posts: 38
Registered: ‎02-23-2011
Message 3 of 5 (454 Views)

Re: Sitescope Regular Expression "AND" in Content Check?

Unfortunately that results in a Content match error.  I'm currently using this:

 

/localWorkQueueSizeGauge\"\:\{\"value\"\:(\d*).*workQueueSizeGauge\"\:\{\"value\"\:(\d*)/s

 What this does is get the first search, everything in between and then the last search.  The problem with this is that if the order of appearance isn't the same, this will fail.

Please use plain text.
Advisor
Joshua_Polier
Posts: 38
Registered: ‎02-23-2011
Message 4 of 5 (450 Views)

Re: Sitescope Regular Expression "AND" in Content Check?

Now trying this:

 

/WorkQueueHelper\.workQueueSizeGauge\"\:\{\"value\"\:(\d*).*LocalWorkQueueHelper\.localWorkQueueSizeGauge\"\:\{\"value\"\:(\d*)|LocalWorkQueueHelper\.localWorkQueueSizeGauge\"\:\{\"value\"\:(\d*).*WorkQueueHelper\.workQueueSizeGauge\"\:\{\"value\"\:(\d*)/s

 

Allows me to check both directions but the problem comes with the values I'm saving.  If I have to values (localWorkQueueSizeGauge) and (workQueueSizeGauge), I can't guarantee the value for either correlates to the value name.

Please use plain text.
Respected Contributor
dcsbeemer
Posts: 296
Registered: ‎07-19-2011
Message 5 of 5 (435 Views)

Re: Sitescope Regular Expression "AND" in Content Check?

Hi Joshua_Polier


If I understand correctly, the data isn't always in this order:

{"version":"3.0.0","gauges":{"concurrent.task.engine.ConcurrentTaskEngine.localWorkThreadPoolGauge":{"value":0},
"concurrent.task.engine.ConcurrentTaskEngine.workThreadPoolGauge":{"value":1},
"concurrent.task.shared.LocalWorkQueueHelper.localWorkQueueSizeGauge":{"value":0},
"concurrent.task.shared.WorkQueueHelper.inCompleteTasksGauge":{"value":0},
"concurrent.task.shared.WorkQueueHelper.workQueueSizeGauge":{"value":0}},
"counters":{"concurrent.task.engine.ConcurrentTaskEngine.Work_Processed_This_Hour":{"count":1896},"


Does localWorkQueueSizeGauge and workQueueSizeGauge always appear, and if so, does the one always appear before the other?

Depending on how dynamic the data is, this could become a bit tricky. I'd suggest splitting your monitoring up into two, one for localWorkQueueSizeGauge and another for workQueueSizeGauge.

It is possible to monitor both with only one monitor, but that will be quite complicated if the data is as dynamic as I suspect.


The problem with the regex or operator "|" is that as far as I know (and I could be wrong here), you can only use it in-between round brackets, or what you're looking to match. That means that if you definitely want to use one monitor only, you'll need regex similar to this:

/(localWorkQueueSizeGauge\"\:\{\"value\"\:[0-9]+\}[A-z0-9,.:"{}\n]+workQueueSizeGauge\"\:\{\"value\"\:[0-9]+\}|(workQueueSizeGauge\"\:\{\"value\"\:[0-9]+\}[A-z0-9,.:"{}\n]+localWorkQueueSizeGauge\"\:\{\"value\"\:[0-9]+\}/

The problem with that though is that it will essentially return the complete list of data that you're not necessarily interested in, and makes setting thresholds a bit of a nightmare.


I'd definitely recommend using two monitors for this. I'm sure there's probably a simple way of accomplishing this with a single monitor, but unfortunately my regex-kungfu isn't good enough to provide you with any worthwhile advice on how to do it.
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation