cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Set success conditions for HTTP Monitor

owen_chen
Guide

Hi Everyone,

 

My client wants to regularly check whether some servers are running, so I set up HTTP Monitor to monitor, I only need to set IP: Port, if the status code returns 200, it is normal.

But I have a problem now. Our services are all configured with HA (High Availability), but one of the services has a special mechanism. If Service A is runnable, Service B will temporarily stop, so when I detect Service When B, the response Error code = 15 (Connection timeout).

截圖 2022-09-05 下午3.48.59.png

 

Is there any way to set the HTTP Monitor to one of Service A or B when the status code = 200, the HTTP monitor is considered successful?
I have tried using Script but can't seem to do the above?

 

Thanks,

Owen

9 REPLIES 9

NicolasT
Organizer

Hello,

 

here is an http synthetic (not browser) I made.

I got two web sites (say A and B). My use case :

- I would like to get at least one 200, if A is 200, global status ok, skip B

- If A is anything than 200, I try B

- If B is anything than 200, global status KO.

 

It looks quite similar as your need.

 

{
	"version": "1.0",
	"requests": [
		{
			"description": "https://www.mywebsite.fr/",
			"url": "https://www.mywebsite.fr/",
			"method": "GET",
			"configuration": {
				"acceptAnyCertificate": false,
				"followRedirects": false
			},
			"postProcessingScript": "if (response.getStatusCode() == 200 ) { api.skipNextSyntheticRequest(); } else if ( response.getStatusCode() == 302 ) { api.setValue(\"redirected\",\"1\"); }",
			"requestTimeout": 60
		},
		{
			"description": "https://www.mywebsite.de/",
			"url": "https://www.mywebsite.de/",
			"method": "GET",
			"configuration": {
				"acceptAnyCertificate": true,
				"followRedirects": false
			},
			"postProcessingScript": "if (response.getStatusCode() == 200 ) { api.finish(); } else if ( response.getStatusCode() == 302 && api.getValue(\"redirected\") == 1 ) { api.fail(\"Abnormal HTTP Redirect on two steps\");\n api.finish(); } else { api.fail(\"HTTP Failure on two steps\");\n api.finish(); }",
			"requestTimeout": 60
		}
	]
}

 

@NicolasT Thank you for your reply.

This is a good answer.
However, the result of my test should be because the return code=15 I got, it doesn't seem to be the status code, so I can't enter "response.getStatusCode() !=200".

Thanks again for your reply.

I don't get how to test the return code.

 

But, if you got no response, then you got no status code, so it's null, or 0 or something different from 200 🙂  The test should to the job ? 

 

Hi @NicolasT ,

 

Thank you for your reply.

截圖 2022-09-07 上午10.06.31.png

I tried several conditional expressions with reference to the screenshot above, for example:
response.getStatusCode() is Null
response.getStatusCode() != 200
response.getStatusCode() == 0
But nothing seems to work.

I'm guessing that maybe "healthStatusCode" would be considered a failure if it were a few specific items.

 

Jacek_Janowicz
Dynatrace Champion
Dynatrace Champion

Hi @owen_chen 

If my understanding is correct, from user point of view it is OK when either service A returns 200 or service B returns 200, Is that correct? Going further, I assume that your end users are perhaps not even aware that there are two different services running in HA mode, they just can receive (or not) expected response

 

If all above is true, how about totally different approach?

Instead of monitoring your service A and service B, perhaps you should try to monitor service / URL which is exposed to your final users?

 

Best Regards,

 

Jacek

I agree with this pilosophy. 

Rules for simple monitoring : What is the service furbished to the end users? Is it available or not , how do you simply monitor it?

They don't care at all about the infrastructure layer and if unavailable, in this case, the causation will be trivial to get.

 

Hi @Jacek_Janowicz ,

 

Thank you for your reply.

I agree and have thought about it.

However, when I proposed this idea to my client, he said that because the private network segment where ActiveGate is located does not pass through the DNS server, the Domain name cannot be recognized, which is why I have to detect the A and B servers separately.

However, maybe I should be able to make ActiveGate recognize this Domain name?

 

Thanks,
Owen

If this is a private internal website, you should think about a private activegate with correct access. That will solve your DNS issue.

Hi @owen_chen 

 

Adjusting AG, to be able to recognize domain name is one option of course.

But this case sounds to me like an extra reason for deploying your private location within the same segment of network, as your users. Not only should it solve DNS related problem, but additionally, this way results of synthetic tests will be even more accurate and trustworthy (since tests are executed from the same "place" and with the same network conditions, as applications end users have)

 

Best Regards,

 

Jacek

Featured Posts