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

Added support for endpoints in httpcheckreceiver #37265

Merged
merged 15 commits into from
Jan 24, 2025

Conversation

VenuEmmadi
Copy link
Contributor

Description

This PR enhances the httpcheckreceiver by adding support for multiple endpoints (endpoints). Users can now specify a list of endpoints in addition to a single endpoint for each target. This improves flexibility and reduces redundancy when monitoring multiple similar endpoints.

Additional changes include:

  • Updates to config.go to handle endpoints.
  • Updates to scraper.go to iterate over and scrape all specified endpoints.
  • Added unit tests for the new functionality in config_test.go and scraper_test.go.
  • Updated documentation (README.md) to reflect the changes.

Link to Tracking Issue

Fixes #37121

Testing

  • All existing and new tests pass.
  • Tested the httpcheckreceiver manually using the following configuration:
receivers:
  httpcheck:
    collection_interval: 30s
    targets:
      - method: "GET"
        endpoints:
          - "https://opentelemetry.io"
      - method: "GET"
        endpoints: 
          - "http://localhost:8080/hello"
          - "http://localhost:8080/hello"
        headers:
          Authorization: "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqYXZhaW51c2UiLCJleHAiOjE3MzcwMzMzMTcsImlhdCI6MTczNzAxNTMxN30.qNb_hckvlqfWmnnaw2xP9ie2AKGO6ljzGxcMotoFZg3CwcYSTGu7VE6ERsvX_nHlcZOYZHgPc7_9WSBlCZ9M_w"   
      - method: "GET"
        endpoint: "http://localhost:8080/hello"
        headers:
          Authorization: "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqYXZhaW51c2UiLCJleHAiOjE3MzcwMzMzMTcsImlhdCI6MTczNzAxNTMxN30.qNb_hckvlqfWmnnaw2xP9ie2AKGO6ljzGxcMotoFZg3CwcYSTGu7VE6ERsvX_nHlcZOYZHgPc7_9WSBlCZ9M_w"
processors:
  batch:
    send_batch_max_size: 1000
    send_batch_size: 100
    timeout: 10s
exporters:
  debug:
    verbosity: detailed
service:
  pipelines:
    metrics:
      receivers: [httpcheck]
      processors: [batch]
      exporters: [debug]

Documentation

Describe any documentation changes or additions:

<!-- Describe the documentation added. -->
#### Documentation
- Updated the `README.md` to include examples for `endpoints`.
- Verified `documentation.md` for metric output consistency.

@VenuEmmadi VenuEmmadi requested review from codeboten and a team as code owners January 16, 2025 09:32
Copy link

linux-foundation-easycla bot commented Jan 16, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@github-actions github-actions bot added the receiver/httpcheck HTTP Check receiver label Jan 16, 2025
@VenuEmmadi
Copy link
Contributor Author

Hi @codeboten and @mx-psi , I hope you're doing well. When you have some time, could you kindly review and share your feedback on this PR? Your input would be greatly appreciated. Thank you!

Copy link
Contributor

@atoulme atoulme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, some nits.

@VenuEmmadi VenuEmmadi requested a review from mx-psi January 20, 2025 13:08
@VenuEmmadi
Copy link
Contributor Author

Hi @atoulme and @mx-psi, , since this PR is already approved, could you please advise on the next steps to get it merged? Thank you!

@atoulme
Copy link
Contributor

atoulme commented Jan 21, 2025

Next step is a review by the codeowners.

Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @VenuEmmadi, could the endpoint be marked as deprecated? seems unnecessary to have both, this could be done in a separate PR, not necessary to do it here

@VenuEmmadi
Copy link
Contributor Author

Hi @mx-psi, We now have the codeowner's approval also. Could you please proceed to merge the code?
Thanks!

@mx-psi
Copy link
Member

mx-psi commented Jan 22, 2025

thanks @VenuEmmadi, could the endpoint be marked as deprecated? seems unnecessary to have both, this could be done in a separate PR, not necessary to do it here

