{{announcement.body}}
{{announcement.title}}

Getting Anypoint Monitoring to Work With Mule Runtime on a Mac

DZone 's Guide to

Getting Anypoint Monitoring to Work With Mule Runtime on a Mac

While Anypoint Monitoring does not support macOS out of the box, there is a way to get it to work. All you need is to install Anypoint Monitoring agent as per the docs and then use a custom script to run the Anypoint Monitoring agent on your Mac. Read on to see how I got it working on my Mac.

· Integration Zone ·
Free Resource

MuleSoft Anypoint Monitoring is an amazing tool to monitor Mule apps. It works flawlessly as long as it runs within the supported configuration. However, it’s not so fun when you primarily code and test your Mule 4 apps on a Mac. So when I experimented and gotten it to work with my RPi-powered Mule Server, I figured out how to also get Anypoint Monitoring to work with Mule Runtime on a Mac. Because, when it works, the result is glorious.

Anypoint Monitoring working with Mule on a Mac

But before I continue.

Disclaimer:
I’m currently an employee at MuleSoft, a Salesforce company at this point in posting this article. Also, note that this post is a result of my experimentation and is NOT a supported configuration by MuleSoft.

Anypoint Monitoring With Mule Runtime on a Mac

In my previous experimentation, I found out that Anypoint Monitoring essentially uses a filebeat-god (go daemon) binary to run as a service to harvest the logs, and push it to the Anypoint Platform cloud. The default Anypoint Monitoring installation and setup scripts would not completely work since the Mac is not officially supported.

However, the installation and setup script does perform all the other necessary configurations and certificate creations to provide everything that you need to get it working. All we need is to manually start up the filebeat process. Especially since filebeat supports macOS in the first place. So there is no need to even compile your filebeat process from the source code.

Anypoint Monitoring filebeat binary for OSX

Step 1: Install Anypoint Monitoring as per the Docs

Install Anypoint Monitoring as per usual and run the am/bin/install and am/bin/setup scripts too. Do the necessary restart of Mule Server as well as how you would install it as per normal. There are a bunch of configurations that the script will do to prepare the Anypoint Monitoring agent to do what it needs to do. When installing on your Mac, it will not prompt you to install it as a service. When the installation and setup script throws up a bunch of errors, you can just ignore it.

Step 2: Create a Custom Anypoint Monitoring Startup Script

When you run this on Linux, Anypoint Monitoring sets up itself as a service. It also uses a daemonized filebeat-god (god = go daemon) binary instead of the regular filebeat binary. This is because a filebeat is a process that would run continuously in the foreground. So if you kill the shell that where the filebeat process is running, the logs will no longer be harvested.

But since the Mac is primarily my development and test machine, I don’t need a filebeat to run as a service. Instead, we can just use nohup to keep the process running in the background after manually starting up the service. I think that this is a lot easier to manage and debug.

To do so, all we need now is to write a custom Anypoint Monitoring filebeat startup script. The following is the script I wrote. You can name the script with any name you want. I “creatively” named it start_am.sh.

Shell
 




x
12


 
1
#!/bin/bash
2
 
          
3
# Import variables
4
# Edit the MULE_HOME to your mule installation directory
5
MULE_HOME=/opt/mule/mule-enterprise-standalone-4.3.0
6
AM_HOME=${MULE_HOME}/am
7
source ${AM_HOME}/bin/tools/serviceHelper
8
source ${AM_HOME}/bin/tools/message
9
FILEBEAT_DATA=${MULE_HOME}/.mule/.am/filebeat/data
10
FILEBEAT_LOGS=${AM_HOME}/filebeat/logs
11
 
          
12
${AM_HOME}/filebeat/osx/filebeat -strict.perms=false -c ${AM_HOME}/config/filebeat.yml -path.home ${AM_HOME} -path.data ${FILEBEAT_DATA} -path.logs ${FILEBEAT_LOGS}



If you need to just download a copy, here is my start_am.sh script. You will need to allow the file to be executed.

Step 3: Run the Script!

At this point, you’re ready to roll. As mentioned earlier, I just use nohup to keep the filebeat process running even when my terminal screen is killed.

Shell
 




xxxxxxxxxx
1


1
nohup ./start_am.sh &



Using nohup to keep Anypoint Monitoring agent running in the background

Nohup returns the process ID (PID) if you want to know which one to kill. Or you can just use ps aux | grep start_am_osx.sh to find the process as well.

The process ID of the start_am.sh script

So to kill the process, all you need to do is use the kill <pid> command.

Kill the Anypoint Monitoring agent using its process ID

To confirm that Anypoint Monitoring is now running properly on your Mac, head over to the am/filebeat/logs directory, and check the content of the logs. tail -f /opt/mule/mule-enterprise-standalone-4.3.0/am/filebeat/log/filebeat

You should see a bunch of log content as per the screenshot above. When you see the monitoring logs coming through the harvester, all is good!

Anypoint Monitoring Does Play Well With Mule on a Mac!

When it works, it is cool. You can see the series of screenshots below of the Hello-world Mule 4 API that is running on my Mac.

Topics:
anypoint, macos, monitoring, mule, mulesoft, osx

Published at DZone with permission of Ken Ng . See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}