What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

API Filter

Votes:

0

I'm looking for help using multiple filters in my API call. For example, I can filter by "Group-A," but I'm not sure how to filter for "Group-A" and "Group-B. Please see below

   api_url = "https://server/api/table.xml?content=sensors&columns=objid,group,device,sensor,status,uptimetime,uptime,knowntime&apitoken=KEY"

query = {'filter_type':'ping','filter_group':'GROUP-A'}

response = requests.get(api_url, verify=False, params=query)

api filter prtg

Created on May 17, 2023 8:59:11 PM

Last change on May 23, 2023 12:48:43 PM by  Ricardo Sanchez [Paessler Technical Support]



5 Replies

Votes:

0

Hello Dear customer,

Thank you for contacting PRTG support.

To filter for multiple groups in your API call using the PRTG API, you can make use of the filter_group parameter with multiple values separated by a comma. Here's an example of how you can modify your code to filter for both "Group-A" and "Group-B":

{{{import requests

api_url = "https://server/api/table.xml?content=sensors&columns=objid,group,device,sensor,status,uptimetime,uptime,knowntime&apitoken=KEY"

query = {'filter_type': 'ping', 'filter_group': 'GROUP-A,GROUP-B'}

response = requests.get(api_url, verify=False, params=query)}}}

In the filter_group parameter, you can provide a comma-separated list of the groups you want to filter for. In the example above, it filters for both "Group-A" and "Group-B". You can modify the list to include any additional groups you require.

Make sure to replace 'GROUP-A' and 'GROUP-B' with the actual names of the groups you want to filter. Also, ensure that the API token (KEY) is properly replaced with your actual PRTG API token.

This modified code will retrieve the sensors that belong to either "Group-A" or "Group-B" based on the provided filter criteria.

Created on May 23, 2023 12:48:19 PM by  Ricardo Sanchez [Paessler Technical Support]

Last change on May 23, 2023 12:50:45 PM by  Ricardo Sanchez [Paessler Technical Support]



Votes:

0

I tried to added multiple groups into the parameter, but it's not working. Do I need to format the list differently?

C:\Users\name\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py:1095: InsecureRequestWarning: Unverified HTTPS request is being made to host 'prtg.domain.local'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
  warnings.warn(
<?xml version="1.0" encoding="UTF-8"?>
  <sensors totalcount="0" listend="1">
   <prtg-version>23.2.83.1760</prtg-version>
  </sensors>

Created on May 23, 2023 4:23:46 PM

Last change on May 24, 2023 6:16:18 AM by  Felix Wiesneth [Paessler Support]



Votes:

0

Hello

I have checked this internally and as we use API v1 it is not possible to use multiple filters in an API call

Regards

Created on May 24, 2023 2:31:35 PM by  Ricardo Sanchez [Paessler Technical Support]



Votes:

0

Is there documentation for API v2? I have API v2 activated. I assumed that I was using API v2.

Created on May 24, 2023 3:55:03 PM



Votes:

0

Hello

Thank you for your response,

There are some documents here for you to check about APIv2:

If you have any questions please let us know

Regards

Created on May 26, 2023 2:16:43 PM by  Ricardo Sanchez [Paessler Technical Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.