Free up to 1MM monthly messages. No credit card required.
It’s important to keep tabs on your running PubNub Functions, monitoring their state and health. PubNub provides structural integrity for applications of any scale, but there could be times where the code within the Function does something you didn’t intend, so we’ve developed a tool that allows you to monitor those irregularities.
The Function monitoring tool is a Python script that monitors all of your event handlers and displays alerts/notifications in the terminal. This is beneficial because you can easily add all of your logs of this system to Elasticsearch via the remote server running the monitor. This will enable services like Kibana, Grafana, and PagerDuty – which in turn covers logging, metrics, and alerts for the on-call engineering team.
First, we’ll start off by cloning the project.
git pull https://github.com/bigoper/pubnub-monitoring-functions.git master
Once we have that, go into the pfunc-monitor
folder.
cd pfunc-monitor
Now install all the dependencies.
sudo pip install -r requirements.txt
Great! Now let’s add our credentials for PubNub.
python app.py --user=YourEmailAddress --password='yourPassword'
If your login is correct, the terminal should print out Success.(1)
. Once you receive that, you can run the script and let it listen for any notifications that come in from your Functions.
python app.py
Now if anything comes up, you’ll see it in your terminal!
It’s important to understand the different layers of a PubNub Function, which in turn gives us a better understanding of the different channels it makes on startup.
Looking at the diagram below, you can see the different apps we’ve created in our PubNub account. Inside those apps, we have keysets that are linked to those apps. Each keyset then has their own modules, and finally, within those modules, we have our Functions.
This is really important for understanding our code, since from a debugging perspective, we are subscribing to channels related to each piece in the hierarchy.
Let’s see how this would look in our Admin Dashboard.
You can see in the console that we have three different channels that we connect to.
The first on is “*”, which is the same channel that the Function is listening on. The next two are a bit more unique. They are related to the hierarchy and are channels that are publishing events that are taking place and allow for the debugging. The monitoring tool subscribes to these three channels and prints out the different messages being published.
A roundtable discussion led by PubNub’s COO, Casey Clegg, exploring the topics of what it means to be human in a virtual world.
PubNub Staff
Dr. Joe Kvedar, Chair of the Board for the American Telemedicine Association, joins our COO, Casey Clegg, to discuss why...
PubNub Staff
Today, we are glad to announce that we are currently in the process of implementing ISO-27001 security standards.
PubNub Staff