AppSignal's Node.js package now offers out-of-the-box support for the AMQPlib package, enabling monitoring of inbound and outbound messages from popular Advanced Message Queuing Protocol (AMQP) brokers like RabbitMQ.
In this article, we'll show you how to set up and use AppSignal to monitor your AMQP broker's performance.
Setting Up AMQPlib Monitoring
AMQPlib is automatically instrumented in AppSignal's Node.js package. If you're new to AppSignal, you'll first need to install our Node.js package. If you're already monitoring a Node.js application with AppSignal, you'll need to update your Node.js package.
Installing AppSignal
To start monitoring incoming and outgoing AMQP messages, create an AppSignal account and then install AppSignal's Node.js package:
Note: Make sure you're using version 3.4.2 or higher.
Once installed, you'll need to configure, require, and initialize AppSignal with a valid API key. We recommend doing so with an appsignal.cjs
config file:
Monitoring Incoming and Outgoing AMQP Message Performance
Once your app is up and running with a valid version of AppSignal, you'll automatically receive performance insights for incoming and outgoing AMQP messages.
These insights will help alert you when slow performance is potentially impacting your broker's responsiveness.
Spotting Slow Messages with AppSignal
Let's deliberately send a slow message with a RabbitMQ app to demonstrate the insights AppSignal will give you.
In the following method, we send a message to RabbitMQ. To keep things simple, let's use a timeout function that impacts performance (by forcing a request to take five seconds to complete).
app.post("/vip", async (_req: any, res: any, next: any) => { try { setTimeout(() => { res.send(`Roses are red but stroopwafels are gold.`) }, 5000); }, { noAck: true }); } catch (e) { next(e) } })
When we post to /vip
in our Node.js app, AppSignal will identify and report a performance issue. AppSignal even lets us know the impact an issue is having on our application's overall performance, helping us to resolve high-impact issues first.
We can then delve deeper into the issue and inspect individual occurrences:
When reviewing an occurrence, AppSignal's Event Timeline makes it easy for us to understand what the time-intensive requests are. In this case, we know sending a message took the most time, as the Event Timeline shows us a process_request.http
event that lasts for over five seconds:
In a real-life scenario, these insights help us understand where our app is underperformant. We can navigate to the function being called and go straight to our res.send()
function to see if, for example, an inefficient function is impacting our RabbitMQ broker's ability to broadcast messages efficiently. This potentially helps to save us from hours of debugging.
Ready to Get the Most Out of Your AMQP Broker with AppSignal?
AppSignal has all of the tools developers need to monitor their Node.js AMQP brokers proactively, from anomaly detection to logging. Our developer-friendly UI gives you all of the insights you need to code with confidence.
Read our AMQPlib monitoring page and AMQPlib docs for more information.
Something unclear? Our support team is on hand to answer all your monitoring questions.