orangeCatDeveloper opened a new pull request, #4265:
URL: https://github.com/apache/hertzbeat/pull/4265

   ## What's changed?
   
   Fixes #3307.
   
   Custom jsonPath alias fields like 
`$.status.containerStatuses[0].restartCount` returned empty or misaligned 
values. Two independent causes:
   
   1. **Row misalignment** — `HttpCollectImpl` resolved `$.`-prefixed alias 
fields by running one global `parseScript + alias` query and indexing the 
result by row number. Jayway drops rows that miss the path (e.g. a pending pod 
without `containerStatuses`), so every following row received the value of its 
neighbor. Alias paths are now evaluated against each row object directly 
(`JsonPathParser.parseRowWithJsonPath`, missing paths yield an empty list).
   
   2. **Calculates silently swallowed by JEXL** — a calculates entry like 
`rc=$.status.containerStatuses[0].restartCount` happens to compile as a valid 
JEXL array-access expression and evaluates to null without any log. 
`transformCal` now treats an expression that exactly equals one of the metric's 
`aliasFields` as a direct alias reference and skips JEXL. Real formulas (e.g. 
docker's `cpu_delta=$.cpu_stats... - $.precpu_stats...`) still go through JEXL.
   
   Verified before/after on a local instance against a mocked pods API: `[5, 
null, 2]` per pod after the fix, previously all-null. Official `spring_gateway` 
and `docker` templates (which use `[0]`-terminated calculates that survive via 
the JEXL exception fallback) were verified unchanged before/after.
   
   ## Checklist
   
   - [x]  I have read the [Contributing 
Guide](https://hertzbeat.apache.org/docs/community/code_style_and_quality_guide)
   - [ ]  I have written the necessary doc or comment.
   - [x]  I have added the necessary unit tests and all cases have passed.
   
   ## Add or update API
   
   - [ ] I have added the necessary [e2e 
tests](https://github.com/apache/hertzbeat/tree/master/e2e) and all cases have 
passed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to