receiver/httpcheck: add structured validation result metrics#48443
receiver/httpcheck: add structured validation result metrics#48443VenuEmmadi wants to merge 7 commits into
Conversation
- 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
218e063 to
57f506c
Compare
- 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
57f506c to
5ad48a6
Compare
| monotonic: false | ||
| unit: "{validation}" | ||
| attributes: [http.url, validation.type] | ||
| httpcheck.validation.result: |
There was a problem hiding this comment.
| 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 |
There was a problem hiding this comment.
| 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] |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
| validation.result: | |
| httpcheck.validation.result: |
There was a problem hiding this comment.
Lets Keep current names.
| description: The expected value for the validation (when equals is specified). | ||
| type: string | ||
| requirement_level: recommended | ||
| validation.path: |
There was a problem hiding this comment.
| validation.path: | |
| httpcheck.validation.path: |
Or
| validation.path: | |
| httpcheck.validation.expression: |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
| validation.type: | |
| httpcheck.validation.type: | |
| description: Type of validation performed (contains, json_path, size, regex) | |
| type: string | |
| requirement_level: recommended | |
| validation.type: |
There was a problem hiding this comment.
Lets Keep current names.
| description: OSI transport layer or inter-process communication method. | ||
| type: string | ||
| requirement_level: recommended | ||
| validation.expected: |
There was a problem hiding this comment.
| validation.expected: | |
| httpcheck.validation.expected: |
Or maybe
| validation.expected: | |
| httpcheck.response.expected: |
There was a problem hiding this comment.
Lets Keep current names.
| 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Lets Keep as is. Cardinality is safe (static config values). Events would make debugging harder for users.
Co-authored-by: James Thompson <thompson.tomo@outlook.com>
Description
Adds structured response validation metrics to the HTTP Check Receiver.
Problem: Previously,
httpcheck.validation.passedandhttpcheck.validation.failedonly 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:
validation.typejson_path,contains,regex,sizevalidation.pathsystem_3,healthy,^ok$validation.expectedequalsspecified)true,ok,200validation.resultpassed,failedExample Output:
This enables users to:
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.passedhttpcheck.validation.failedLink to tracking issue
Fixes #44662
Testing
Added unit tests covering:
json_pathcontainsregexsizeVerified:
validation.pathcorrectly identifies the evaluated validationvalidation.resultcorrectly reports passed/failed stateDocumentation
Updated
receiver/httpcheckreceiver/README.mdwith:httpcheck.validation.resultmetric