Telegraf: fix Windows install instructions. (#5086)

* adjust windows install guide

* fix(telegraf): provide optional config instructions for Windows.

- Avoid errors in Windows when just getting started.
- Options for commenting and replacing plugin.
- Fix command formatting.

* Update content/telegraf/v1.26/install.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/telegraf/v1.26/install.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/telegraf/v1.27/install.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/telegraf/v1.27/install.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/telegraf/v1.27/install.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

* Update content/telegraf/v1.26/install.md

Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>

---------

Co-authored-by: Lennart Lösche <loesche.lennart@gmail.com>
Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>
pull/5089/head
Jason Stirnaman 2023-08-15 10:13:37 -05:00 committed by GitHub
parent 56316fcb6c
commit 0d8ebb4ff1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 139 additions and 61 deletions

View File

@ -178,7 +178,7 @@ zypper in telegraf
## Configuration
### Create a configuration file with default input and output plugins.
### Create a configuration file with default input and output plugins
Every plugin will be in the file, but most will be commented out.
@ -235,16 +235,22 @@ brew update
brew install telegraf
```
To have launchd start telegraf at next login:
Run one of the following commands to start Telegraf and begin collecting and processing metrics:
To have launchd start Telegraf as a service after the next login:
```
ln -sfv /usr/local/opt/telegraf/*.plist ~/Library/LaunchAgents
```
To load telegraf now:
Start Telegraf as a launchd service:
```
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.telegraf.plist
```
Or, if you don't want/need launchctl, you can just run:
To run `telegraf` directly (and not as a launchd service):
```
telegraf -config /usr/local/etc/telegraf.conf
```
@ -255,12 +261,12 @@ telegraf -config /usr/local/etc/telegraf.conf
### Create a configuration file with default input and output plugins.
Every plugin will be in the file, but most will be commented out.
```
telegraf config > telegraf.conf
```
The output `telegraf.conf` contains all available plugins--some are enabled and the rest are commented out.
### Create a configuration file with specific inputs and outputs
```
telegraf --input-filter <pluginname>[:<pluginname>] --output-filter <outputname>[:<outputname>] config > telegraf.conf
@ -286,43 +292,75 @@ In PowerShell _as an administrator_, do the following:
and extract its contents to `C:\Program Files\InfluxData\telegraf\`:
```powershell
> wget https://dl.influxdata.com/telegraf/releases/telegraf-{{% latest-patch %}}_windows_amd64.zip -UseBasicParsing -OutFile telegraf-{{< latest-patch >}}_windows_amd64.zip
> Expand-Archive .\telegraf-{{% latest-patch %}}_windows_amd64.zip -DestinationPath 'C:\Program Files\InfluxData\telegraf\'
wget `
https://dl.influxdata.com/telegraf/releases/telegraf-{{% latest-patch %}}_windows_amd64.zip `
-UseBasicParsing `
-OutFile telegraf-{{< latest-patch >}}_windows_amd64.zip `
Expand-Archive .\telegraf-{{% latest-patch %}}_windows_amd64.zip `
-DestinationPath 'C:\Program Files\InfluxData\telegraf\'
```
2. Move the `telegraf.exe` and `telegraf.conf` files from
`C:\Program Files\InfluxData\telegraf\telegraf-{{% latest-patch %}}`
up a level to `C:\Program Files\InfluxData\telegraf`:
2. Choose one of the following steps to place your `telegraf.exe` and `telegraf.conf` files in `C:\Program Files\InfluxData\telegraf`:
```powershell
> cd "C:\Program Files\InfluxData\telegraf"
> mv .\telegraf-{{% latest-patch %}}\telegraf.* .
- Move the `telegraf.exe` and `telegraf.conf` files from
`C:\Program Files\InfluxData\telegraf\telegraf-{{% latest-patch %}}` to the parent directory `C:\Program Files\InfluxData\telegraf`--for example:
```powershell
cd "C:\Program Files\InfluxData\telegraf";
mv .\telegraf-{{% latest-patch %}}\telegraf.* .
```
- **Or**, create a [Windows symbolic link (Symlink)](https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/) for
`C:\Program Files\InfluxData\telegraf` that points to the extracted directory.
{{% note %}}
The remaining instructions assume that `telegraf.exe` and `telegraf.conf` files are stored in
`C:\Program Files\InfluxData\telegraf` or that you created a Symlink to point to this directory.
{{% /note %}}
3. Optional: Disable the [`inputs.processes` plugin](/{{% latest "telegraf" %}}/plugins/#input-processes).
This plugin doesn't support Windows and returns an error when run with the `--test` flag.
Open `telegraf.conf` in your editor and comment the `inputs.processes` configuration lines.
```toml
...
# This plugin ONLY supports non-Windows
# [[inputs.processes]]
...
# # use_sudo = false
...
```
Or create a [Windows symbolic link (Symlink)](https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/)
to point to this directory.
4. Optional: Enable a plugin to collect Windows-specific metrics--for example, uncomment the [`inputs.win_services` plugin](/{{% latest "telegraf" %}}/plugins/#input-win_services) configuration line:
> The instructions below assume that either the `telegraf.exe` and `telegraf.conf` files are stored in `C:\Program Files\InfluxData\telegraf`, or you've created a Symlink to point to this directory.
3. Install Telegraf as a service:
```powershell
> .\telegraf.exe --service install --config "C:\Program Files\InfluxData\telegraf\telegraf.conf"
```toml
...
# # Input plugin to report Windows services info.
# # This plugin ONLY supports Windows
[[inputs.win_services]]
...
```
Make sure to provide the absolute path of the `telegraf.conf` configuration file,
otherwise the Windows service may fail to start.
4. To test that the installation works, run:
5. Run the following command to install Telegraf and the configuration as a Windows service.
For the `--config` option, pass the absolute path of the `telegraf.conf` configuration file.
```powershell
> C:\"Program Files"\InfluxData\telegraf\telegraf.exe --config C:\"Program Files"\InfluxData\telegraf\telegraf.conf --test
.\telegraf.exe --service install `
--config "C:\Program Files\InfluxData\telegraf\telegraf.conf"
```
5. To start collecting data, run:
6. To test that the installation works, enter the following command:
```powershell
telegraf.exe --service start
.\telegraf.exe `
--config C:\"Program Files"\InfluxData\telegraf\telegraf.conf --test
```
When run in test mode (using the `--test` flag), Telegraf runs once, collects metrics, outputs them to the console, and then exits. It doesn't run processors, aggregators, or output plugins.
6. To start collecting data, run:
```powershell
.\telegraf.exe --service start
```
<!--
@ -333,7 +371,7 @@ If you have multiple Telegraf configuration files, you can specify a `--config-d
1. Create a directory for configuration snippets at `C:\Program Files\Telegraf\telegraf.d`.
2. Include the `--config-directory` option when registering the service:
```powershell
> C:\"Program Files"\Telegraf\telegraf.exe --service install --config C:\"Program Files"\Telegraf\telegraf.conf --config-directory C:\"Program Files"\Telegraf\telegraf.d
C:\"Program Files"\Telegraf\telegraf.exe --service install --config C:\"Program Files"\Telegraf\telegraf.conf --config-directory C:\"Program Files"\Telegraf\telegraf.d
```
-->
@ -375,7 +413,7 @@ Use the Telegraf custom builder tool to compile Telegraf with only the plugins y
```
cd telegraf
```
3. Build the Telegraf custom builder tool by entering the folllowing command:
3. Build the Telegraf custom builder tool by entering the following command:
```sh
make build_tools
```
@ -384,7 +422,7 @@ Use the Telegraf custom builder tool to compile Telegraf with only the plugins y
```sh
./tools/custom_builder/custom_builder --config /etc/telegraf.conf
```
- **Single Telegraf confiuaration and Telegraf configuration directory**:
- **Single Telegraf configuration and Telegraf configuration directory**:
```sh
./tools/custom_builder/custom_builder \
--config /etc/telegraf.conf \

View File

@ -178,7 +178,7 @@ zypper in telegraf
## Configuration
### Create a configuration file with default input and output plugins.
### Create a configuration file with default input and output plugins
Every plugin will be in the file, but most will be commented out.
@ -235,16 +235,22 @@ brew update
brew install telegraf
```
To have launchd start telegraf at next login:
Run one of the following commands to start Telegraf and begin collecting and processing metrics:
To have launchd start Telegraf as a service after the next login:
```
ln -sfv /usr/local/opt/telegraf/*.plist ~/Library/LaunchAgents
```
To load telegraf now:
Start Telegraf as a launchd service:
```
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.telegraf.plist
```
Or, if you don't want/need launchctl, you can just run:
To run `telegraf` directly (and not as a launchd service):
```
telegraf -config /usr/local/etc/telegraf.conf
```
@ -261,6 +267,8 @@ Every plugin will be in the file, but most will be commented out.
telegraf config > telegraf.conf
```
The output `telegraf.conf` contains all available plugins--some are enabled and the rest are commented out.
### Create a configuration file with specific inputs and outputs
```
telegraf --input-filter <pluginname>[:<pluginname>] --output-filter <outputname>[:<outputname>] config > telegraf.conf
@ -286,43 +294,75 @@ In PowerShell _as an administrator_, do the following:
and extract its contents to `C:\Program Files\InfluxData\telegraf\`:
```powershell
> wget https://dl.influxdata.com/telegraf/releases/telegraf-{{% latest-patch %}}_windows_amd64.zip -UseBasicParsing -OutFile telegraf-{{< latest-patch >}}_windows_amd64.zip
> Expand-Archive .\telegraf-{{% latest-patch %}}_windows_amd64.zip -DestinationPath 'C:\Program Files\InfluxData\telegraf\'
wget `
https://dl.influxdata.com/telegraf/releases/telegraf-{{% latest-patch %}}_windows_amd64.zip `
-UseBasicParsing `
-OutFile telegraf-{{< latest-patch >}}_windows_amd64.zip `
Expand-Archive .\telegraf-{{% latest-patch %}}_windows_amd64.zip `
-DestinationPath 'C:\Program Files\InfluxData\telegraf\'
```
2. Move the `telegraf.exe` and `telegraf.conf` files from
`C:\Program Files\InfluxData\telegraf\telegraf-{{% latest-patch %}}`
up a level to `C:\Program Files\InfluxData\telegraf`:
2. Choose _one_ of the following steps to place your `telegraf.exe` and `telegraf.conf` files in `C:\Program Files\InfluxData\telegraf`:
```powershell
> cd "C:\Program Files\InfluxData\telegraf"
> mv .\telegraf-{{% latest-patch %}}\telegraf.* .
- Move the `telegraf.exe` and `telegraf.conf` files from
`C:\Program Files\InfluxData\telegraf\telegraf-{{% latest-patch %}}` to the parent directory `C:\Program Files\InfluxData\telegraf`--for example:
```powershell
cd "C:\Program Files\InfluxData\telegraf";
mv .\telegraf-{{% latest-patch %}}\telegraf.* .
```
- **Or**, create a [Windows symbolic link (Symlink)](https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/) for
`C:\Program Files\InfluxData\telegraf` that points to the extracted directory.
{{% note %}}
The remaining instructions assume that `telegraf.exe` and `telegraf.conf` files are stored in
`C:\Program Files\InfluxData\telegraf` or that you created a Symlink to point to this directory.
{{% /note %}}
3. Optional: Disable the [`inputs.processes` plugin](/{{% latest "telegraf" %}}/plugins/#input-processes).
This plugin doesn't support Windows and returns an error when run with the `--test` flag.
Open `telegraf.conf` in your editor and comment the `inputs.processes` configuration lines.
```toml
...
# This plugin ONLY supports non-Windows
# [[inputs.processes]]
...
# # use_sudo = false
...
```
Or create a [Windows symbolic link (Symlink)](https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/)
to point to this directory.
4. Optional: Enable a plugin to collect Windows-specific metrics--for example, uncomment the [`inputs.win_services` plugin](/{{% latest "telegraf" %}}/plugins/#input-win_services) configuration line:
> The instructions below assume that either the `telegraf.exe` and `telegraf.conf` files are stored in `C:\Program Files\InfluxData\telegraf`, or you've created a Symlink to point to this directory.
3. Install Telegraf as a service:
```powershell
> .\telegraf.exe --service install --config "C:\Program Files\InfluxData\telegraf\telegraf.conf"
```toml
...
# # Input plugin to report Windows services info.
# # This plugin ONLY supports Windows
[[inputs.win_services]]
...
```
Make sure to provide the absolute path of the `telegraf.conf` configuration file,
otherwise the Windows service may fail to start.
4. To test that the installation works, run:
5. Run the following command to install Telegraf and the configuration as a Windows service.
For the `--config` option, pass the absolute path of the `telegraf.conf` configuration file.
```powershell
> C:\"Program Files"\InfluxData\telegraf\telegraf.exe --config C:\"Program Files"\InfluxData\telegraf\telegraf.conf --test
.\telegraf.exe --service install `
--config "C:\Program Files\InfluxData\telegraf\telegraf.conf"
```
5. To start collecting data, run:
6. To test that the installation works, enter the following command:
```powershell
telegraf.exe --service start
.\telegraf.exe `
--config C:\"Program Files"\InfluxData\telegraf\telegraf.conf --test
```
When run in test mode (using the `--test` flag), Telegraf runs once, collects metrics, outputs them to the console, and then exits. It doesn't run processors, aggregators, or output plugins.
6. To start collecting data, run:
```powershell
.\telegraf.exe --service start
```
<!--
@ -333,7 +373,7 @@ If you have multiple Telegraf configuration files, you can specify a `--config-d
1. Create a directory for configuration snippets at `C:\Program Files\Telegraf\telegraf.d`.
2. Include the `--config-directory` option when registering the service:
```powershell
> C:\"Program Files"\Telegraf\telegraf.exe --service install --config C:\"Program Files"\Telegraf\telegraf.conf --config-directory C:\"Program Files"\Telegraf\telegraf.d
C:\"Program Files"\Telegraf\telegraf.exe --service install --config C:\"Program Files"\Telegraf\telegraf.conf --config-directory C:\"Program Files"\Telegraf\telegraf.d
```
-->
@ -375,7 +415,7 @@ Use the Telegraf custom builder tool to compile Telegraf with only the plugins y
```
cd telegraf
```
3. Build the Telegraf custom builder tool by entering the folllowing command:
3. Build the Telegraf custom builder tool by entering the following command:
```sh
make build_tools
```