sudofox's journal

Austin Burk's journal, where I share little snippets of my writing, code, and dreams.

Setup: Debugging Mackerel with Fiddler

Hello!

Today I'd like to introduce what I've used to understand how Mackerel communications work with the Mackerel API. It's actually really simple, thanks to the flexibility of mackerel-agent's configuration.

First, I set up Fiddler Web Debugger, a very useful (and free!) tool that I have used for many projects in the past. It serves as a proxy server that you can manipulate and debug traffic with.

Inside your mackerel-agent.conf (I've put mine at the top), put this:

http_proxy = "http://proxy.example.com:8080"
apibase = "http://api.mackerelio.com"

We are removing SSL to get it to proxy properly without doing strange things with installing a self-signed SSL on the system, and then re-adding it with Fiddler.

To do this, let's add the following AutoResponder rule in Fiddler:

f:id:austinburk:20180908002621p:plain

Match: regex:^(ix)http://api.mackerelio.com/(.*)$

Respond with: https://api.mackerelio.com/$1

You can also import this rule by saving the following content into a Fiddler AutoResponder Export file (.farx) and importing it from the AutoResponder menu:

<?xml version="1.0" encoding="utf-8"?>
<AutoResponder LastSave="2018-09-07T11:30:18.2557112-04:00" FiddlerVersion="5.0.20181.14850">
  <State Enabled="true" Fallthrough="true" UseLatency="false">
    <ResponseRule Match="regex:^(?ix)http://api.mackerelio.com/(.*)$" Action="https://api.mackerelio.com/$1" Enabled="true" />
  </State>
</AutoResponder>

Restart mackerel-agent and it will take effect immediately.

Congratulations! Now you can watch mackerel-agent as it talks to the server. You can also (if desired) modify the messages going to Mackerel for testing purposes.

To disable this, simply comment out (prefix with #) or remove the lines in mackerel-agent.conf, and restart mackerel-agent.

I would not recommend sending your Mackerel data (which includes your API key) unencrypted over the Internet, so please do this within your internal infrastructure (private network) only.