Heartbeat check.response.code multiple values

Hi,

We are using heartbeat v6.7.1 on a windows server.

We have a heartbeat request to a login page; which will depending on its cluster state provide a different response code.

if the cluster state for the url is primary then the login url returns a status code 200 and if its not the primary it returns a 503 or 502.

We want to define all the known response codes for what we consider to be “up” (200,502,503) .

Every other response code we want to therefore be “down”.

But the documentation is a bit confusing when it comes to the “check” conditions. We obviously need it to be an OR condition.

I have tried various check condition formats and only success has been when defining a single statuscode check.

The HTTP Check

Which format for the “check” conditions

or:

- equals:

    http.response.code: 200

- equals:

    http.response.code: 502

- equals:

    http.response.code: 503

check.response.status: 200

check.response.status: 502

check.response.status: 503

There doesnt appear to be a way to provide multiple codes like this.( not an integer i know)

check.response.status: 200,502,503

Note : we dont want to be changing the yml everytime someone changes the cluster nodes around.

@Jugsofbeer I agree this could be improved, or at the very least better documented. The conditions there use the standard beats condition processors, which includes a logical or! So, for your use case:

- or:
  - equals:  
      http.response.code: 200
  - equals:
      http.response.code: 502
  - equals:
      http.response.code: 503

should do the trick.

Perhaps we could still improve the experience by having a new type of equality check other than equals. Something like equals_any: {of: [200, 502, 503], in: 'http.response.code' which would be more terse.

Thoughts? CC @ruflin

Hi,

I have re-tried this format and this doesn't actually work.

Adding in this format actually prevents this from executing, it doesnt get far enough to say up or down.

Exact format of what I tried is below.

- type: http
  name: aem-author
  enabled: true
  schedule: '@every 60s' # every 60 seconds from start of beat
  urls: ["https://aem-author.localhost/libs/granite/core/content/login.html?resource=%2F&$$login$$=%24%24login%24%24&j_reason=unknown&j_reason_code=unknown"]
  ipv4: true
  ipv6: false
  mode: any
  method: "GET" 
  timeout: 15s
  - or:
  - equals:  
      http.response.code: 200
  - equals:
      http.response.code: 502
  - equals:
      http.response.code: 503

Your suggestion for an improved equality check seems fine to me.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.