09-May-2023 23:51
I am checking a server using an API, using curl it succeeds but it takes two steps. First I request a bearer token by sending username and password, I then recieve a token valid for 300 seconds. I then pass that token to the api page and get a reponse with text I can match against for health monitoring. The API wont accept basic auth unfortunately.
I am a bit stuck as to how I can translate this into a health monitor though, if anyone can help it would be appreciated it. I presume I need an external monitor as there would be no way to pass the token as a variable to my post request right?
here is a basic overview from the cli I have trimmed outputs:
Get a token:
curl -k --request POST --url https://192.168.1.1/api/v1/token --data "grant_type=password&username=myusername&password=pass123"
repsonds with:
"access_token":"123mytoken123","token_type":"bearer","expires_in":300"}
Send a second request
curl -kH "Authorization: Bearer 123mytoken123" "https://192.168.1.1/api/v1/serverstatus"
responds with:
{"ThisNode":1,"ServerStatus":"Alive","ServerHasError":false}
10-May-2023 05:24
@Ryan_ This does seem like a good use case for an external monitor. Sadly I am not all that familiar with building them but the following two links might assist you in writing yours.
https://my.f5.com/manage/s/article/K71282813
https://community.f5.com/t5/technical-articles/ltm-external-monitors-the-basics/ta-p/277128