@VenuEmmadi Before we merge this, could you either file an issue for this or open a PR for this?

@VenuEmmadi
Copy link
Contributor Author

VenuEmmadi commented Jan 22, 2025

thanks @VenuEmmadi, could the endpoint be marked as deprecated? seems unnecessary to have both, this could be done in a separate PR, not necessary to do it here

Hi @codeboten and @mx-psi Thank you for the suggestion regarding marking endpoint as deprecated. However, since endpoint is part of the confighttp configuration, it cannot be deprecated. The httpcheck receiver relies on confighttp, and the endpoint is used indirectly within the configuration structure.

Removing or deprecating it would disrupt the functionality and standard configuration pattern provided by confighttp. As such, we should continue supporting endpoint alongside the new endpoints feature for now.

@codeboten codeboten merged commit 27cab50 into open-telemetry:main Jan 24, 2025
164 checks passed
@github-actions github-actions bot added this to the next release milestone Jan 24, 2025
@codeboten
Copy link
Contributor

Captured an issue around adding a validation check to prevent users from setting the endpoint field here: #37460

chengchuanpeng pushed a commit to chengchuanpeng/opentelemetry-collector-contrib that referenced this pull request Jan 26, 2025
#### Description
This PR enhances the `httpcheckreceiver` by adding support for multiple
endpoints (`endpoints`). Users can now specify a list of endpoints in
addition to a single `endpoint` for each target. This improves
flexibility and reduces redundancy when monitoring multiple similar
endpoints.

Additional changes include:
- Updates to `config.go` to handle `endpoints`.
- Updates to `scraper.go` to iterate over and scrape all specified
endpoints.
- Added unit tests for the new functionality in `config_test.go` and
`scraper_test.go`.
- Updated documentation (`README.md`) to reflect the changes.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to Tracking Issue
Fixes open-telemetry#37121

<!-- Describe what testing was performed and which tests were added. -->
#### Testing
- All existing and new tests pass.
- Tested the `httpcheckreceiver` manually using the following
configuration:
```yaml
receivers:
  httpcheck:
    collection_interval: 30s
    targets:
      - method: "GET"
        endpoints:
          - "https://opentelemetry.io"
      - method: "GET"
        endpoints: 
          - "http://localhost:8080/hello"
          - "http://localhost:8080/hello"
        headers:
          Authorization: "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqYXZhaW51c2UiLCJleHAiOjE3MzcwMzMzMTcsImlhdCI6MTczNzAxNTMxN30.qNb_hckvlqfWmnnaw2xP9ie2AKGO6ljzGxcMotoFZg3CwcYSTGu7VE6ERsvX_nHlcZOYZHgPc7_9WSBlCZ9M_w"   
      - method: "GET"
        endpoint: "http://localhost:8080/hello"
        headers:
          Authorization: "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqYXZhaW51c2UiLCJleHAiOjE3MzcwMzMzMTcsImlhdCI6MTczNzAxNTMxN30.qNb_hckvlqfWmnnaw2xP9ie2AKGO6ljzGxcMotoFZg3CwcYSTGu7VE6ERsvX_nHlcZOYZHgPc7_9WSBlCZ9M_w"
processors:
  batch:
    send_batch_max_size: 1000
    send_batch_size: 100
    timeout: 10s
exporters:
  debug:
    verbosity: detailed
service:
  pipelines:
    metrics:
      receivers: [httpcheck]
      processors: [batch]
      exporters: [debug]
```

#### **Documentation**
Describe any documentation changes or additions:
```markdown
<!-- Describe the documentation added. -->
#### Documentation
- Updated the `README.md` to include examples for `endpoints`.
- Verified `documentation.md` for metric output consistency.

---------

Co-authored-by: Antoine Toulme <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
receiver/httpcheck HTTP Check receiver
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance httpcheckreceiver to Support Nested "endpoints" Under targets
4 participants