Ability to manipulate environment variables in config

Hi,

We’re using telegraf to monitor resources provisioned by or on Heroku, like PostgreSQL and Redis. Heroku occasionally performs maintenance on these resources which sometimes means the URLs used to access them change. Heroku will automatically update the application’s environment and restart the app, so it seamlessly picks up the new values. However, this means I have manually go collect the new values Heroku provided and update the telegraf config for the relevant collectors.

I had the great idea that maybe I could just run a telegraf instance as a heroku dyno within each app, which would give it full access to all the environment variables, and would also automatically get updated and restarted when they changed. However, in a couple cases, I’m not able to just use the environment variables as-is.

In the case of redis, Heroku provides an environment variable like:

REDIS_URL='redis://h:password@ec2-54-999-999-999.compute-1.amazonaws.com:12345'

The telegraf redis collector gets grumpy about the redis:// part of the URL, and demands they start with tcp://. As far as I know, there’s no way for me to “gsub” the environment variable as part of the config.

The other is DATABASE_URL for the postgres databases. It looks like this:

DATABASE_URL=postgres://user:pass@ec2-3-999-999-999.compute-1.amazonaws.com:5432/db7oo58bxyzabc

I’d like to be able to “extract” that 14-character database name from the end of the url, and use it in a couple places in the config. First, on the smaller Heroku postgres plans, you share a server with multiple, sometimes hundreds, of other users’ databases. The telegraf collector provides a databases = ["names"] option to only collect from those database names, but since I can’t extract just the name from the URL, telegraf attempts to collects stats for all of those hundreds of dbs, and fills the logs with authentication errors.

Also, I’d like to be able to use the processor.enum.mapping feature to “rename” those ugly database names to match the app they belong to, like $dbname = ${HEROKU_APP_NAME}. This would also require me to be able to extract the dbname from the URL.

Are features like these available in the telegraf config already, and I just haven’t found the documentation? If not, has any one else had a similar feature request that might be implemented?

Thanks!