Use HTTP Analyzer to check for a HTTP Status Code using not equals

For a HTTP Analyzer I can check for an client side error or a specific http status code, using pass: "statusCode == 200" for example, but if I try to check for anything except a specific status code, i.e. pass: "statusCode != 200" then the analyzer doesn’t work at all. Is there a way to do a not equals logical operator and I’m just doing it wrong, some other way of accomplishing this with the HTTP Analyzer, or is it just not supported?

It looks like you can only compare for equality ([code](t looks to me like you can only compare equality. troubleshoot/pkg/analyze/host_http.go at main · replicatedhq/troubleshoot · GitHub)).

If you want a catchall case, you can generally put that last without a when condition. So you could do something like this:

        outcomes:
          - pass:
              when: "statusCode == 200"
              message: Good
          - fail:
              message: Bad
1 Like

We haven’t released it yet, but we just added support for additional comparison operators for status codes in the HTTP Analyzer: ==, !=, >=,>, <=,<

We also added support to chain expressions with “||” and “&&”. For example, you could use the following expression to test for any 2xx code: statusCode => 200 && statusCode <= 299

This will be available in the next troubleshoot release.

1 Like

This feature is now available in the newest version of Troubleshoot: Release v0.118.0 · replicatedhq/troubleshoot · GitHub