I am using heartbeat 6.4.0. I can see that in case of successful connection, unauthorized access, not found it returns http.response.status_code as 200, 401, 404 respectively.
But, in case of errors like below there is response code returned
Get http://xx.xx.xxx.xxx:5000/: dial tcp xx.xx.xxx.xxx:5000: connectex: No connection could be made because the target machine actively refused it.
or
Get http://myurl:90: dial tcp xx.xx.xxx.xx:90: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I have written a service that check the status code to see if the url is up or not. I have not taken into consideration the field monitor.status, because it returns down in case of 401 response code.
How to check the status of a url if there is no status code returned? Is there a way to put a condition that can handle the situations where there are no response code returned ?
Assuming you only want the monitor to report Down only in cases of network failures when there's no status code returned (i.e. response headers never reach the request initiator) , you can put multiple acceptable status codes e.g.
The above monitor will report Up even if host returns 401, 404, 500. Whereas in case of network failure, the request will timeout and monitor will show Down. You can configure the timeout using the timeout property. Hope that helps.
failed to load monitor tasks: can not convert 'object' into 'uint' accessing 'check.response.status' (source:'C:\Program Files\heartbeat-6.4.0-windows-x86_64\heartbeat.yml') when initializing monitor http(0)
I also tried:
check.response:
status: [200, 302, 401]
Error:
failed to load monitor tasks: can not convert 'object' into 'uint' accessing 'check.response.status' (source:'C:\Program Files\heartbeat-6.4.0-windows-x86_64\heartbeat.yml') when initializing monitor http(0)
That error tells the array syntax for status is not supported in v6.4.0. The support starts from v7.7.
If upgrading is not option, you can try something like
check.response:
status: 0
body:
- hello
- world
To provide all the acceptable strings or regex patterns under check.reponse.body that shall put the monitor in an Up state. Caveat would be that 404 cannot be covered as up state in this case. Definitely it's not a scalable solution so upgrade is recommended.
status
The expected status code. If this setting is not configured or it’s set to 0, any status code other than 404 is accepted.
... body
A list of regular expressions to match the the body output. Only a single expression needs to match.
I have checked with multiple urls using the same configuration as above. When the http.response.status_code is any one of 200 or 302 or 401. I am getting monitor.status as up otherwise monitor.status is down.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.