# How to create custom HTTP monitors with Postman, curl, and Python

**URL:** <https://community.f5.com/t/how-to-create-custom-http-monitors-with-postman-curl-and-python/66388>\
**Category:** F5 Technical Articles\
**Tags:** big-ip, devops, ltm, application-delivery\
**Created:** [June 1, 2016, 4:35pm UTC](https://community.f5.com/t/how-to-create-custom-http-monitors-with-postman-curl-and-python/66388 "2016-06-01T16:35:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_Chen](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/eric_chen/32/8369_2.png) [@Eric\_Chen](https://community.f5.com/u/Eric_Chen)\
**Post date:** [June 1, 2016, 4:35pm UTC](https://community.f5.com/t/how-to-create-custom-http-monitors-with-postman-curl-and-python/66388/1 "2016-06-01T16:35:51Z")

</div>

The following is a guide on how to monitor your service/microservices using Postman, curl, and Python. BIG-IP enables you to monitor your applications health by creating monitors that emulate your end-user clients. When creating a monitor for API services it can be useful to use the Postman Chrome App to create these monitors.

## Monitoring 101

If you’ve gone through the process of creating a custom HTTP monitor you’re familiar with the process of creating the correct “Send String” to use in the monitor. [SOL2167](https://support.f5.com/kb/en-us/solutions/public/2000/100/sol2167.html) has some examples including the following for a HTTP/1.1 post request:

> ```auto
> POST /form.cgi HTTP/1.1\r\nHost: host.domain.com\r\nConnection: Close\r\n\r\nFirst=Joe&Last=Cool
> 
> ```

A previous DevCentral article “[HTTP Monitoring with POST Request](https://devcentral.f5.com/s/articles/ltm-http-monitoring-with-post-request)” dives into the details of building the request from scratch, but this can be a bit intimidating. Instead we’re going to use the Postman Chrome App to build the requests.

## An alternate way to build a monitor

The Postman Chrome App is a useful add-on for the Google Chrome browser that enables a developer to troubleshoot/test APIs. Features include the ability to modify arbitrary HTTP headers and inspect responses from endpoints.

The first step to building a monitor is to use Postman to construct the request. In the following example I’m sending a request to a simple REST API (httpbin, Python application very useful for testing). In this case I’m sending a POST request with a custom User-Agent to distinguish the monitor from other clients. I’m also specifying a “Accept-Encoding” header to avoid getting back a compressed response and setting the “Connection” header to “Close” to avoid lingering TCP connections on the server.

![image_281978.png](https://d20hrnpixdzcsd.cloudfront.net/original/2X/6/6a0095cf2d35de3e3ea9fd0718d9d1ed1465940f.png)

The body of the request contains a JSON payload that includes some newline characters:

![image_281978.png](https://d20hrnpixdzcsd.cloudfront.net/original/2X/9/95ad835d2e32ef5aef0bfbb59b1a4d95a0bc3bfb.png)

Once I click “Send” in Postman I can see the response from the server. In this case httpbin also sends the headers back to the client in the response:

 ![image_281978.png](https://d20hrnpixdzcsd.cloudfront.net/original/2X/f/f9c23fe27093893dec6f2c3ef878f76e777d4f27.png)

## Creating the new monitor with Python

Now that I have a working request/response I need to convert this into a BIG-IP monitor. The first step is to change the Postman settings to remove the no-cache/Postman Token header (additional headers that are not required). The updated settings look like the following:

 ![image_281978.png](https://d20hrnpixdzcsd.cloudfront.net/original/2X/5/531c76f7c0dffec7941b5d614d1250369977c44e.png)

Once this is complete click on the “Generate Code” link and select “curl” as the output.

![image_281978.png](https://d20hrnpixdzcsd.cloudfront.net/original/2X/6/6690e0d2a96c32ed51246e47bbb60bfec9f564e9.png)

Click on the “Copy to Clipboard” and connect to your BIG-IP via the shell and run the command to verify that your new monitor will also work from the BIG-IP.

 ![image_281978.png](https://d20hrnpixdzcsd.cloudfront.net/original/2X/8/818b4de47cc4988c0c6d33cd2acaee2204f4e1b7.png)

Once this is done you can either:

a. Change the output to HTTP and do some finangling to replace newline characters and quote strings

b. Run my Python script from [CodeShare](https://devcentral.f5.com/s/articles/convert-curl-command-to-big-ip-monitor-send-string) that converts the curl input to a BIG-IP monitor Send String

For option b.

After you install the Python script from [CodeShare](https://devcentral.f5.com/s/articles/convert-curl-command-to-big-ip-monitor-send-string) (in this case it is running on the BIG-IP, but you could also run this on your local computer or another server that has Python 2.x available). In this example I replace “curl” with “python curl\_to\_send\_string.py”.

![image_281978.png](https://d20hrnpixdzcsd.cloudfront.net/original/2X/5/58e1c72d7ca37a2ba6c5daf5aec2397b52fb1175.png)

Take the output from the script and enter it as the Send String on the BIG-IP

![image_281978.png](https://d20hrnpixdzcsd.cloudfront.net/original/2X/2/29508e78e6255b48ccb7600c5c4dea90c3af6149.png)

Attach the new monitor to your pool and you should be all set. This same method can also be applied to an HTTPS monitor as well.

## Applying the monitor

Putting this all together with a Local Traffic Policy you can serve up RESTful APIs that can monitor the health of the supporting services behind it.

The following example is creating a separate policy for requests that start with v1 vs. v2 and sending these to separate pools with monitors that track the health of the service.

 ![image_281978.png](https://d20hrnpixdzcsd.cloudfront.net/original/1X/ecab1102b55eb3cdeb719f1f140ec9400ae8cb15.png)

From the Network Map you can quickly check on the health of services that are behind an API endpoint.

 ![image_281978.png](https://d20hrnpixdzcsd.cloudfront.net/original/2X/f/fd0a6ca0bc7e1e248f5cfb5642ac9d844ea113f3.png)

## Distributed Systems are Hard

Microservices provide many values for decoupling monolithic systems into more manageable slices, but can lead to an increase in complexity and obscuring of issues. Using BIG-IP and monitors can help reduce the headache of tracking down issues and make it easier to keep your systems up and customers happy.
