Closed schoenm1 closed 11 months ago
Get-Sensor provides two parameters for filtering based on tags
-Tag
which performs a logical OR between all operands-Tags
which contains a logical AND between all operands# Get all sensors that have either tag "foo" or "bar"
Get-Sensor -Tag foo,bar
# Get all sensors that have both of the tags "foo" and "bar"
Get-Sensor -Tags foo,bar
Due PRTG not doing case insensitive comparisons when filtering for "equals", and tags being stored within PRTG as a space delimited string, PrtgAPI does a "contains" query (@sub
) and then applies your wildcard expression to the returned results client side, reducing the response to just the items you were really after.
I was not aware of the @tag
syntax, however I have tested and confirmed that you should be able to apply this filter yourself using the New-SearchFilter
cmdlet (flt
for short)
flt tags eq "@tag(TestGroup,-pingsensor)" | get-sensor
In my test server, TestGroup
returns 24 sensors. 4 of which have the pingsensor
tag, and excluding it correctly returns the other 20 sensors
What's going on?
Hi @lordmilko Your function
Get-Sensor -Tags $mytags
is calling (tested with -verbose) an url with'&filter_tags=@sub(...)'
I'm working with Tags using Tag,+Tag,-Tag example:https://myserver/sensors.htm?filter_tags=@tag(%2BDT:Probe-Device,%2BSLA-Platin,Ping,cpu,memory,%2DNo-Display)
which ishttps://myserver/sensors.htm?filter_tags=@tag(+DT:Probe-Device,+SLA-Platin,Ping,cpu,memory,-No-Display)
=> this will show all Sensors MUST Include "SLA-Platin" and either "DT:Probe-Device" or "Ping" but must not include 'No-Display'. In other words: "NOT No-Display AND SLA-Platin AND (Ping or DT;Probe-Device)" In your functionGet-Sensor -Tags $mytags
the +,- is not allowed When testing with verbose, your function is using '&filter_tags=@sub(...)'and not the '&filter_tags=@tag(...)'
. Is there a possibility to use PRTGAPi for using + and -? Or can I only use:Due Dilligance