PRTG API技术求助:如何筛选带有特定标签的所有设备?
Filtering PRTG Devices by Specific Tag via API
Hey there! I’ve spent plenty of time working with PRTG’s API to pull filtered device data, so let’s walk through exactly how to get devices with a specific tag.
The most flexible endpoint for this task is the table.json API, which lets you query device datasets and apply precise filters. Here’s how to structure your request:
Basic Request Structure
You’ll need to construct a GET request with these key parameters:
content=devices: Tells PRTG you want to retrieve device recordsfilter_tag=<your-tag>: The tag you want to filter devices by (exact match)columns=<fields>: Specify which device details to return (e.g.,objid,name,host,tags)- Authentication: Use
username=<your-username>andpasshash=<your-passhash>(passhash is preferred over plaintext password for security)
Full example URL:
https://your-prtg-server/api/table.json?content=devices&output=json&columns=objid,name,host,tags&filter_tag=production-server&username=prtg-admin&passhash=123456789
Example Testing with Curl
If you want to test quickly from the command line, use this curl command (replace placeholders with your actual data):
curl "https://your-prtg-server/api/table.json?content=devices&output=json&columns=objid,name,tags&filter_tag=production&username=admin&passhash=123456"
Advanced Filtering Options
- Multiple tags (match any): Separate tags with commas to get devices that have at least one of the tags:
filter_tag=production,web-server - Multiple tags (match all): Use a
+(URL-encoded as%2B) to get devices that have all specified tags:filter_tag=production%2Bweb-server - Include subdevices: Add
&show=subdevicesto the request if you want to include child devices under parent groups/devices.
Authentication Notes
To get your passhash:
- Log into PRTG as an admin user
- Go to Setup > Account Settings > My Account
- Copy the value from the "Passhash" field (this is a unique hash for your account, safer to use than your password in API calls)
Troubleshooting Tips
- Double-check the tag spelling: PRTG tags are case-sensitive, so make sure it matches exactly how the tag appears in your device settings
- Verify permissions: Ensure your user account has access to the devices you’re trying to retrieve
- Check for typos in the API endpoint or parameters (common mistakes include missing
content=devicesor incorrect passhash)
内容的提问来源于stack exchange,提问作者Vojta
相关产品推荐
相关产品推荐

