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

**URL:** <https://community.replicated.com/t/use-http-analyzer-to-check-for-a-http-status-code-using-not-equals/1494>\
**Category:** How do I?\
**Created:** [March 6, 2025, 2:34pm UTC](https://community.replicated.com/t/use-http-analyzer-to-check-for-a-http-status-code-using-not-equals/1494 "2025-03-06T14:34:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/brian/32/786_2.png) [@Brian](https://community.replicated.com/u/Brian)\
**Post date:** [March 6, 2025, 2:34pm UTC](https://community.replicated.com/t/use-http-analyzer-to-check-for-a-http-status-code-using-not-equals/1494/1 "2025-03-06T14:34:47Z")

</div>

For a [HTTP Analyzer](https://troubleshoot.sh/docs/analyze/http/) 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?

---

<div class="post-metadata">

**Author:** ![Alex\_Parker](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/alex_parker/32/777_2.png) [@Alex\_Parker](https://community.replicated.com/u/Alex_Parker)\
**Post date:** [March 6, 2025, 7:10pm UTC](https://community.replicated.com/t/use-http-analyzer-to-check-for-a-http-status-code-using-not-equals/1494/2 "2025-03-06T19:10:38Z")

</div>

It looks like you can only compare for equality ([code](https://github.com/replicatedhq/troubleshoot/blob/main/pkg/analyze/host_http.go#L76-L78)).

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

```auto
        outcomes:
          - pass:
              when: "statusCode == 200"
              message: Good
          - fail:
              message: Bad

```

---

<div class="post-metadata">

**Author:** ![johannes](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/johannes/32/789_2.png) [@johannes](https://community.replicated.com/u/johannes)\
**Post date:** [March 6, 2025, 11:49pm UTC](https://community.replicated.com/t/use-http-analyzer-to-check-for-a-http-status-code-using-not-equals/1494/3 "2025-03-06T23:49:38Z")

</div>

We haven’t released it yet, but we just added [support for additional comparison operators](https://github.com/replicatedhq/troubleshoot/pull/1753) 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.

---

<div class="post-metadata">

**Author:** ![johannes](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/johannes/32/789_2.png) [@johannes](https://community.replicated.com/u/johannes)\
**Post date:** [March 11, 2025, 2:44pm UTC](https://community.replicated.com/t/use-http-analyzer-to-check-for-a-http-status-code-using-not-equals/1494/4 "2025-03-11T14:44:32Z")

</div>

This feature is now available in the newest version of Troubleshoot: [Release v0.118.0 · replicatedhq/troubleshoot · GitHub](https://github.com/replicatedhq/troubleshoot/releases/tag/v0.118.0)
