diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fe92de24606..45c74f523c4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ Main (unreleased) `prometheus.exporter.cadvisor` (flow mode) and the `cadvisor` integration (static mode). (@hainenber) +- Grafana Agent on Windows now automatically restarts on failure. (@hainenber) + ### Bugfixes - Permit `X-Faro-Session-ID` header in CORS requests for the `faro.receiver` diff --git a/packaging/grafana-agent-flow/windows/install_script.nsis b/packaging/grafana-agent-flow/windows/install_script.nsis index 011e6b59c121..a333807c1196 100644 --- a/packaging/grafana-agent-flow/windows/install_script.nsis +++ b/packaging/grafana-agent-flow/windows/install_script.nsis @@ -97,6 +97,10 @@ Section "install" # Start the service. nsExec::ExecToLog 'sc start "Grafana Agent Flow"' Pop $0 + + # Auto-restart agent on failure. Reset failure counter after 60 seconds without failure + nsExec::ExecToLog `sc failure "Grafana Agent Flow" reset= 60 actions= restart/5000 reboot= "Grafana Agent Flow has failed. Restarting in 5 seconds"` + Pop $0 SectionEnd Function CreateConfig diff --git a/packaging/grafana-agent/windows/install_script.nsis b/packaging/grafana-agent/windows/install_script.nsis index 235ab1af402d..07f8986026da 100644 --- a/packaging/grafana-agent/windows/install_script.nsis +++ b/packaging/grafana-agent/windows/install_script.nsis @@ -132,6 +132,9 @@ Function Install Pop $0 nsExec::ExecToLog `sc start "Grafana Agent"` Pop $0 + # Auto-restart agent on failure. Reset failure counter after 60 seconds without failure + nsExec::ExecToLog `sc failure "Grafana Agent" reset= 60 actions= restart/5000 reboot= "Grafana Agent has failed. Restarting in 5 seconds"` + Pop $0 FunctionEnd Function WriteConfig