diff --git a/.ci/Dockerfile.remark b/.ci/Dockerfile.remark index fd4f59159..93b243157 100644 --- a/.ci/Dockerfile.remark +++ b/.ci/Dockerfile.remark @@ -1,14 +1,12 @@ FROM registry.gitlab.com/pipeline-components/remark-lint:latest - WORKDIR /app/ -# Generic #RUN apk add --no-cache COPY /.ci/remark-lint /app/ # Node -ENV PATH "$PATH:/app/node_modules/.bin/" +ENV PATH="$PATH:/app/node_modules/.bin/" RUN yarn install && yarn cache clean ENV NODE_PATH=/app/node_modules/ RUN ln -nfs /app/node_modules /node_modules @@ -23,3 +21,6 @@ LABEL \ org.label-schema.name="Remark-lint" \ org.label-schema.schema-version="1.0" \ org.label-schema.url="https://pipeline-components.gitlab.io/" + +ENTRYPOINT [ "remark" ] +CMD [ "" ] diff --git a/.ci/remark-lint/.remark-lint.js b/.ci/remark-lint/.remark-lint.js new file mode 100644 index 000000000..741e8eefa --- /dev/null +++ b/.ci/remark-lint/.remark-lint.js @@ -0,0 +1,25 @@ +import remarkPresetLintConsistent from 'remark-preset-lint-consistent'; +import remarkPresetLintRecommended from 'remark-preset-lint-recommended'; +import remarkPresetLintMarkdownStyleGuide from 'remark-preset-lint-markdown-style-guide'; +import remarkFrontmatter from 'remark-frontmatter'; +import remarkFrontmatterSchema from 'remark-lint-frontmatter-schema'; +import remarkNoShellDollars from 'remark-lint-no-shell-dollars'; +import remarkToc from 'remark-toc'; + +const remarkConfig = { + settings: { + bullet: '-', + plugins: [ + remarkPresetLintConsistent, + remarkPresetLintRecommended, + remarkPresetLintMarkdownStyleGuide, + remarkFrontmatter, + remarkFrontmatterSchema, + remarkNoShellDollars, + // Generate a table of contents in `## Contents` + [remarkToc, { heading: '' }], + ], + }, +}; + +export default remarkConfig; \ No newline at end of file diff --git a/.ci/vale/styles/Google/Units.yml b/.ci/vale/styles/Google/Units.yml index 024c816e1..ed07061ce 100644 --- a/.ci/vale/styles/Google/Units.yml +++ b/.ci/vale/styles/Google/Units.yml @@ -5,5 +5,5 @@ nonword: true level: error tokens: - \b\d+(?:B|kB|MB|GB|TB) -# Ignore duration literals in code blocks. - - \b(?!\`)\d+(?:ns|ms|s|min|h|d) +# Match time units, but not duration literals inside code blocks. + - \b`(\n)?\d+(ns|ms|s|min|h|d)`\b diff --git a/Dockerfile.pytest b/Dockerfile.pytest index b47718c82..5a853098f 100644 --- a/Dockerfile.pytest +++ b/Dockerfile.pytest @@ -12,6 +12,7 @@ RUN echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] h # Install InfluxDB clients to use in tests. RUN apt-get update && apt-get upgrade -y && apt-get install -y \ + apt-utils \ curl \ git \ gpg \ @@ -52,7 +53,7 @@ COPY ./test/pytest/pytest.ini pytest.ini # Python and Pytest dependencies. COPY ./test/pytest/requirements.txt requirements.txt # Pytest fixtures. -COPY ./test/pytest/conftest.py conftest.py +COPY ./test/pytest/conftest.py conftest.py RUN pip install -Ur requirements.txt # Activate the Python virtual environment configured in the Dockerfile. @@ -70,6 +71,7 @@ RUN service influxdb start # Copy test scripts and make them executable. COPY --chmod=755 ./test/scripts/parse_yaml.sh /usr/local/bin/parse_yaml +COPY --chmod=755 ./test/scripts/get-container-info.sh /usr/local/bin/get-container-info ENTRYPOINT [ "pytest" ] diff --git a/compose.yaml b/compose.yaml index 35d66f2a0..eff36180b 100644 --- a/compose.yaml +++ b/compose.yaml @@ -36,6 +36,7 @@ services: - local - lint cloud-pytest: + container_name: cloud-pytest image: influxdata/docs-pytest build: context: . @@ -85,6 +86,7 @@ services: target: /app/content working_dir: /app cloud-dedicated-pytest: + container_name: cloud-dedicated-pytest image: influxdata/docs-pytest build: context: . @@ -139,6 +141,7 @@ services: target: /app/content working_dir: /app cloud-serverless-pytest: + container_name: cloud-serverless-pytest image: influxdata/docs-pytest build: context: . @@ -188,6 +191,7 @@ services: target: /app/content working_dir: /app clustered-pytest: + container_name: clustered-pytest image: influxdata/docs-pytest build: context: . @@ -242,6 +246,7 @@ services: target: /app/content working_dir: /app telegraf-pytest: + container_name: telegraf-pytest image: influxdata/docs-pytest build: context: . @@ -290,6 +295,7 @@ services: target: /app/content working_dir: /app v2-pytest: + container_name: v2-pytest image: influxdata/docs-pytest build: context: . @@ -339,6 +345,7 @@ services: target: /app/content working_dir: /app influxdb2: + container_name: influxdb2 image: influxdb:2 ports: - 8086:8086 @@ -366,6 +373,7 @@ services: source: influxdb2-config target: /etc/influxdb2 remark-lint: + container_name: remark-lint build: context: . dockerfile: .ci/Dockerfile.remark diff --git a/content/telegraf/v1/configuration.md b/content/telegraf/v1/configuration.md index efe742c27..f176c3ea7 100644 --- a/content/telegraf/v1/configuration.md +++ b/content/telegraf/v1/configuration.md @@ -22,22 +22,105 @@ See [Get started](/telegraf/v1/get_started/) to quickly get up and running with ## Generate a configuration file -A default Telegraf configuration file can be auto-generated by Telegraf: +The `telegraf config` command lets you generate a configuration file using Telegraf's list of plugins. -``` +- [Create a configuration with default input and output plugins](#create-a-configuration-with-default-input-and-output-plugins) +- [Create a configuration with specific input and output plugins](#create-a-configuration-with-specific-input-and-output-plugins) + +### Create a configuration with default input and output plugins + +To generate a configuration file with default input and output plugins enabled, +enter the following command in your terminal: + +{{< code-tabs-wrapper >}} +{{% code-tabs %}} +[Linux and macOS](#) +[Windows](#) +{{% /code-tabs %}} +{{% code-tab-content %}} +```bash telegraf config > telegraf.conf ``` - -To generate a configuration file with specific inputs and outputs, you can use the -`--input-filter` and `--output-filter` flags: - +{{% /code-tab-content %}} +{{% code-tab-content %}} +```powershell +.\telegraf.exe config > telegraf.conf ``` -telegraf --input-filter cpu:mem:net:swap --output-filter influxdb:kafka config +{{% /code-tab-content %}} +{{< /code-tabs-wrapper >}} + +The generated file contains settings for all available plugins--some are enabled and the rest are commented out. + +### Create a configuration file with specific input and output plugins + +To generate a configuration file that contains settings for only specific plugins, +use the `--input-filter` and `--output-filter` options to +specify [input plugins](/telegraf/v1/plugins/input_plugins) +and [output plugins](/telegraf/v1/plugins/output_plugins/). +Use a colon (`:`) to separate plugin names. + +#### Syntax + +{{< code-tabs-wrapper >}} +{{% code-tabs %}} +[Linux and macOS](#) +[Windows](#) +{{% /code-tabs %}} +{{% code-tab-content %}} +```bash +telegraf \ +--input-filter [:] \ +--output-filter [:] \ +config > telegraf.conf ``` +{{% /code-tab-content %}} +{{% code-tab-content %}} +```powershell +.\telegraf.exe ` +--input-filter [:] ` +--output-filter [:] ` +config > telegraf.conf +``` +{{% /code-tab-content %}} +{{< /code-tabs-wrapper >}} + +#### Example + +The following example shows how to include configuration sections for the +[`inputs.cpu`](/telegraf/v1/plugins/#input-cpu), +[`inputs.http_listener_v2`](/telegraf/v1/plugins/#input-http_listener_v2), +[`outputs.influxdb_v2`](/telegraf/v1/plugins/#output-influxdb_v2), and +[`outputs.file`](/telegraf/v1/plugins/#output-file) plugins: + +{{< code-tabs-wrapper >}} +{{% code-tabs %}} +[Linux and macOS](#) +[Windows](#) +{{% /code-tabs %}} +{{% code-tab-content %}} +```bash +telegraf \ +--input-filter cpu:http_listener_v2 \ +--output-filter influxdb_v2:file \ +config > telegraf.conf +``` +{{% /code-tab-content %}} +{{% code-tab-content %}} +```powershell +.\telegraf.exe ` +--input-filter cpu:http_listener_v2 ` +--output-filter influxdb_v2:file ` +config > telegraf.conf +``` +{{% /code-tab-content %}} +{{< /code-tabs-wrapper >}} + +For more advanced configuration details, see the +[configuration documentation](/telegraf/v1/administration/configuration/). ## Configuration file locations -Use the `--config` flag to specify the configuration file location: +When starting Telegraf, use the `--config` flag to specify the configuration file location: - Filename and path, for example: `--config /etc/default/telegraf` - Remote URL endpoint, for example: `--config "http://remote-URL-endpoint"` @@ -46,9 +129,56 @@ Use the `--config-directory` flag to include files ending with `.conf` in the specified directory in the Telegraf configuration. On most systems, the default locations are `/etc/telegraf/telegraf.conf` for -the main configuration file and `/etc/telegraf/telegraf.d` for the directory of +the main configuration file and `/etc/telegraf/telegraf.d` (on Windows, `C:\"Program Files"\Telegraf\telegraf.d`) for the directory of configuration files. +Telegraf processes each configuration file separately, and +the effective configuration is the union of all the files. +If any file isn't a valid configuration, Telegraf returns an error. + +{{% warn %}} + +#### Partial configurations aren't supported + +Telegraf doesn't concatenate configuration files before processing them. +Each configuration file that you provide must be a valid configuration. + +If you want to use separate files to manage a configuration, you can use your +own custom code to concatenate and pre-process the files, and then provide the +complete configuration to Telegraf--for example: + +1. Configure plugin sections and assign partial configs a file extension different + from `.conf` to prevent Telegraf loading them--for example: + + ```toml + # main.opcua: Main configuration file + ... + [[inputs.opcua_listener]] + name = "PluginSection" + endpoint = "opc.tcp://10.0.0.53:4840" + ... + ``` + + ```toml + # group_1.opcua + [[inputs.opcua_listener.group]] + name = "SubSection1" + ... + ``` + + ```toml + # group_2.opcua + [[inputs.opcua_listener.group]] + name = "SubSection2" + ... + ``` + +2. Before you start Telegraf, run your custom script to concatenate `main.opcua`, `group_1.opcua`, + `group_2.opcua` into a valid `telegraf.conf`. +3. Start Telegraf with the complete, valid `telegraf.conf` configuration. + +{{% /warn %}} + ## Set environment variables Use environment variables anywhere in the configuration file by enclosing them in `${}`. @@ -63,6 +193,8 @@ You can also set environment variables using the Linux `export` command: `export Set environment variables in the Telegraf environment variables file (`/etc/default/telegraf`)--for example: + + ```sh USER="alice" INFLUX_URL="http://localhost:8086" @@ -72,7 +204,7 @@ INFLUX_PASSWORD="monkey123" In the Telegraf configuration file (`/etc/telegraf.conf`), reference the variables--for example: -```sh +```toml [global_tags] user = "${USER}" @@ -86,7 +218,7 @@ In the Telegraf configuration file (`/etc/telegraf.conf`), reference the variabl When Telegraf runs, the effective configuration is the following: -```sh +```toml [global_tags] user = "alice" @@ -94,7 +226,6 @@ When Telegraf runs, the effective configuration is the following: urls = "http://localhost:8086" skip_database_creation = true password = "monkey123" - ``` ## Global tags diff --git a/content/telegraf/v1/configure_plugins/input_plugins/_index.md b/content/telegraf/v1/configure_plugins/input_plugins/_index.md index 516dce22c..257a61913 100644 --- a/content/telegraf/v1/configure_plugins/input_plugins/_index.md +++ b/content/telegraf/v1/configure_plugins/input_plugins/_index.md @@ -12,6 +12,6 @@ menu: Telegraf input plugins are used with the InfluxData time series platform to collect metrics from the system, services, or third-party APIs. All metrics are gathered from the inputs you enable and configure in the [Telegraf configuration file](/telegraf/v1/configuration/). -For a complete list of input plugins and links to their detailed configuration options, see [input plugins](/telegraf/v1/plugins/inputs/). +For a complete list of input plugins and links to their detailed configuration options, see [input plugins](/telegraf/v1/plugins/#input-plugins). In addition to plugin-specific data formats, Telegraf supports a set of [common data formats](/telegraf/v1/data_formats/input/) available when configuring many of the Telegraf input plugins. diff --git a/content/telegraf/v1/configure_plugins/output_plugins/_index.md b/content/telegraf/v1/configure_plugins/output_plugins/_index.md index 9128a306f..f6f8019e9 100644 --- a/content/telegraf/v1/configure_plugins/output_plugins/_index.md +++ b/content/telegraf/v1/configure_plugins/output_plugins/_index.md @@ -11,6 +11,6 @@ menu: --- Output plugins define where Telegraf will deliver the collected metrics. Send metrics to InfluxDB or to a variety of other datastores, services, and message queues, including Graphite, OpenTSDB, Datadog, Librato, Kafka, MQTT, and NSQ. -For a complete list of output plugins and links to their detailed configuration options, see [output plugins](/telegraf/v1/plugins/outputs/). +For a complete list of output plugins and links to their detailed configuration options, see [output plugins](/telegraf/v1/plugins/#output-plugins). In addition to plugin-specific data formats, Telegraf supports a set of [common data formats](/telegraf/v1/data_formats/output/) available when configuring many of the Telegraf output plugins. diff --git a/content/telegraf/v1/install.md b/content/telegraf/v1/install.md index 696663572..82d362767 100644 --- a/content/telegraf/v1/install.md +++ b/content/telegraf/v1/install.md @@ -13,32 +13,10 @@ aliases: This page provides directions for installing, starting, and configuring Telegraf. To install Telegraf, do the following: -- [Download Telegraf](#download) - [Review requirements](#requirements) -- [Complete the installation](#installation) +- [Download and install Telegraf](#download-and-install-telegraf) - [Custom compile Telegraf](#custom-compile) -## Download - -Download the latest Telegraf release at the [InfluxData download page](https://www.influxdata.com/downloads/). - -### Verify Linux releases using GPG - -InfluxData uses [GPG (GnuPG)](https://www.gnupg.org/software/) to sign released software and provides -public key and encrypted private key (`.key` file) pairs that you can use to verify the integrity of downloads from the InfluxData repository. - -Before running the [install](#install) sample code, substitute the key-pair compatible with your OS version: - -For newer OS releases (for example, Ubuntu 20.04 LTS and newer) that support subkey verification: - -- Private key file: `influxdata-archive.key` -- Public key: `943666881a1b8d9b849b74caebf02d3465d6beb716510d86a39f6c8e8dac7515` - -For all Ubuntu and Debian versions, including older versions (for example, CentOS/RHEL 7, Ubuntu 18.04 LTS, or Debian Buster) that don't support subkeys for verification: - -- Private key file: `influxdata-archive_compat.key` -- Public key: `393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c` - ## Requirements Installation of the Telegraf package may require `root` or administrator privileges to complete successfully. @@ -60,7 +38,100 @@ Telegraf uses a host's local time in UTC to assign timestamps to data. Use the Network Time Protocol (NTP) to synchronize time between hosts. If hosts' clocks aren't synchronized with NTP, the timestamps on the data might be inaccurate. -## Install +## Download and install Telegraf + + + +_**Recommended**_: Before you open and install packages and downloaded files, use SHA +checksum verification and GPG signature verification to ensure the files are +intact and authentic. + +SHA checksum and GPG signature verification are complementary checks. + +_For some Linux platforms, the [installation instructions](#download-and-install-instructions) include steps to verify downloaded packages and binaries._ + +For more information, see the following: + +{{< expand-wrapper >}} +{{% expand "Verify download integrity using SHA-256" %}} + +For each released binary, InfluxData publishes the SHA checksum that +you can use to verify that the downloaded file is intact and hasn't been corrupted. + +To use the SHA checksum to verify the downloaded file, do the following: + +1. In the [downloads page](https://www.influxdata.com/downloads), + select the **Version** and **Platform** for your download. + + The page displays the unique SHA256 checksum for the file--for example: + + {{< img-hd src="/img/telegraf/downloads-telegraf-linux-amd64.png" alt="Screenshot of InfluxData downloads page showing the Telegraf SHA256 and code snippet" />}} + +2. Copy the SHA256 value--for example: + + ```text + 030182d2dca7bf4793fb741d1bbf9c35cf2afb84e13802ac866914f72271b8ea + ``` + +3. Compute the SHA checksum of the downloaded file and compare it to the + published checksum--for example, enter the following command in your terminal. + + _Note: Include two spaces between the checksum and the filename._ + + + + + ```bash + echo '030182d2dca7bf4793fb741d1bbf9c35cf2afb84e13802ac866914f72271b8ea telegraf-{{% latest-patch %}}_linux_amd64.tar.gz' \ + | sha256sum -c - + ``` + + Replace the following: + + - {{% code-placeholder-key %}}`030182d2dca7bf4793fb741d1bbf9c35cf2afb84e13802ac866914f72271b8ea`{{% /code-placeholder-key %}}: the SHA checksum copied from the downloads page + +If the checksums match, the output is the following: + +``` +telegraf-{{% latest-patch %}}_linux_amd64.tar.gz: OK +``` + +Otherwise, an error message. + +{{% /expand %}} +{{% expand "Verify file integrity and authenticity using GPG" %}} + +InfluxData uses [GPG (GnuPG)](https://www.gnupg.org/software/) to sign released software and provides +public key and encrypted private key (`.key` file) pairs that you can use to +verify the integrity of packages and binaries from the InfluxData repository. + +Before running the [install](#install) sample code, substitute the key-pair compatible with your OS version: + +For newer OS releases (for example, Ubuntu 20.04 LTS and newer, Debian Buster +and newer) that support subkey verification: + +- Private key file: [`influxdata-archive.key`](https://repos.influxdata.com/influxdata-archive.key) +- Public key: `943666881a1b8d9b849b74caebf02d3465d6beb716510d86a39f6c8e8dac7515` + +For older versions (for example, CentOS/RHEL 7, Ubuntu 18.04 LTS, or Debian +Stretch) that don't support subkeys for verification: + +- Private key file: [`influxdata-archive_compat.key`](https://repos.influxdata.com/influxdata-archive_compat.key) +- Public key: `393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c` + +_For security, InfluxData periodically rotates keys and publishes the new key pairs._ + +{{% /expand %}} +{{< /expand-wrapper >}} + + {{< tabs-wrapper >}} {{% tabs style="even-wrap" %}} @@ -68,56 +139,79 @@ aren't synchronized with NTP, the timestamps on the data might be inaccurate. [RedHat & CentOS](#) [SLES & openSUSE](#) [FreeBSD/PC-BSD](#) + [Linux binaries (AMD)](#) + [Linux binaries (ARM)](#) [macOS](#) [Windows](#) {{% /tabs %}} {{% tab-content %}} -Debian and Ubuntu users can install the latest stable version of Telegraf using the `apt-get` package manager. +Debian and Ubuntu users can install the latest stable version of Telegraf using +the `apt-get` package manager. - [Install from the InfluxData repository](#install-from-the-influxdata-repository) - [Install from a `.deb` file](#install-from-a-deb-file) -#### Install from the InfluxData repository +### Install from the InfluxData repository -Run the following commands using `apt-get` to install Telegraf from the InfluxData repository: +Run the following commands using `apt-get` to install Telegraf from the InfluxData +repository: {{< code-tabs-wrapper >}} {{% code-tabs %}} -[All versions](#) [Ubuntu 20.04 LTS and newer](#) +[Older than Ubuntu 20.04](#) {{% /code-tabs %}} {{% code-tab-content %}} + + +```bash +curl --silent --location -O \ +https://repos.influxdata.com/influxdata-archive.key \ +&& echo "943666881a1b8d9b849b74caebf02d3465d6beb716510d86a39f6c8e8dac7515 influxdata-archive.key" \ +| sha256sum -c - && cat influxdata-archive.key \ +| gpg --dearmor \ +| sudo tee /etc/apt/trusted.gpg.d/influxdata-archive.gpg > /dev/null \ +&& echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive.gpg] https://repos.influxdata.com/debian stable main' \ +| sudo tee /etc/apt/sources.list.d/influxdata.list +sudo apt-get update && sudo apt-get install telegraf +``` + + +{{% /code-tab-content %}} +{{% code-tab-content %}} + + ```bash # influxdata-archive_compat.key GPG Fingerprint: 9D539D90D3328DC7D6C8D3B9D8FF8E1F7DF8B07E -curl -s https://repos.influxdata.com/influxdata-archive_compat.key > influxdata-archive_compat.key -echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && cat influxdata-archive_compat.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null -echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list +curl --silent --location -O \ +https://repos.influxdata.com/influxdata-archive_compat.key \ +&& echo "393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key" \ +| sha256sum -c - \ +&& cat influxdata-archive_compat.key \ +| gpg --dearmor \ +| sudo tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null +echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' \ +| sudo tee /etc/apt/sources.list.d/influxdata.list sudo apt-get update && sudo apt-get install telegraf ``` -{{% /code-tab-content %}} -{{% code-tab-content %}} -```bash -curl -s https://repos.influxdata.com/influxdata-archive.key > influxdata-archive.key -echo '943666881a1b8d9b849b74caebf02d3465d6beb716510d86a39f6c8e8dac7515 influxdata-archive.key' | sha256sum -c && cat influxdata-archive.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdata-archive.gpg > /dev/null -echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list -sudo apt-get update && sudo apt-get install telegraf -``` + {{% /code-tab-content %}} {{< /code-tabs-wrapper >}} -#### Install from a `.deb` file +### Install from a `.deb` file To manually install the Debian package from a `.deb` file: 1. Download the latest Telegraf `.deb` release - from the Telegraf section of the [downloads page](https://influxdata.com/downloads/). -2. Run the following command (making sure to supply the correct version number for the downloaded file): + from the [downloads page](https://influxdata.com/downloads/#telegraf). +2. Run the following command (making sure to supply the correct version number + for the downloaded file): - ```sh - sudo dpkg -i telegraf_{{< latest-patch >}}-1_amd64.deb + ```bash + sudo dpkg -i telegraf_{{% latest-patch %}}-1_amd64.deb ``` {{% /tab-content %}} @@ -129,22 +223,28 @@ To use the `yum` package manager to install the latest stable version of Telegra 1. In your terminal, enter the following command to add the InfluxData repository to the `yum` configuration: - ```bash - cat < + -2. Enter the following command to install `telegraf` from the repository. + ```bash + cat < + + + ```bash + sudo yum install telegraf + ``` The `telegraf` configuration file is installed at `/etc/telegraf/telegraf.conf`. @@ -155,19 +255,23 @@ The openSUSE Build Service provides RPM packages for SUSE Linux. To use the `zypper` package manager to install the latest stable version of Telegraf, follow these steps: -1. In your terminal, enter the following command to add the Go repository to the `zypper` configuration: +1. In your terminal, enter the following command to add the Go repository to the `zypper` configuration: - ```bash - # add go repository - zypper ar -f obs://devel:languages:go/ go - ``` + -2. Enter the following command to install `telegraf`. + ```bash + # add go repository + zypper ar -f obs://devel:languages:go/ go + ``` - ```bash - # install latest telegraf - zypper in telegraf - ``` +2. Enter the following command to install `telegraf`. + + + + ```bash + # install latest telegraf + zypper in telegraf + ``` {{% /tab-content %}} @@ -176,16 +280,70 @@ Telegraf is part of the FreeBSD package system. To use the `pkg` package manager to install the latest stable version of Telegraf, enter the following command: + + ```bash sudo pkg install telegraf ``` The `telegraf` configuration file is installed at `/usr/local/etc/telegraf.conf`. Examples are installed at `/usr/local/etc/telegraf.conf.sample`. - + {{% /tab-content %}} - {{% tab-content %}} + + +Choose from the following options to install Telegraf binary files for Linux AMD: + +- To install on Linux AMDv7, see the [downloads page](https://www.influxdata.com/downloads/#telegraf). +- [Download and install on Linux AMDv8](#download-and-install-on-linux-amdv8) + +### Download and install on Linux AMDv8 + +{{% code-placeholders "030182d2dca7bf4793fb741d1bbf9c35cf2afb84e13802ac866914f72271b8ea" %}} + +```bash +curl -s --location -O \ +https://dl.influxdata.com/telegraf/releases/telegraf-{{% latest-patch %}}_linux_amd64.tar.gz \ +&& echo "030182d2dca7bf4793fb741d1bbf9c35cf2afb84e13802ac866914f72271b8ea telegraf-{{% latest-patch %}}_linux_amd64.tar.gz" \ +| sha256sum -c - +``` + +{{% /code-placeholders %}} + +Replace the following: + +- {{% code-placeholder-key %}}`0c57ff1a4a3af5fa387d23b0bc743b8eaed3a110d4ae7d422c439d2911cdf9b1`{{% /code-placeholder-key %}}: the SHA checksum from the [downloads page](https://www.influxdata.com/downloads/#telegraf) + + +{{% /tab-content %}} +{{% tab-content %}} + +Choose from the following options to install Telegraf binary files for Linux ARM: + +- To install on Linux ARM(32-bit), see the [downloads page](https://www.influxdata.com/downloads/#telegraf). +- [Download and install on Linux ARM (64-bit)](#download-and-install-on-linux-arm-64) + +### Download and install on Linux AMDv8 + +{{% code-placeholders "030182d2dca7bf4793fb741d1bbf9c35cf2afb84e13802ac866914f72271b8ea" %}} + +```bash +curl -s --location -O \ +https://dl.influxdata.com/telegraf/releases/telegraf-{{% latest-patch %}}_linux_arm64.tar.gz \ +&& echo "0c57ff1a4a3af5fa387d23b0bc743b8eaed3a110d4ae7d422c439d2911cdf9b1 telegraf-{{% latest-patch %}}_linux_arm64.tar.gz" \ +| sha256sum -c - +``` +{{% /code-placeholders %}} + +Replace the following: + +- {{% code-placeholder-key %}}`0c57ff1a4a3af5fa387d23b0bc743b8eaed3a110d4ae7d422c439d2911cdf9b1`{{% /code-placeholder-key %}}: the SHA checksum from the [downloads page](https://www.influxdata.com/downloads/#telegraf) + + +{{% /tab-content %}} +{{% tab-content %}} + Choose from the following options to install Telegraf for macOS: - To manually install Telegraf from a file, see the [downloads page](https://www.influxdata.com/downloads/). @@ -201,23 +359,25 @@ The `telegraf` binary installed by Homebrew differs from the macOS `.dmg` builds - `telegraf` (Homebrew) isn't a static binary. - `telegraf` (Homebrew) works with the Telegraf CPU plugin (due to Homebrew support for [Cgo](https://pkg.go.dev/cmd/cgo)). - The `.dmg` builds available on [downloads](https://www.influxdata.com/downloads/) don't support the CPU plugin. + The `.dmg` builds available on the [downloads page](https://www.influxdata.com/downloads/) don't support the CPU plugin. {{% /note %}} To install using Homebrew, do the following: -1. If you haven't already, follow the instructions to install the [Homebrew](http://brew.sh/) package manager. -2. Enter the following commands to update brew and install Telegraf: +1. If you haven't already, follow the instructions to install the [Homebrew](http://brew.sh/) package manager. +2. Enter the following commands to update brew and install Telegraf: - ```zsh - brew update && brew install telegraf - ``` + - The path where `brew` installs the `telegraf.conf` configuration file depends on your system architecture: + ```zsh + brew update && brew install telegraf + ``` - - ARM-based (Apple Silicon) systems: `/opt/homebrew/etc/telegraf.conf` - - Intel-based (x86_64) systems: `/usr/local/etc/telegraf.conf` + The path where `brew` installs the `telegraf.conf` configuration file depends on your system architecture: + + - ARM-based (Apple Silicon) systems: `/opt/homebrew/etc/telegraf.conf` + - Intel-based (x86_64) systems: `/usr/local/etc/telegraf.conf` 3. Choose one of the following methods to start Telegraf and begin collecting and processing metrics: - [Run Telegraf in your terminal](#run-telegraf-in-your-terminal) @@ -234,6 +394,8 @@ To run `telegraf` in your terminal (in the foreground and not as a service), ent {{% /code-tabs %}} {{% code-tab-content %}} + + ```zsh telegraf -config /opt/homebrew/etc/telegraf.conf ``` @@ -241,6 +403,8 @@ telegraf -config /opt/homebrew/etc/telegraf.conf {{% /code-tab-content %}} {{% code-tab-content %}} + + ```zsh telegraf -config /usr/local/etc/telegraf.conf ``` @@ -295,79 +459,68 @@ see [Launch PowerShell as administrator](https://docs.microsoft.com/en-us/powers In PowerShell _as an administrator_, do the following: -1. Use the following commands to download the Telegraf Windows binary - and extract its contents to `C:\Program Files\InfluxData\telegraf\`: +1. Use the following commands to download the Telegraf Windows binary + 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\' - ``` + ```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\' + ``` -2. Choose _one_ of the following steps to place your `telegraf.exe` and `telegraf.conf` files in `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`: - - 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: + - 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.* . - ``` + ```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. + - **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 %}} + {{% 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 %}} + {{% /note %}} -3. Optional: Enable a plugin to collect Windows-specific metrics--for example, uncomment the [`inputs.win_services` plugin](/telegraf/v1/plugins/#input-win_services) configuration line: +3. Optional: Enable a plugin to collect Windows-specific metrics--for example, uncomment the [`inputs.win_services` plugin](/telegraf/v1/plugins/#input-win_services) configuration line: - ```toml - ... - # # Input plugin to report Windows services info. - # # This plugin ONLY supports Windows - [[inputs.win_services]] - ... - ``` - -4. 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 - .\telegraf.exe --service install ` - --config "C:\Program Files\InfluxData\telegraf\telegraf.conf" - ``` - -5. To test that the installation works, enter the following command: - - ```powershell - .\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 - ``` - - + +4. 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 + .\telegraf.exe --service install ` + --config "C:\Program Files\InfluxData\telegraf\telegraf.conf" + ``` + +5. To test that the installation works, enter the following command: + + ```powershell + .\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 + ``` + ### Logging and troubleshooting @@ -388,9 +541,13 @@ The following commands are available: {{< /tab-content >}} {{< /tabs-wrapper >}} -## Generate a custom configuration file +## Generate a configuration file -The `telegraf config` command lets you generate a configuration file using Telegraf's list of plugins. +The `telegraf config` command lets you generate a configuration file from +Telegraf's [plugin list](/telegraf/v1/commands/plugins/). + +- [Create a configuration file with default input and output plugins](#create-a-configuration-file-with-default-input-and-output-plugins) +- [Create a configuration with specific input and output plugins](#create-a-configuration-file-with-specific-input-and-output-plugins) ### Create a configuration file with default input and output plugins @@ -414,11 +571,14 @@ telegraf config > telegraf.conf {{% /code-tab-content %}} {{< /code-tabs-wrapper >}} -The generated file contains settings for all available plugins--some are enabled and the rest are commented out. - ### Create a configuration file with specific input and output plugins -To generate a configuration file that contains settings for only specific input and output plugins, specify `telegraf` plugin filters--for example: +To generate a configuration file that contains settings for only specific plugins, +use the `--input-filter` and `--output-filter` options to +specify [input plugins](/telegraf/v1/plugins/input_plugins) +and [output plugins](/telegraf/v1/plugins/output_plugins/)--for example: + +{{% code-placeholders "cpu|http|influxdb_v2|file" %}} {{< code-tabs-wrapper >}} {{% code-tabs %}} @@ -428,21 +588,23 @@ To generate a configuration file that contains settings for only specific input {{% code-tab-content %}} ```bash telegraf \ ---input-filter [:] \ ---output-filter [:] \ +--input-filter cpu:http \ +--output-filter influxdb_v2:file \ config > telegraf.conf ``` {{% /code-tab-content %}} {{% code-tab-content %}} ```powershell .\telegraf.exe ` ---input-filter [:] ` ---output-filter [:] ` +--input-filter cpu:http ` +--output-filter influxdb_v2:file ` config > telegraf.conf ``` {{% /code-tab-content %}} {{< /code-tabs-wrapper >}} +{{% /code-placeholders %}} + For more advanced configuration details, see the [configuration documentation](/telegraf/v1/administration/configuration/). @@ -461,27 +623,38 @@ Use the Telegraf custom builder tool to compile Telegraf with only the plugins y ### Build the custom builder tool -1. Clone the Telegraf repository: +1. Clone the Telegraf repository and then change into the repository + directory--for example, enter the following command in your terminal: - ```bash - git clone https://github.com/influxdata/telegraf.git - ``` -2. Change directories into the top-level of the Telegraf repository: + - ```bash - cd telegraf - ``` -3. Build the Telegraf custom builder tool by entering the following command: + - ```bash - make build_tools - ``` + ```bash + git clone https://github.com/influxdata/telegraf.git && cd ./telegraf + ``` +2. To build the Telegraf custom builder tool, enter the following command: + + + + ```bash + make build_tools + ``` ### Run the custom builder to create a `telegraf` binary -The custom builder builds a `telegraf` binary with only the plugins included in the specified configuration files or directories. +The custom builder builds a `telegraf` binary with only the plugins included in +the specified configuration files or directories. -Run the `custom_builder` tool with at least one `--config` or `--config-directory` flag to specify Telegraf configuration files to build from. +Run the `custom_builder` tool with at least one `--config` or `--config-directory` +flag to specify Telegraf configuration files to build from. - `--config`: accepts local file paths and URLs. - `--config-dir`: accepts local directory paths. @@ -492,12 +665,33 @@ You can include multiple `--config` and `--config-dir` flags. ##### Single Telegraf configuration + + + + + + ```bash ./tools/custom_builder/custom_builder --config /etc/telegraf.conf ``` ##### Single Telegraf configuration and Telegraf configuration directory + + + + + + ```bash ./tools/custom_builder/custom_builder \ --config /etc/telegraf.conf \ @@ -506,6 +700,8 @@ You can include multiple `--config` and `--config-dir` flags. ##### Remote Telegraf configuration + + ```bash ./tools/custom_builder/custom_builder \ --config http://url-to-remote-telegraf/telegraf.conf diff --git a/data/products.yml b/data/products.yml index a01d42302..1ba25ac9f 100644 --- a/data/products.yml +++ b/data/products.yml @@ -77,7 +77,7 @@ telegraf: versions: [v1] latest: v1.31 latest_patches: - v1: 1.31.0 + v1: 1.31.3 chronograf: name: Chronograf diff --git a/lefthook.yml b/lefthook.yml index 7608bc2f6..b94242b37 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -50,7 +50,7 @@ pre-commit: tags: test,codeblocks,v2 env: - SERVICE: cloud-pytest - run: docker compose run $SERVICE '{staged_files}' + run: docker compose run --rm --name $SERVICE $SERVICE '{staged_files}' cloud-dedicated-pytest: tags: test,codeblocks,v3 glob: content/influxdb/cloud-dedicated/**/*.md @@ -58,14 +58,14 @@ pre-commit: - SERVICE: cloud-dedicated-pytest run: | ./test/scripts/monitor-tests.sh start $SERVICE ; - docker compose run $SERVICE {staged_files} ; + docker compose run --name $SERVICE $SERVICE {staged_files} ; ./test/scripts/monitor-tests.sh stop $SERVICE cloud-serverless-pytest: tags: test,codeblocks,v3 glob: content/influxdb/cloud-serverless/**/*.md env: - SERVICE: cloud-serverless-pytest - run: docker compose run $SERVICE '{staged_files}' + run: docker compose run --rm --name $SERVICE $SERVICE '{staged_files}' clustered-pytest: tags: test,codeblocks,v3 glob: content/influxdb/clustered/**/*.md @@ -73,20 +73,20 @@ pre-commit: - SERVICE: clustered-pytest run: | ./test/scripts/monitor-tests.sh start $SERVICE ; - docker compose run $SERVICE {staged_files} ; + docker compose run --name $SERVICE $SERVICE {staged_files} ; ./test/scripts/monitor-tests.sh stop $SERVICE telegraf-pytest: tags: test,codeblocks glob: content/telegraf/**/*.md env: - SERVICE: telegraf-pytest - run: docker compose run $SERVICE '{staged_files}' + run: docker compose run --rm --name $SERVICE $SERVICE '{staged_files}' v2-pytest: tags: test,codeblocks,v2 glob: content/influxdb/v2/**/*.md env: - SERVICE: v2-pytest - run: docker compose run --rm $SERVICE '{staged_files}' + run: docker compose run --rm --name $SERVICE $SERVICE '{staged_files}' prettier: tags: frontend,style glob: "*.{css,js,ts,jsx,tsx}" diff --git a/static/img/telegraf/downloads-telegraf-linux-amd64.png b/static/img/telegraf/downloads-telegraf-linux-amd64.png new file mode 100644 index 000000000..879af9f7a Binary files /dev/null and b/static/img/telegraf/downloads-telegraf-linux-amd64.png differ diff --git a/test/Dockerfile.test-oss.centos b/test/Dockerfile.test-oss.centos new file mode 100644 index 000000000..281dc4e31 --- /dev/null +++ b/test/Dockerfile.test-oss.centos @@ -0,0 +1,55 @@ +# Description: Dockerfile for testing installation of InfluxDB and clients on CentOS Stream 9. + +# Example build command: +# docker buildx build -t influxdatadocs/oss-centos --file test/Dockerfile.test-oss.centos . + +# Example run command--logs are stored in the volume `influxdatadocs-oss-centos-log`: +# docker run --rm --mount type=volume,src=influxdatadocs-oss-centos-log,dst=/var/log/ influxdatadocs/oss-centos + + +FROM dokken/centos-stream-9:latest AS influxdb +LABEL name="test-oss-centos" +LABEL description="InfluxData Docs Test OSS install on CentOS" + +LABEL "com.influxdata.docs"="https://docs.influxdata.com/influxdb/v2/install/?t=Linux" + +ARG INFLUXDB_LATEST_PATCH=2.7.10 +ARG TELEGRAF_LATEST_PATCH=1.31.3 +ARG PUBLIC_SHA=943666881a1b8d9b849b74caebf02d3465d6beb716510d86a39f6c8e8dac7515 +ARG basearch=aarch64 + +# Install InfluxDB keys to verify client installs. + +RUN curl --silent --location -O \ + https://repos.influxdata.com/influxdata-archive.key \ + && echo "${PUBLIC_SHA} influxdata-archive.key" \ + | sha256sum -c && cat influxdata-archive.key \ + | gpg --dearmor \ + | tee /etc/pki/rpm-gpg/RPM-GPG-KEY-influxdata > /dev/null + +# Follow the documentation to add the InfluxData repository to the list of repositories. +RUN cat < /var/log/influxd.log 2>&1 & while ! curl -s http://localhost:8086/health | grep -q '\"status\":\"pass\"'; do sleep 1; done; telegraf --config /etc/telegraf/telegraf.conf --test"] diff --git a/test/Dockerfile.test-oss.ubuntu b/test/Dockerfile.test-oss.ubuntu new file mode 100644 index 000000000..620748cd7 --- /dev/null +++ b/test/Dockerfile.test-oss.ubuntu @@ -0,0 +1,41 @@ +# Description: Dockerfile for testing installation of InfluxDB and clients on Ubuntu. + +# Example build command: +# docker buildx build -t influxdatadocs/oss-ubuntu --file test/Dockerfile.test-oss.ubuntu . + +# Example run command--logs are stored in the volume `influxdatadocs-oss-ubuntu-log`: +# docker run --rm --mount type=volume,src=influxdatadocs-oss-ubuntu-log,dst=/var/log/ influxdatadocs/oss-ubuntu + + +FROM ubuntu:latest AS influxdb +LABEL name="test-oss-ubuntu" +LABEL description="InfluxData Docs Test OSS install on Ubuntu" + +LABEL "com.influxdata.docs"="https://docs.influxdata.com/influxdb/v2/install/?t=Linux" + +ARG INFLUXDB_LATEST_PATCH=2.7.10 +ARG TELEGRAF_LATEST_PATCH=1.31.3 +ARG PUBLIC_SHA=943666881a1b8d9b849b74caebf02d3465d6beb716510d86a39f6c8e8dac7515 +ARG basearch=aarch64 + +# Install gnupg2 and curl to verify client installs. +RUN apt-get update && apt-get install -y gnupg2 curl + +# Install InfluxDB keys to verify client installs. +RUN curl --silent --location -O \ + https://repos.influxdata.com/influxdata-archive.key \ + && echo "${PUBLIC_SHA} influxdata-archive.key" \ + | sha256sum -c && cat influxdata-archive.key \ + | gpg --dearmor \ + | tee /etc/apt/trusted.gpg.d/influxdata-archive.gpg > /dev/null \ + && echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive.gpg] https://repos.influxdata.com/debian stable main' \ + | tee /etc/apt/sources.list.d/influxdata.list + +# Install InfluxDB and clients to use in tests. + +# Follow the Telegraf install instructions (https://docs.influxdata.com/telegraf/v1/install/?t=curl), except for sudo (which isn't available in Docker). +RUN apt-get update && apt-get install influxdb2 influxdb2-cli telegraf + +ENTRYPOINT ["/bin/bash"] +# Run InfluxDB in the background, wait for it to start, and then test Telegraf. +CMD ["-c", "influxd > /var/log/influxd.log 2>&1 & while ! curl -s http://localhost:8086/health | grep -q '\"status\":\"pass\"'; do sleep 1; done; telegraf --config /etc/telegraf/telegraf.conf --test"] diff --git a/test/scripts/get-container-info.sh b/test/scripts/get-container-info.sh new file mode 100644 index 000000000..3b61ee206 --- /dev/null +++ b/test/scripts/get-container-info.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# Function to check if the script is running inside a Docker container +is_running_in_docker() { + if [ -f /.dockerenv ]; then + return 0 + fi + + if grep -qE '/docker|/lxc' /proc/1/cgroup; then + return 0 + fi + + return 1 +} diff --git a/test/scripts/prepare-content.sh b/test/scripts/prepare-content.sh index d678362a4..34b01a3ba 100644 --- a/test/scripts/prepare-content.sh +++ b/test/scripts/prepare-content.sh @@ -97,8 +97,17 @@ function substitute_placeholders { # v2-specific replacements. sed -i 's|https:\/\/us-west-2-1.aws.cloud2.influxdata.com|$INFLUX_HOST|g; - s|{{< latest-patch >}}|${influxdb_latest_patches_v2}|g; - s|{{< latest-patch cli=true >}}|${influxdb_latest_cli_v2}|g;' \ + s|influxdb2-{{< latest-patch >}}|influxdb2-${influxdb_latest_patches_v2}|g; + s|{{< latest-patch cli=true >}}|${influxdb_latest_cli_v2}|g; + s|influxdb2-{{% latest-patch %}}|influxdb2-${influxdb_latest_patches_v2}|g; + s|{{% latest-patch cli=true %}}|${influxdb_latest_cli_v2}|g;' \ + $file + + # Telegraf-specific replacements + sed -i 's|telegraf-{{< latest-patch >}}|telegraf-${telegraf_latest_patches_v1}|g; + s|telegraf-{{% latest-patch %}}|telegraf-${telegraf_latest_patches_v1}|g; + s/--input-filter \[:\]/--input-filter cpu:influxdb/g; + s/--output-filter \[:\]/--output-filter influxdb_v2:file/g;' \ $file # Skip package manager commands. @@ -107,6 +116,7 @@ function substitute_placeholders { $file # Environment-specific replacements. + # You can't use sudo with Docker. sed -i 's|sudo ||g;' \ $file fi