Open-Monitor collects business metrics by scanning business system logs line by line. It uses regular expressions to identify and extract JSON strings from log lines. Once a match is found, the system parses the JSON to extract key-value pairs for metric calculation.
Matching Process:
- The system applies a configured regular expression to each log line.
- It extracts the substring captured by the first set of parentheses
(). - This substring is parsed as a JSON object.
Example:
- Regex:
\[.*\]\[.*\]\[.*\]\[.*\]\[.*\]\[.*\]\[.*\]\[(.*)\]\[.*\] - Log Line:
[INFO][2020-01-01 10:00:00 169][ConsumeMessageThread_9][][20111201A][][][{"costTime":52,"method":"GET","resCode":"200"}][] - Extracted JSON:
{"costTime":52,"method":"GET","resCode":"200"}
Note: You can configure multiple JSON segments, but avoid using duplicate keys across segments as they will overwrite each other.
Regex: \[.*\]\[.*\]\[.*\]\[.*\]\[.*\]\[.*\]\[.*\]\[(.*)\]\[.*\]
Log Line: [INFO][2020-01-01 10:00:00 169][ConsumeMessageThread_9][][20111201A][][][{"costTime":52,"method":"GET","resCode":"200"}][]