Skip to content
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

[receiver/httpcheck] Add configuration option to prevent following redirections #34623

Open
rogercoll opened this issue Aug 12, 2024 · 5 comments
Labels
enhancement New feature or request receiver/httpcheck HTTP Check receiver

Comments

@rogercoll
Copy link
Contributor

Component(s)

receiver/httpcheck

Is your feature request related to a problem? Please describe.

An HTTP endpoint can return either 307 or 308 as status code when it has been redirected. Let's say I want to monitor a temporal redirection (307) and act upon changes (e.g. end of redirection → 2xx).

For example, the http://wikipedia.com endpoint is redirected to the https://wikipedia.com but I don't want to ensure its reachability but its redirection. Receiver config:

        receivers:
          httpcheck:
            collection_interval: 180s
            targets:
              - endpoint: http://wikipedia.com
                method: GET

The default http client seems to be following redirects, thus getting a 2xx instead:

NumberDataPoints #1
Data point attributes:
     -> http.url: Str(http://wikipedia.com)
     -> http.status_code: Int(200)
     -> http.method: Str(GET)
     -> http.status_class: Str(2xx)
StartTimestamp: 2024-08-12 20:46:16.299435558 +0000 UTC
Timestamp: 2024-08-12 20:47:57.305112135 +0000 UTC
Value: 1
NumberDataPoints #2
Data point attributes:
     -> http.url: Str(http://wikipedia.com)
     -> http.status_code: Int(200)
     -> http.method: Str(GET)
     -> http.status_class: Str(3xx)
StartTimestamp: 2024-08-12 20:46:16.299435558 +0000 UTC
Timestamp: 2024-08-12 20:47:57.305112135 +0000 UTC
Value: 0

Describe the solution you'd like

A config option to define the maximum number of redirects or completely disable them by default.

NumberDataPoints #1
Data point attributes:
     -> http.url: Str(http://wikipedia.com)
     -> http.status_code: Int(200)
     -> http.method: Str(GET)
     -> http.status_class: Str(2xx)
StartTimestamp: 2024-08-12 20:46:16.299435558 +0000 UTC
Timestamp: 2024-08-12 20:47:57.305112135 +0000 UTC
Value: 0
NumberDataPoints #2
Data point attributes:
     -> http.url: Str(http://wikipedia.com)
     -> http.status_code: Int(200)
     -> http.method: Str(GET)
     -> http.status_class: Str(3xx)
StartTimestamp: 2024-08-12 20:46:16.299435558 +0000 UTC
Timestamp: 2024-08-12 20:47:57.305112135 +0000 UTC
Value: 1

For example, Elastic uses the max_redirects configuration options which defaults to 0 (so no redirects are followed, but the status of the redirect is reported)

Describe alternatives you've considered

Adding the configuration option in the confighttp

Additional context

No response

@rogercoll rogercoll added enhancement New feature or request needs triage New item requiring triage labels Aug 12, 2024
@github-actions github-actions bot added the receiver/httpcheck HTTP Check receiver label Aug 12, 2024
Copy link
Contributor

Pinging code owners:

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

@atoulme
Copy link
Contributor

atoulme commented Aug 13, 2024

Sounds good to me. Probably requires to be added to confighttp.

@rogercoll
Copy link
Contributor Author

+1 to add the config option to confihttp (e.g max_redirects)

ref open-telemetry/opentelemetry-collector#10870

@AwsmAshraf
Copy link

Hi,
Is this being worked on? I'm also interested in this feature

@rogercoll
Copy link
Contributor Author

Hi @AwsmAshraf ,

Yes, there is this ongoing PR: open-telemetry/opentelemetry-collector#10877

@atoulme atoulme removed the needs triage New item requiring triage label Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request receiver/httpcheck HTTP Check receiver
Projects
None yet
Development

No branches or pull requests

3 participants