How to use Solace HybridEdge to integrate with Slack

Use HybridEdge to Monitor Your Solace PubSub+ Broker and Integrate With Slack

Monitoring system activity is one of the most critical aspects of system operations. Real-time monitoring of your infrastructure is vital – as an operator or system administrator, you want to be notified about any events regarding system health so that appropriate measures can be taken to fix issues in a proactive fashion.

Solace message brokers generate a wide variety of events and metrics for monitoring by using open interfaces such as Syslog and SEMP, and these need to be integrated with your existing enterprise monitoring tool for alerting purposes.

Note: My previous post shows you how to integrate Solace with your enterprise monitoring system using Syslog.

Based on my experience in the field, such monitoring integrations generally are slow to implement, are not prioritized as much as setting up functionality, and an operations team may not be exposed to the variety of information available for monitoring system activity.

Solace HybridEdge

HybridEdge diagram with public cloud, private cloud and on-premise

Solace HybridEdge is a standalone Java Spring application built around Apache Camel that allows you to integrate Solace message brokers with other messaging systems, such as RabbitMQ, ActiveMQ, IBM MQ and Kafka, in a standards-based fashion. Apache Camel is a mediation framework built to solve the problem of enterprise application integration.

Integrating enterprise systems is challenging because they may communicate using:

  • different message formats,
  • different transports; and,
  • require translation/routing/aggregation.

Apache Camel is a powerful open source framework, based on the well-known Enterprise Integration Patterns, that enables the integration of different enterprise systems. It is a modular framework consisting of a number of components – each acting in an abstraction layer for integrating with a particular enterprise system.

Solace has built an Apache Camel component, which you can use in your Camel application as a producer or consumer of Solace messages. For more information on HybridEdge, check out this video:


The primary use cases for HybridEdge are to integrate Solace messaging running in public clouds, private clouds, or enterprise data centres with other legacy messaging systems. Among these, HybridEdge can also be used to solve other common customer problems.

In this post, I’ll show you how to quickly set up HybridEdge to monitor your Solace PubSub+ broker so that from Day 1 you have basic monitoring and alerting of your Solace PubSub+ instance.

Overview

I’m going to use HybridEdge to monitor Solace system-level events and integrate them with Slack. Slack is a popular instant messaging platform that is used widely for team collaboration. I’ll then set up the integration using absolutely no coding whatsoever – just some simple configuration changes. To do this, you’ll need a system which has:

  • Java Runtime Environment (JRE);
  • network access to the Solace PubSub+ broker you want to monitor; and,
  • Slack.

You do not need a developer environment or build tools such as Gradle or Maven.

Keep in mind that Solace PubSub+ message brokers generate Syslog messages to record events occurring on the platform. These include:

  • routine operations, such as creation and deletion of message-vpns and queues;
  • warning conditions, such as a queue reaching its spool quota or a message-vpn reaching maximum client connections; and,
  • emergency or critical conditions, such as a routing blade taken offline due to excessive temperature.

In addition, Solace message brokers can be configured to generate and publish these events over the message bus to well-known topics. Monitoring applications can subscribe to these topics and be asynchronously notified when a new event is generated.

Let’s configure HybridEdge to subscribe to these monitoring events generated over the message bus and post them to Slack for alerting.

For this tutorial, we are going to listen on System level events only, although these can also be extended to message-vpn level events.

The HybridEdge application will:

  1. use the Solace component to subscribe to monitoring events published on the PubSub+ broker over the message bus;
  2. inject these messages to the Slack component; and,
  3. the Slack component will post these messages to a Slack channel to generate an alert.

Optionally, you can add a processor in step 2. to customize the content of your alert message, but for this demonstration, I will keep things simple and post the event message as-is.

Configuring Event publishing over the message bus

In order to configure event publishing over the message bus, run the following commands as a CLI admin user on your PubSub+ broker:

solace> enable
solace# configure
solace(configure)# logging event
solace(configure/logging/event)#
solace(configure/logging/event)# publish-system
solace(configure/logging/event)# system-tag SOLSG1
solace(configure/logging/event)# end

Create a new message-vpn and set the authentication scheme to “internal” as this is a demo. Designate it as the management message-vpn. This is where the system events will be published to:

solace# configure
solace(configure)# create message-vpn <vpn-name>
solace(configure/message-vpn)# authentication user-class client
solace(...message-vpn/authentication/user-class)# basic auth-type internal
solace(...message-vpn/authentication/user-class)# exit
solace(configure/message-vpn/authentication)# exit
solace(configure/message-vpn)# no shutdown
solace(configure/message-vpn)# exit
solace(configure)# management-message-vpn <vpn-name>

Create a client username on the message-vpn to enable client access:

solace(configure)# create client-username <username> message-vpn <vpn-name>
solace(configure/client-username)# password <password>
solace(configure/client-username)# no shutdown
solace(configure/client-username)# exit

The event messages are published on a predefined topic:

#LOG/<level>/SYSTEM/<routerName>/<eventName>

For simplicity, in this example I am going to use HybridEdge to subscribe to “#LOG/>” to receive all the System events at all Severity levels.

Note: This integration will not work with messaging services created on Solace PubSub+ Cloud, as you cannot connect to or configure the management message-vpn on PubSub+ Cloud.

Configuring an Incoming WebHook on Slack

