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

   ## What's changed?
   
   Please refer to: [#3739](https://github.com/apache/hertzbeat/issues/3739)
   
   I sincerely apologize. Since Prometheus's streaming parsing is an iterative 
process, while fixing issue #3739, I focused solely on the current error and 
overlooked subsequent issues.
   
   I reviewed VictoriaMetrics' parsing logic and Prometheus' documentation, 
identifying the following issues with the current streaming parsing:
   
   > Issue 1:Unable to handle '\n\r' at the end of data in special cases.
   ```
   // For details, please refer to: 
lib/protoparser/prometheus/stream/streamparser.go:26
   The VictoriaMetrics Prometheus parser processes data through two primary 
functions:
       - unmarshalRows: Processes multi-row data, splitting by line breaks.
       - unmarshalRow: Processes a single row of data, removing the trailing \r.
   ```
   
   > Issue 2:Prometheus's label semantic parsing is incorrect.
   
   In Prometheus's 
[text-format-example](https://prometheus.io/docs/instrumenting/exposition_formats/?utm_source=chatgpt.com#text-format-example),
 it is explicitly stated: **label_value can be any sequence of UTF-8 
characters, but the backslash (\), double-quote ("), and line feed (\n) 
characters must be escaped as \\, \", and \n, respectively.**
   
   Currently, when processing the following metrics, unexpected results (such 
as exceptions being thrown or parsing errors) may occur. For example:
   ```
   item_create_total{app="item-microservi\"ce-center",value="agent"} 0.0
   item_update_total{app1_="item-microservi\\ce-center",value="agent"} 0.0
   ```
   
   > Issue 3:Prometheus tag parsing cannot handle unknown escape characters.
   ```
   When encountering an unknown escape character, parsing should not be 
abandoned; it should be treated as a regular character (left unchanged), for 
example: label="test\value"
   This is consistent with VictoriaMetrics' processing and resolution: 
lib/protoparser/prometheus/parser.go:420
   ```
   
   ## 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.
   - [ ]  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.
   
   <img width="1397" height="392" alt="Snipaste_2025-09-06_22-13-11" 
src="https://github.com/user-attachments/assets/14b6d20e-0a6e-4a4c-80bd-a5d981bf86de";
 />
   <img width="1439" height="403" alt="Snipaste_2025-09-06_22-13-32" 
src="https://github.com/user-attachments/assets/b2d42c44-864c-458b-a67e-76c8c077b17e";
 />
   


-- 
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: notifications-unsubscr...@hertzbeat.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@hertzbeat.apache.org
For additional commands, e-mail: notifications-h...@hertzbeat.apache.org

Reply via email to