appsignal

Monitor Node.js AMQP Brokers with AppSignal

Connor James

Connor James on

Monitor Node.js AMQP Brokers with AppSignal

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:

Node.js
npm install --save @appsignal/nodejs

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:

Node.js
// appsignal.cjs const { Appsignal } = require("@appsignal/nodejs"); new Appsignal({ active: true, name: "<YOUR APPLICATION NAME>", pushApiKey: "<YOUR API KEY>", }); Once configured, AppSignal will automatically be instrumented to send and receive AMPQ messages. ### Updating AppSignal If you're already monitoring your Node.js app with AppSignal, update the AppSignal package to version 4.3.2 or higher. We recommend updating your package to the latest version: ```shell npm update appsignal@latest

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).

Shell
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.

Screenshot of AppSignal performance overview

We can then delve deeper into the issue and inspect individual occurrences:

Screenshot of performance samples

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:

Screenshot of event timeline

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.

Connor James

Connor James

Official technical writer at AppSignal. Podcast addict who loves cannoli so much that he's considering changing his name to Connoli. He thinks there's a `u` in color. You might find him on the mic, on the stage, or lying on the sofa when he's off Documentation Duty.

All articles by Connor James

Become our next author!

Find out more

AppSignal monitors your apps

AppSignal provides insights for Ruby, Rails, Elixir, Phoenix, Node.js, Express and many other frameworks and libraries. We are located in beautiful Amsterdam. We love stroopwafels. If you do too, let us know. We might send you some!

Discover AppSignal
AppSignal monitors your apps