I tried to get a list of tags from sensors, but API returned me a string consists of parent tags and sensor tags.

API request:

https://XXX/api/table.xml?content=sensors&id=6205&columns=objid,device,name,tags&username=XXX&password=XXX

in XML file i have this in tags column - "bandwidthsensor snmptrafficsensor vendors_Cisco voicegw sd-uc-voice UC"

bandwidthsensor snmptrafficsensor - this are sensor tags

vendors_Cisco voicegw sd-uc-voice UC - this are parent tags

Can I get only sensor tags without parent tags somehow?


Article Comments

Hello Vitaliy,

Thank you for your KB-post.

I am afraid that this cannot be changed. When using the column "tags" in API requests, it will always return list of all tags for the object - this includes tags from the object itself plus those inherited from parent objects.

Best regards


Nov, 2018 - Permalink

Hello Isidora! How can i add new tag to sensor via API?


Nov, 2018 - Permalink

Hi Vitaliy,

I am afraid that is not possible by using default API options in PRTG.

However, you might want to try PrtgAPI using Powershell to achieve this.

Best regards


Nov, 2018 - Permalink

You can retrieve the separate Tags and ParentTags of objects using the Get-ObjectProperty cmdlet of PrtgAPI

C:\> Get-Sensor | Get-ObjectProperty | select *tag*

ParentTags    Tags
----------    ----
{Contoso}     {systemhealthsensor}

Regards,

lordmilko


Nov, 2018 - Permalink

Thank you Lordmilko! :)


Nov, 2018 - Permalink