Get metrics from PHP-FPM and fix the truncated field problem


I have many php-fpm socks on multple servers, and i use telegraf with [[inputs.phpfpm]] to send metrics to influxdb.
This work perfectly but … php-fpm himself sets truncated value for “host” field.
As I can’t find a workaround, in telegraf phpfpm input configuration, to override the tag value with a “dynamic” value that could be extracted from the path blob declared in parameter, I would like to know if anyone has ever encountered such a problem or how you’ll solve it.


In telegraf the host tag is usually the hostname of the system telegraf is running on. I do not see a host field in the phpfpm readme. Are you sure this isn’t the hostname of the system?

in telegraf phpfpm input configuration, to override the tag value with a “dynamic” value

You can use the starlark processor to do dynamic transformation of metrics after they are collected.

Sorry, this is not the “host” tag but the “pool” tag.
Thanks for starlark, it’s really interesting.
I use a wildcard in the “urls” parameter of phpfpm input, do you think I can access the exact url i’m on to extract the “pool” that is a folder in this url ?

Not sure I follow. Can you provide an example of what you are seeing and what you hope to achieve?


On each server to monitor, the php fpm sock are organizeded as:


Telegraf input is configured like this:

  urls = ["/var/phpfpm/*/php-fpm.sock:status"]

and sends metrics like that:

phpfpm,pool=mysite.mytoolongdomai accepted_conn=1i,active_processes=1i, [...]

The pool tag is truncated because of php-fpm status itself. I can confirm this when i query the sock with cgi-fcgi : pool is truncated.
So I need to get a full pool value, which is in the full file path of the sock.
Maybe I can get this information using starlark ?

Is the full pool value in any of the cgi-fcgi output?

Are you dropping the URL parameter as well? Looking at the readme I expected to see a URL tag.