Skip to content
This repository was archived by the owner on Jul 28, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

- [ENHANCEMENT] Updated elasticsearch_exporter to v1.2.1 (@gaantunes)

- [ENHANCEMENT] Add remote write to silent Windows Installer (@mattdurham)

- [BUGFIX] Sanitize autologged Loki labels by replacing invalid characters with underscores (@mapno)

# v0.19.0 (2021-09-29)
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/install-agent-on-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Existing configuration files will be kept when re-installing or upgrading the Gr

### Silent Installation

Silent installation can be achieved via `grafana-agent-installer.exe /S /EnableExporter "true"`. EnableExporter enables or disables Windows Exporter, default is `false`.
Silent installation can be achieved via `grafana-agent-installer.exe /S /EnableExporter true /Username 12345 /Password password /Url http://example.com `. EnableExporter enables or disables Windows Exporter, default is `false`. Username, Password and Url set the global remote_write configuration, they can be omitted if not using remote_write.

## Security

Expand Down
19 changes: 16 additions & 3 deletions packaging/windows/install_script.nsis
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Var EnableExporterCheck
Var EnableExporterValue
Var EnableExporterDialog
Var PassedInParameters
Var Url
Var Username
Var Password

Page license
Page directory
Expand Down Expand Up @@ -56,6 +59,9 @@ Section "install"
ThisIsSilent:
${GetParameters} $PassedInParameters
${GetOptions} $PassedInParameters "/EnableExporter" $EnableExporterValue
${GetOptions} $PassedInParameters "/Url" $Url
${GetOptions} $PassedInParameters "/Username" $Username
${GetOptions} $PassedInParameters "/Password" $Password
Call Install
Return
RunInstaller:
Expand Down Expand Up @@ -89,7 +95,7 @@ Function enableWindowsExporterLeave
FunctionEnd

Function Install
# Premptively stop Grafana Agent if it is running
# Preemptively stop Grafana Agent if it is running
nsExec::ExecToLog 'sc stop "Grafana Agent"'
Pop $0
# Files for the install directory - to build the installer, these should be in the same directory as the install script (this file)
Expand Down Expand Up @@ -118,7 +124,7 @@ Function Install
Call WriteConfig


# Create our batch file, since services cant run with parameters, nsexec is used to surpress console output, instead goes
# Create our batch file, since services cant run with parameters, nsexec is used to suppress console output, instead goes
# to NSIS log window
nsExec::ExecToLog 'sc create "Grafana Agent" binpath= "$INSTDIR\agent-windows-amd64.exe"'
Pop $0
Expand All @@ -143,6 +149,13 @@ Function WriteConfig
FileWrite $9 ` wal_directory: $APPDATA\grafana-agent-wal$\n`
FileWrite $9 ` global:$\n`
FileWrite $9 ` scrape_interval: 1m$\n`
${If} $Url != ""
FileWrite $9 ` remote_write: $\n`
FileWrite $9 ` - url: $Url $\n`
FileWrite $9 ` basic_auth: $\n`
FileWrite $9 ` username: $Username $\n`
FileWrite $9 ` password: $Password $\n`
${EndIf}
FileWrite $9 ` configs:$\n`
FileWrite $9 ` - name: integrations$\n`
${If} $EnableExporterValue == "true"
Expand All @@ -162,7 +175,7 @@ Function un.onInit
Return
WarnUser:
#Verify the uninstaller - last chance to back out
MessageBox MB_OKCANCEL "Permanantly remove ${APPNAME}? This will remove the WAL and the agent config." IDOK next
MessageBox MB_OKCANCEL "Permanently remove ${APPNAME}? This will remove the WAL and the agent config." IDOK next
Abort
next:
!insertmacro VerifyUserIsAdmin
Expand Down