Skip to content

receiver/httpcheck: add structured validation result metrics#48443

Open
VenuEmmadi wants to merge 7 commits into
open-telemetry:mainfrom
VenuEmmadi:feature/add-validation-target-attribute
Open

receiver/httpcheck: add structured validation result metrics#48443
VenuEmmadi wants to merge 7 commits into
open-telemetry:mainfrom
VenuEmmadi:feature/add-validation-target-attribute

Conversation

@VenuEmmadi
Copy link
Copy Markdown
Member

Description

Adds structured response validation metrics to the HTTP Check Receiver.

Problem: Previously, httpcheck.validation.passed and httpcheck.validation.failed only exposed aggregated counts per validation type, making it difficult to identify which specific validation rule passed or failed when multiple validations were configured for the same endpoint.

Solution: This change introduces a new metric, httpcheck.validation.result, which emits one datapoint per validation rule.

The new metric emits one datapoint per validation rule with the following structured attributes:

Attribute Description Example
validation.type Type of validation performed json_path, contains, regex, size
validation.path The expression being evaluated system_3, healthy, ^ok$
validation.expected Expected value (when equals specified) true, ok, 200
validation.result Pass/fail result of the validation passed, failed

Example Output:

httpcheck.validation.result{
  validation.type="json_path",
  validation.path="system_3",
  validation.expected="true",
  validation.result="failed"
} = 1

This enables users to:

  • Identify exactly which validation failed
  • Query validations by JSON path or validation expression
  • Monitor multiple validations from a single HTTP request
  • Avoid configuring multiple duplicate receivers for the same endpoint

Why this matters: Without this change, a user with the following API response:

{"system_1": true, "system_2": true, "system_3": false}

and multiple validations would only see aggregated validation counts, without visibility into which specific validation failed. The new structured metric makes each validation independently observable.

Backward compatibility: The following legacy metrics continue to work unchanged as aggregate metrics that expose counts grouped by validation type:

  • httpcheck.validation.passed
  • httpcheck.validation.failed

Link to tracking issue

Fixes #44662

Testing

Added unit tests covering:

  • Structured validation result metrics
  • JSON path validation attributes
  • Passed and failed validation scenarios
  • Backward compatibility for legacy metrics
  • Multiple validation types:
    • json_path
    • contains
    • regex
    • size

Verified:

  • One datapoint is emitted per validation rule
  • validation.path correctly identifies the evaluated validation
  • validation.result correctly reports passed/failed state
  • Legacy metrics continue emitting aggregated counts by validation type

Documentation

Updated receiver/httpcheckreceiver/README.md with:

  • Documentation for the new httpcheck.validation.result metric
  • Structured attribute descriptions
  • Example metric outputs
  • Multiple JSON path validation examples
  • Backward compatibility notes for legacy metrics
  • Updated validation configuration examples
  • Clarification for gjson path syntax usage

- Add validation.target attribute to httpcheck.validation.passed and httpcheck.validation.failed metrics
- Emit one datapoint per validation instead of aggregated counts
- Update documentation and tests
- Add new httpcheck.validation.result metric with structured attributes:
  - validation.type: Type of validation (json_path, contains, regex, size, not_contains)
  - validation.path: The expression being evaluated
  - validation.expected: Expected value (when equals specified)
  - validation.result: Passed or failed result
- Keep old httpcheck.validation.passed/failed metrics for backward compatibility
- Fix per-type counting for old metrics (no longer hardcoded to json_path)
- Emit one data point per validation for structured metric
- Add comprehensive test TestValidationResultStructuredAttributes
- Support mixed validation types (json_path, contains, regex, size)
- Update README with examples and documentation
@VenuEmmadi VenuEmmadi requested a review from a team as a code owner May 17, 2026 15:18
@VenuEmmadi VenuEmmadi requested a review from codeboten May 17, 2026 15:18
@github-actions github-actions Bot added the receiver/httpcheck HTTP Check receiver label May 17, 2026
@VenuEmmadi VenuEmmadi force-pushed the feature/add-validation-target-attribute branch from 218e063 to 57f506c Compare May 17, 2026 15:31
- Add new httpcheck.validation.result metric with structured attributes:
  - validation.type: Type of validation (json_path, contains, regex, size, not_contains)
  - validation.path: The expression being evaluated
  - validation.expected: Expected value (when equals specified)
  - validation.result: Passed or failed result
- Keep old httpcheck.validation.passed/failed metrics for backward compatibility
- Fix per-type counting for old metrics (no longer hardcoded to json_path)
- Emit one data point per validation for structured metric
- Add comprehensive test TestValidationResultStructuredAttributes
- Support mixed validation types (json_path, contains, regex, size)
- Update README with examples and documentation
@VenuEmmadi VenuEmmadi force-pushed the feature/add-validation-target-attribute branch from 57f506c to 5ad48a6 Compare May 17, 2026 15:38
monotonic: false
unit: "{validation}"
attributes: [http.url, validation.type]
httpcheck.validation.result:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
httpcheck.validation.result:
httpcheck.validation.outcome:

aggregation_temporality: cumulative
monotonic: false
unit: "{validation}"
attributes: [http.url, validation.type, validation.path, validation.expected, validation.result] No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
attributes: [http.url, validation.type, validation.path, validation.expected, validation.result]
attributes: [http.url, httpcheck.validation.type, httpcheck.validation.path, httpcheck. validation.expected, httpcheck.validation.result]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Lets Keep current names. OTel conventions typically use short, scoped names. validation.type is clear within httpcheck context.

description: The validation expression being evaluated (JSONPath, contains string, regex pattern, size constraint).
type: string
requirement_level: recommended
validation.result:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
validation.result:
httpcheck.validation.result:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Lets Keep current names.

description: The expected value for the validation (when equals is specified).
type: string
requirement_level: recommended
validation.path:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
validation.path:
httpcheck.validation.path:

Or

Suggested change
validation.path:
httpcheck.validation.expression:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Lets use validation.expression - it's more generic and accurate.

description: The result of the validation (passed or failed).
type: string
requirement_level: recommended
validation.type:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
validation.type:
httpcheck.validation.type:
description: Type of validation performed (contains, json_path, size, regex)
type: string
requirement_level: recommended
validation.type:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Lets Keep current names.

description: OSI transport layer or inter-process communication method.
type: string
requirement_level: recommended
validation.expected:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
validation.expected:
httpcheck.validation.expected:

Or maybe

Suggested change
validation.expected:
httpcheck.response.expected:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Lets Keep current names.

Comment on lines +182 to +191
httpcheck.validation.result:
description: Result of a response validation (1 for each validation, with result attribute).
enabled: false
stability: development
sum:
value_type: int
aggregation_temporality: cumulative
monotonic: false
unit: "{validation}"
attributes: [http.url, validation.type, validation.path, validation.expected, validation.result] No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am wondering if we should remove validation.path & validation.expected from a metric due to cardinality & instead complement the metric with an event httpcheck.validation.failure. This event would emit that lower level detail and can add things like error.message.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Lets Keep as is. Cardinality is safe (static config values). Events would make debugging harder for users.

Comment thread .chloggen/httpcheck-validation-result-metric.yaml Outdated
Co-authored-by: James Thompson <thompson.tomo@outlook.com>
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.

httpcheck receiver - Additonal attributes on validation

3 participants