Getting Anypoint Monitoring to work with Mule Runtime on a Mac
As I’ve written in my last post, 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.

But before I continue.
<Disclaimer>
I’m currently an employee at MuleSoft, a Salesforce company at this point of posting this article. Also, note that this post is a result of my own experimentation and is NOT a supported configuration by MuleSoft.
</Disclaimer>
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 really 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 own filebeat process from the source code.

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.
Note that I’ve installed Mule at /opt/mule/mule-enterprise-standalone-4.3.0. Also, I’m assuming that your Mule server is already running.
cd /opt/mule/mule-enterprise-standalone-4.3.0 wget https://s3.amazonaws.com/cdn-anypoint-prod/artifacts/monitoring-center-ui/app/hybrid/am-2.2.3.0.zip unzip am-2.2.3.0.zip cd am ./bin/install /opt/mule/mule-enterprise-standalone-4.3.0/bin/mule restart ./bin/setup
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 daemonised filebeat-god (god = go daemon) binary instead of the regular filebeat binary. This is because 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 really need 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 personally 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.
#!/bin/bash # Import variables # Edit the MULE_HOME to your mule installation directory MULE_HOME=/opt/mule/mule-enterprise-standalone-4.3.0 AM_HOME=${MULE_HOME}/am source ${AM_HOME}/bin/tools/serviceHelper source ${AM_HOME}/bin/tools/message FILEBEAT_DATA=${MULE_HOME}/.mule/.am/filebeat/data FILEBEAT_LOGS=${AM_HOME}/filebeat/logs ${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.
sudo chmod +x start_am.sh
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.
nohup ./start_am.sh &

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.

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

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 really cool. You can see the series of screenshots below of the Hello-world Mule 4 API that is running on my Mac.



In Conclusion
Never let unsupported configurations hold you back. The whole point of an open platform like Elastic is that you can always find a way to get it working. 😆 Plus, a little bit of vi <installation/setup file> can be insightful most of the time.
Again. Do note that this is not a supported configuration by MuleSoft. Therefore, do this as your own “risk”.
Recommended Reading
As I mentioned earlier, I have also gotten Anypoint Monitoring to work with Mule running on the ARM-based Raspberry Pi! Read it here to find out how you can also do the same.

You can also check out more MuleSoft related posts here on my MuleSoft Cookbook section.