How to Use the NetBeez API to Display Top 10 Agents with Alerts

By August 4, 2021NetBeez

Another use case for the NetBeez API

I previously wrote a blog post about using the NetBeez API to retrieve ping results. In that example, I show you how you can use the API to gather network latency and packet loss data between one source agent and a destination network or application. That example is useful to prove whether or not the network is impacting the end-user experience with network services or applications.

In this article, I’ll give you another example of how to use the NetBeez API to gather network performance metrics. Here, I will guide you through the procedure to print the top 10 network agents that have triggered the largest number of alerts in the last 24 hours. What is a network agent? An agent can be a dedicated hardware or software appliance deployed on-prem at a remote branch, or a software endpoint that runs on a user’s desktop or laptop (find more information here). This example can be used to identify the network locations or remote users (e.g. WFH employees) that have experienced the highest number of network performance issues.

Working with the NetBeez API

If you’re interested in testing the following code yourself, please review the API get started section of the article that I previously referenced. There you can find all the steps required to set up the necessary variables to make REST API requests to a BeezKeeper instance.

More documentation about the NetBeez API can be found here: and for the legacy API which will eventually be fully replaced by the one just mentioned:

List the top 10 agents with the most alerts.

Let’s first see how we can retrieve all the alerts triggered by the NetBeez agents during the past 24 hours. We’ll then group alerts per agent and count them. After that, we’ll sort them and pick the top 10 agents with the largest number of alerts. Lastly, we enrich the data with the agent names by fetching them through some extra API calls. Let’s get started …

First let’s set the timestamps from and to. In this case I pick from 2021-07-05 to 2021-07-06 …

We then retrieve the alerts using the /n_alerts.jsonb legacy api from swagger.

Then we filter out only the alerts with severity less than 5 (failure alerts have severity 1, and warning alerts have severity 4. When an alert is cleared that event is marked with severity 6). Then count the alerts per agent, and then get the top 10. Please notice that here the agents are referenced by their ID (source_agent_id).

To convert the agent IDs to agent names we then retrieve the agent objects one by one and extract the name strings from those objects.

Finally, we prepare the data for plotting.


I hope this article provided another good example on how to use the NetBeez API to identify users or network locations that are experiencing more issues than others.  The code contained herein is available as a Jupyter Notebook on the NetBeez GitHub account and for a live instance of the notebook, you can check out the nb-api binder link. 

Lastly, are there other examples that you want me to share when using the NetBeez API? Just drop a note in the comments section!