Run Telegraf Controller as a service
Run Telegraf Controller as a managed system service so it starts on boot, restarts on failure, and shuts down cleanly.
Before you begin
Services run non-interactively, so settings that Telegraf Controller normally prompts for must come from the service environment:
- EULA: on the first run on a host, accept the EULA by setting
TELEGRAF_CONTROLLER_EULA=acceptin the service environment. See Review the EULA. - Owner account: if no owner account exists yet, set
OWNER_EMAIL,OWNER_USERNAME, andOWNER_PASSWORDin the service environment, or create the owner in the web interface after the service starts. See Set up the owner account. - Database path: by default, Telegraf Controller stores its SQLite
database inside the running user’s home directory.
For a dedicated service user, set an explicit database path the service
user owns with the
databaseoption. See Manage the database.
Linux (systemd)
Create a dedicated system user and data directory:
sudo useradd --system --create-home --home-dir /var/lib/telegraf-controller telegraf-controllerCreate an environment file:
sudo mkdir -p /etc/telegraf-controller sudo tee /etc/telegraf-controller/env > /dev/null <<EOF TELEGRAF_CONTROLLER_EULA=accept DATABASE_URL=/var/lib/telegraf-controller/sqlite.db EOFCreate a Telegraf Controller service file:
sudo tee /etc/systemd/system/telegraf-controller.service > /dev/null <<EOF [Unit] Description=Telegraf Controller After=network.target [Service] Type=simple User=telegraf-controller EnvironmentFile=/etc/telegraf-controller/env WorkingDirectory=/var/lib/telegraf-controller ExecStart=/opt/telegraf-controller/telegraf_controller Restart=on-failure RestartSec=10 [Install] WantedBy=multi-user.target EOFMove the executable to
/opt:sudo mkdir -p /opt/telegraf-controller sudo mv telegraf_controller /opt/telegraf-controller/ sudo chmod +x /opt/telegraf-controller/telegraf_controllerEnable and start the service:
sudo systemctl daemon-reload sudo systemctl enable telegraf-controller sudo systemctl start telegraf-controller
The systemd journal captures the server log output.
Read it with journalctl -u telegraf-controller.
macOS (LaunchDaemon)
Create a plist file:
sudo tee /Library/LaunchDaemons/com.influxdata.telegraf-controller.plist > /dev/null <<EOF <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.influxdata.telegraf-controller</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/telegraf_controller</string> </array> <key>EnvironmentVariables</key> <dict> <key>TELEGRAF_CONTROLLER_EULA</key> <string>accept</string> </dict> <key>RunAtLoad</key> <true/> <key>KeepAlive</key> <true/> <key>StandardOutPath</key> <string>/var/log/telegraf-controller.log</string> <key>StandardErrorPath</key> <string>/var/log/telegraf-controller.error.log</string> </dict> </plist> EOFAdd other configuration, such as an explicit database path, as additional keys in the
EnvironmentVariablesdictionary.Move the executable to
/usr/local/bin:sudo mv telegraf_controller /usr/local/bin/Load the service:
sudo launchctl load /Library/LaunchDaemons/com.influxdata.telegraf-controller.plist
The server log output goes to the file paths configured in
StandardOutPath and StandardErrorPath.
Windows (NSSM)
Use NSSM (Non-Sucking Service Manager) to run Telegraf Controller as a Windows service.
In Command Prompt or PowerShell, install the Telegraf Controller service:
nssm install TelegrafController "C:\Program Files\TelegrafController\telegraf_controller.exe" nssm set TelegrafController DisplayName "Telegraf Controller" nssm set TelegrafController Description "Web-based Telegraf configuration manager" nssm set TelegrafController Start SERVICE_AUTO_STARTSet environment variables and capture the server log output to files:
nssm set TelegrafController AppEnvironmentExtra TELEGRAF_CONTROLLER_EULA=accept nssm set TelegrafController AppStdout "C:\Program Files\TelegrafController\telegraf-controller.log" nssm set TelegrafController AppStderr "C:\Program Files\TelegrafController\telegraf-controller.error.log"Start the service:
nssm start TelegrafController
Shut down cleanly
Always stop the service through the service manager, for example
systemctl stop telegraf-controller, launchctl unload, or nssm stop,
so the process receives a normal termination signal and can finish writing
to the database.
Killing the process forcefully risks database corruption.
See
Prevent corruption.
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Telegraf Controller and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.