Skip to content

httpcheck returns 1 even if http_status_class & http_status_code is not the same #39683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gfelot opened this issue Apr 28, 2025 · 2 comments
Labels
bug Something isn't working needs triage New item requiring triage receiver/httpcheck HTTP Check receiver

Comments

@gfelot
Copy link

gfelot commented Apr 28, 2025

Component(s)

receiver/httpcheck

What happened?

Description

Getting status code from a healthcheck URL with receivers/httpcheck of services that is up return 1 also when http_status_class & http_status_code are not equal.

Steps to Reproduce

receivers:  
  httpcheck: # https://signoz.io/blog/health-check-monitoring-with-opentelemetry/
    collection_interval: 30s
    targets:
      - endpoint: "https://<ip_server>/healthcheck"
        method: GET
        tls:
          insecure_skip_verify: true
[...]
exporters:
  clickhousemetricswrite:
    endpoint: tcp://<signoz_serveur>:9000/signoz_metrics?username=u&password=p
    tls:
      insecure: true
    resource_to_telemetry_conversion:
      enabled: true

Expected Result

When service is up, http_status_code: 200 is sent so only the line with http_status_class: 2xx should be at one.

When I request in clickhouse (SigNoz stack) with

SELECT *
FROM signoz_metrics.time_series_v4
WHERE (metric_name = 'httpcheck_status') AND (JSONExtractString(labels, 'service_name') = 'PASSPORT') AND (JSONExtractString(labels, 'vm_hostname') = '3dx-dev08')
LIMIT 10

I got answer like

Row 3:
──────
env:            DEV
temporality:    Cumulative
metric_name:    httpcheck_status
description:    1 if the check resulted in status_code matching the status_class, otherwise 0.
unit:           1
type:           Sum
is_monotonic:   false
fingerprint:    2470872169406690154 -- 2.47 quintillion
unix_milli:     1745697600000 -- 1.75 trillion
labels:         {"__name__":"httpcheck_status","__temporality__":"Cumulative","deployment_environment":"DEV","health_score":"3","host_name":"FRPAR3DXDEV08","http_method":"GET","http_status_class":"5xx","http_status_code":"200","http_url":"https://<ip_serveur>/3dpassport/healthcheck","os_type":"linux","service_name":"PASSPORT","vm_hostname":"3dx-dev08"}
attrs:          {}
scope_attrs:    {}
resource_attrs: {}
__normalized:   true

I can see unit: 1 and I interprete this as 1.

For exemple in this 2xx check

Row 7:
──────
env:            DEV
temporality:    Cumulative
metric_name:    httpcheck_status
description:    1 if the check resulted in status_code matching the status_class, otherwise 0.
unit:           1
type:           Sum
is_monotonic:   false
fingerprint:    9321289193155664995 -- 9.32 quintillion
unix_milli:     1745697600000 -- 1.75 trillion
labels:         {"__name__":"httpcheck_status","__temporality__":"Cumulative","deployment_environment":"DEV","health_score":"3","host_name":"FRPAR3DXDEV08","http_method":"GET","http_status_class":"2xx","http_status_code":"200","http_url":"https://<ip_serveur>/3dpassport/healthcheck","os_type":"linux","service_name":"PASSPORT","vm_hostname":"3dx-dev08"}
attrs:          {}
scope_attrs:    {}
resource_attrs: {}
__normalized:   true

Actual Result

Getting 1 for 2xx, 0 for 3xx to 5xx.

Collector version

v0.111.39

Environment information

Environment

OS: RedHat 8.10
Compiler: Compilled with go version go1.23.6 (Red Hat 1.23.6-1.module+el8.10.0+22945+b2c96a17) linux/amd64

OpenTelemetry Collector configuration

Log output

Additional context

No response

@gfelot gfelot added bug Something isn't working needs triage New item requiring triage labels Apr 28, 2025
@github-actions github-actions bot added the receiver/httpcheck HTTP Check receiver label Apr 28, 2025
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@AtiX
Copy link

AtiX commented May 19, 2025

Adding onto that, it seems like the metric for http_status_class=2xx and http_status_code=200 still stays at 1 even if the target host returns an error.

What you receive are two data points (e.g. when the service returns a 502 error):

  • http_status_class=2xx and http_status_code=502 = 0 (expected, the status code does not match the status_class)
  • http_status_class=2xx and http_status_code=200 = 1 (unexpected, the service is returning a 502, so the value should not be 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage New item requiring triage receiver/httpcheck HTTP Check receiver
Projects
None yet
Development

No branches or pull requests

2 participants