Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new configurable option to the windows installer for static mode #5958

Merged
merged 7 commits into from
Jan 10, 2024
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ Main (unreleased)

- Add support for `http_sd_config` within a `scrape_config` for prometheus to flow config conversion. (@erikbaranowski)

- Add an option to the windows static mode installer for expanding environment vars in the yaml config. (@erikbaranowski)

### Bugfixes

- Update `pyroscope.ebpf` to fix a logical bug causing to profile to many kthreads instead of regular processes https://github.com/grafana/pyroscope/pull/2778 (@korniltsev)
Expand Down
26 changes: 25 additions & 1 deletion docs/sources/static/set-up/install/install-agent-on-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ To do a standard graphical install of Grafana Agent on Windows, perform the foll
1. Double-click on `grafana-agent-installer.exe` to install Grafana Agent.

Grafana Agent is installed into the default directory `C:\Program Files\Grafana Agent`.
The [windows_exporter integration](/docs/agent/latest/static/configuration/integrations/windows-exporter-config) can be enabled with all default windows_exporter options.

The following options are available:

- The [windows_exporter integration][windows_exporter_config] can be enabled with all default windows_exporter options.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was hardcoded to /latest/ but should be corrected now

- The [-config.expand-env][flags] command line flag can be enabled.

## Silent install

Expand Down Expand Up @@ -78,6 +82,24 @@ If you are using `remote_write` you must enable Windows Exporter and set the glo

If you are using Powershell, make sure you use triple quotes `"""http://example.com"""` around the URL parameter.

## Silent install with `-config.expand_env`

It is possible to enable [-config.expand-env][flags] during a silent install.
erikbaranowski marked this conversation as resolved.
Show resolved Hide resolved

1. Navigate to the [latest release](https://github.com/grafana/agent/releases) on GitHub.

1. Scroll down to the **Assets** section.

1. Download the file called `grafana-agent-installer.exe.zip`.

1. Unzip the downloaded file.

1. Run the following command in PowerShell or Command Prompt:

```shell
PATH_TO_INSTALLER/grafana-agent-installer.exe /S /ExpandEnv true
```

## Verify the installation

1. Make sure you can access `http://localhost:12345/-/healthy` and `http://localhost:12345/agent/api/v1/metrics/targets`.
Expand Down Expand Up @@ -146,6 +168,8 @@ Refer to [windows_events](/docs/loki/latest/clients/promtail/configuration/#wind
- [Configure Grafana Agent][configure]

{{% docs/reference %}}
[flags]: "/docs/agent/ -> /docs/agent/<AGENT_VERSION>/static/configuration/flags"
[windows_exporter_config]: "/docs/agent/ -> /docs/agent/<AGENT_VERSION>/static/configuration/integrations/windows-exporter-config"
[start]: "/docs/agent/ -> /docs/agent/<AGENT_VERSION>/static/set-up/start-agent"
[start]: "/docs/grafana-cloud/ -> ../start-agent"
[configure]: "/docs/agent/ -> /docs/agent/<AGENT_VERSION>/static/configuration/create-config-file"
Expand Down
36 changes: 28 additions & 8 deletions packaging/grafana-agent/windows/install_script.nsis
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@ outFile "${OUT}"
LicenseData LICENSE

# Everything must be global Vars
Var EnableOptionsDialog
Var PassedInParameters
Var EnableExporterCheck
Var EnableExporterValue
Var EnableExporterDialog
Var PassedInParameters
Var Url
Var Username
Var Password
Var ExpandEnvCheck
Var ExpandEnvValue

Page license
Page directory
Page custom enableWindowsExporter enableWindowsExporterLeave
Page custom enableOptions enableOptionsLeave
Page instfiles

# Annoyingly macros need to be defined before use
Expand All @@ -61,17 +63,18 @@ Section "install"
${GetOptions} $PassedInParameters "/Url" $Url
${GetOptions} $PassedInParameters "/Username" $Username
${GetOptions} $PassedInParameters "/Password" $Password
${GetOptions} $PassedInParameters "/ExpandEnv" $ExpandEnvValue
Call Install
Return
RunInstaller:
Call Install
SectionEnd

Function enableWindowsExporter
Function enableOptions
nsDialogs::Create 1018
Pop $EnableExporterDialog
Pop $EnableOptionsDialog

${If} $EnableExporterDialog == error
${If} $EnableOptionsDialog == error
Abort
${EndIf}

Expand All @@ -81,16 +84,29 @@ Function enableWindowsExporter
${NSD_CreateCheckBox} 0 13u 100% 12u ""
Pop $EnableExporterCheck

${NSD_CreateLabel} 0 26u 100% 12u "Expand Environment Variables"
Pop $0

${NSD_CreateCheckBox} 0 39u 100% 12u ""
Pop $ExpandEnvCheck

nsDialogs::Show
FunctionEnd

Function enableWindowsExporterLeave
Function enableOptionsLeave
${NSD_GetState} $EnableExporterCheck $EnableExporterValue
${If} $EnableExporterValue == ${BST_CHECKED}
StrCpy $EnableExporterValue "true"
${Else}
StrCpy $EnableExporterValue "false"
${EndIf}

${NSD_GetState} $ExpandEnvCheck $ExpandEnvValue
${If} $ExpandEnvValue == ${BST_CHECKED}
StrCpy $ExpandEnvValue "true"
${Else}
StrCpy $ExpandEnvValue "false"
${EndIf}
FunctionEnd

Function Install
Expand Down Expand Up @@ -128,7 +144,11 @@ Function Install
nsExec::ExecToLog 'sc create "Grafana Agent" binpath= "\"$INSTDIR\grafana-agent-windows-amd64.exe\""'
Pop $0
# These separate create and config commands are needed, on the config the binpath is required
nsExec::ExecToLog 'sc config "Grafana Agent" start= auto binpath= "\"$INSTDIR\grafana-agent-windows-amd64.exe\" -config.file=\"$INSTDIR\agent-config.yaml\""'
${If} $ExpandEnvValue == "true"
nsExec::ExecToLog 'sc config "Grafana Agent" start= auto binpath= "\"$INSTDIR\grafana-agent-windows-amd64.exe\" -config.expand-env -config.file=\"$INSTDIR\agent-config.yaml\""'
${Else}
nsExec::ExecToLog 'sc config "Grafana Agent" start= auto binpath= "\"$INSTDIR\grafana-agent-windows-amd64.exe\" -config.file=\"$INSTDIR\agent-config.yaml\""'
${EndIf}
Pop $0
nsExec::ExecToLog `sc start "Grafana Agent"`
Pop $0
Expand Down