hipages / php-fpm_exporter

A prometheus exporter for PHP-FPM.
Apache License 2.0
587 stars 117 forks source link

Escape all string values in broken json from php-fpm status #292

Open jvrsantacruz opened 1 year ago

jvrsantacruz commented 1 year ago

php-fpm status page sends a broken json where string values are not escaped. eg: "user":"myval\srv_monitor"

There is a current fix in place specifically for the request uri field. This pull request extends this fix to all string fields in the JSON response.

The problem with broken JSON is that only with regexes we cannot reliably split the JSON and extract the strings. The strategy is to break down the string to get the values between field names in the form "user":, detect the values that are of type string and apply the same json.Marshall escaping.

Should fix #258 and #291

jvrsantacruz commented 1 year ago

Hi there! :-)

Is there anything else missing in the PR? I'd be more than happy to fix whatever is needed. We're currently using a fork in our production environments and it's not ideal.

Thank you!

jvrsantacruz commented 11 months ago

Hi! :-)

Is there something that I can/need to add to the branch so it can be released?