The Percona Monitoring and Management (PMM) Amazon Machine Image (AMI) currently lacks native support for ENV variables. In this guide, we’ll walk through a straightforward workaround that simplifies the process of using ENV variables in PMM AMI and reapplying them after an upgrade.
Step one: Adding ENV variables to /srv/.env
Begin by consolidating your ENV variables in the /srv/.env
file. Edit the file and add your variables, like so:
1 2 | PMM_DEBUG=1 DATA_RETENTION=2160h |
Step two: Using systemctl edit
for systemd service
To avoid directly modifying the /usr/lib/systemd/system/supervisord.service
file, which could be overwritten during system upgrades, leverage systemctl edit
for a more sustainable approach. Open a terminal and run:
1 | sudo systemctl edit supervisord.service |
This command opens an editor for creating an override file. Add the following lines to set the environment file:
1 2 | [Service] EnvironmentFile=/srv/.env |
Save and exit the editor.
Step three: Restarting the supervisord service
After applying the changes, restart the supervisord service:
1 2 | sudo systemctl daemon-reload sudo systemctl restart supervisord |
Post-upgrade consideration
While PMM currently rewrites /usr/lib/systemd/system/supervisord.service
on each upgrade, the modifications made using systemctl edit
remain safeguarded.
By adopting the systemctl edit
approach, your ENV variable setup remains intact, offering a cleaner and more maintainable configuration for your PMM AMI.
Percona Monitoring and Management is a best-of-breed open source database monitoring solution. It helps you reduce complexity, optimize performance, and improve the security of your business-critical database environments, no matter where they are located or deployed.
Download Percona Monitoring and Management Today