In order to enable HybridEdge to post messages to Slack, you need to configure an Incoming WebHook URL. For more information, refer to the Slack documentation.

When defining the WebHook, you can define the Slack channel to POST message to when using the WebHook.

Once configured, your WebHook URL will look like this:

https://hooks.slack.com/services/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

Test that you can use the WebHook URL to POST messages to Slack using the following cURL command:

curl -X POST --data-urlencode "payload={\"channel\": \"#general\", \"username\": \"webhookbot\", \"text\": \"This is posted to #general and comes <strong>from</strong> a bot named webhookbot.\", \"icon_emoji\": \":ghost:\"}" https://hooks.slack.com/services/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

This command should post a test message to the #general channel. You can modify the channel parameter as required.

Configuring HybridEdge

First, download the HybridEdge package from the Solace Developer Portal. Once downloaded, extract the contents of the zip archive. The extracted directory should have the following contents:

elnino:HybridEdge-1.0.0 srajgopalan$ ls -lrt
total 48912
drwxrwxr-x@ 3 srajgopalan  staff       102 Mar 27 14:03 jars
drwxrwxr-x@ 8 srajgopalan  staff       272 May 15 16:14 samples
-rw-rw-r--@ 1 srajgopalan  staff       823 May 15 16:14 log4j2.xml
-rw-rw-r--@ 1 srajgopalan  staff     10178 May 16 10:59 README.html
drwxrwxr-x@ 6 srajgopalan  staff       204 May 17 09:31 licenses
-rwxrwxr-x@ 1 srajgopalan  staff       152 May 17 09:31 run
-rw-rw-r--@ 1 srajgopalan  staff  25021926 May 17 09:31 hybrid-edge-1.0.0.jar

In order to use the Camel Slack component, we require the ‘camel-slack’ library as well as all its dependencies. Since we are using the HybridEdge runtime, we need to manually download and add these libraries to the “jars” directory:

camel-slack-2.21.1.jar
httpclient-4.5.5.jar
httpcore-4.4.9.jar
json-20180130.jar
jaxb-impl-2.2.11.jar
jaxb-core-2.2.11.jar
commons-codec-1.9.jar
commons-logging-1.2.jar
junit-4.10.jar
hamcrest-core-1.1.jar
json-simple-1.1.1.jar

These libraries can be downloaded from the Maven repository.

Once the third party libraries have been downloaded and placed in the “jars” directory, copy the application.properties file from the ‘samples’ directory and place it in the HybridEdge home directory.

Modify the file to enter the details of the Solace PubSub+ broker that you want to monitor and your Slack WebHook URL.

Set the property  “spring.main.sources” to slack.xml, which we will create in the next step. In addition, set the Solace JMS property “solace.jms.directTransport” to true, as we want HybridEdge to receive the event messages using the direct transport.

# Solace Credentials
solace.jms.host=&lt;enter broker ip&gt;
solace.jms.msgVpn=&lt;enter message-vpn name&gt;
solace.jms.clientUsername=&lt;enter client user name&gt;
solace.jms.clientPassword=&lt;enter password&gt;
solace.jms.directTransport=true
# Camel/Spring config files should be listed here.
spring.main.sources=slack.xml
# Required so that Camel will keep running
camel.springboot.main-run-controller=true
# Slack
slack.webhookUrl=<enter webhook url>

Finally, create the Camel/Spring config file in the HybridEdge install directory:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:c="http://camel.apache.org/schema/spring"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

<bean id="slack" class="org.apache.camel.component.slack.SlackComponent">
<property name="webhookUrl" value="${slack.webhookUrl}"/>
</bean>

<c:camelContext>

<c:route>
<c:from uri="solace-jms:topic:#LOG/>"/>
<c:to uri="slack:<channel-name>?iconEmoji=:ghost:&amp;amp;username=Cool Solace Alerts"/>
</c:route>

</c:camelContext>

</beans>

Enter the Slack channel name if different from what was configured in the WebHook configuration.

We have defined a Camel route in our application.properties that will receive messages from Solace on the topic “#LOG/> and post them to the Slack component using the WebHook URL defined.

Running the application

You’re all set! In order to run the HybridEdge application, execute the run script:

$ ./run

On successful startup, you should see this log message:

17:41:48.998 [main] INFO  com.solace.hybrid_edge.Application - Started Application in 5.448 seconds (JVM running for 6.581)

Simulating System Events

You can simulate a system event by simply logging into the PubSub+ broker via CLI – you should immediately get a Slack notification on your channel. For example, here is an alert for a system login that was denied:

HybridEdge Slack system alert notification

Summary

Over the course of this blog post, you have set up HybridEdge to monitor system events on a Solace message broker, redirected the events to a Slack channel, and established basic monitoring of your Solace PubSub+ instance. This was achieved using the HybridEdge runtime and modifying the Camel/Spring configuration.

If you want to get your hands dirty, download the HybridEdge Starter project from GitHub to write your own custom message processor and define more complex routes.

As next steps, you can optionally add a Camel processor class if you want to format the message displayed on Slack.

In a future blog post, I will show you how you can set up Email notification of Solace system events.

Please feel free to leave me any comments regarding this example, or comments for the entire community. If you have any issues sending and receiving a message, check the Solace community Q&A for answers to common issues.

Further Reading