diff --git a/telegraf/content.md b/telegraf/content.md index 22df8ab253f8..fd76add97103 100644 --- a/telegraf/content.md +++ b/telegraf/content.md @@ -1,44 +1,39 @@ -# Telegraf +# What is telegraf? -Telegraf is an open source agent written in Go for collecting metrics and data on the system it's running on or from other services. Telegraf writes data it collects to InfluxDB in the correct format. +Telegraf is an open source agent for collecting, processing, aggregating, and writing metrics. Based on a plugin system to enable developers in the community to easily add support for additional metric collection. There are five distinct types of plugins: + +- Input plugins collect metrics from the system, services, or 3rd party APIs +- Output plugins write metrics to various destinations +- Processor plugins transform, decorate, and/or filter metrics +- Aggregator plugins create aggregate metrics (e.g. mean, min, max, quantiles, etc.) +- Secret Store plugins are used to hide secrets from the configuration file [Telegraf Official Docs](https://docs.influxdata.com/telegraf/latest/get_started/) %%LOGO%% -## Using this image +# How to use this image -### Exposed Ports +## Exposed Ports -- 8125 StatsD +- 8125 UDP - 8092 UDP - 8094 TCP -### Using the default configuration - -The default configuration requires a running InfluxDB instance as an output plugin. Ensure that InfluxDB is running on port 8086 before starting the Telegraf container. - -Minimal example to start an InfluxDB container: - -```console -$ docker run -d --name influxdb -p 8086:8086 influxdb -``` - -Starting Telegraf using the default config, which connects to InfluxDB at `http://localhost:8086/`: +## Configuration file -```console -$ docker run --net=container:influxdb %%IMAGE%% -``` +The user is required to provide a valid configuration to use the image. A valid configuration has at least one input and one output plugin specified. The following will walk through the general steps to get going. -### Using a custom config file +### Basic Example -First, generate a sample configuration and save it as `telegraf.conf` on the host: +Configuration files are TOML-based files that declare which plugins to use. A very simple configuration file, `telegraf.conf`, that collects metrics from the system CPU and outputs the metrics to stdout looks like the following: -```console -$ docker run --rm %%IMAGE%% telegraf config > telegraf.conf +```toml +[[inputs.cpu]] +[[outputs.file]] ``` -Once you've customized `telegraf.conf`, you can run the Telegraf container with it mounted in the expected location: +Once a user has a customized configuration file, they can launch a Telegraf container with it mounted in the expected location: ```console $ docker run -v $PWD/telegraf.conf:/etc/telegraf/telegraf.conf:ro %%IMAGE%% @@ -48,131 +43,26 @@ Modify `$PWD` to the directory where you want to store the configuration file. Read more about the Telegraf configuration [here](https://docs.influxdata.com/telegraf/latest/administration/configuration/). -### Using the container with input plugins - -These examples assume you are using a custom configuration file that takes advantage of Docker's built-in service discovery capability. In order to do so, we'll first create a new network: - -```console -$ docker network create influxdb -``` +### Sample Configuration -Next, we'll start our InfluxDB container named `influxdb`: +Users can generate a sample configuration using the `config` subcommand. This will provide the user with a basic config that has a handful of input plugins enabled that collect data from the system. However, the user will still need to configure at least one output before the file is ready for use: ```console -$ docker run -d --name=influxdb \ - --net=influxdb \ - influxdb -``` - -The `telegraf.conf` configuration can now resolve the `influxdb` container by name: - -```toml -[[outputs.influxdb]] - urls = ["http://influxdb:8086"] -``` - -Finally, we start our Telegraf container and verify functionality: - -```console -$ docker run -d --name=telegraf \ - --net=influxdb \ - -v $PWD/telegraf.conf:/etc/telegraf/telegraf.conf:ro \ - %%IMAGE%% -$ docker logs -f telegraf -``` - -#### Aerospike - -Start an instance of aerospike: - -```console -$ docker run -d --name aerospike \ - --net=influxdb \ - -p 3000-3003:3000-3003 \ - aerospike -``` - -Edit your Telegraf config file and set the correct connection parameter for Aerospike: - -```toml -[[inputs.aerospike]] - servers = ["aerospike:3000"] -``` - -Restart your `telegraf` container to pick up the changes: - -```console -$ docker restart telegraf -``` - -#### Nginx - -Create an `nginx_status.conf` configuration file to expose metric data: - -```nginx -server { - listen 8090; - location /nginx_status { - stub_status; - access_log off; - } -} -``` - -Start an Nginx container utilizing it: - -```console -$ docker run -d --name=nginx \ - --net=influxdb \ - -p 8090:8090 -p 8080:80 \ - -v $PWD/nginx_status.conf:/etc/nginx/conf.d/nginx_status.conf:ro \ - nginx -``` - -Verify the status page: [http://localhost:8090/nginx_status](http://localhost:8090/nginx_status). - -Configure the nginx input plugin in your Telegraf configuration file: - -```toml -[[inputs.nginx]] - urls = ["http://nginx:8090/nginx_status"] -``` - -Restart your `telegraf` container to pick up the changes: - -```console -$ docker restart telegraf -``` - -#### StatsD - -Telegraf has a StatsD plugin, allowing Telegraf to run as a StatsD server that metrics can be sent to. In order for this to work, you must first configure the [StatsD plugin](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/statsd) in your config file. - -Run Telegraf with the UDP port 8125 exposed: - -```console -$ docker run -d --name=telegraf \ - --net=influxdb \ - -p 8125:8125/udp \ - -v $PWD/telegraf.conf:/etc/telegraf/telegraf.conf:ro \ - %%IMAGE%% -``` - -Send Mock StatsD data: - -```console -$ for i in {1..50}; do echo $i;echo "foo:1|c" | nc -u -w0 127.0.0.1 8125; done +$ docker run --rm %%IMAGE%% telegraf config > telegraf.conf ``` -Check that the measurement `foo` is added in the DB. +## Supported Plugins Reference -### Supported Plugins Reference +The following are links to the various plugins that are available in Telegraf: -- [Input Plugins](https://docs.influxdata.com/telegraf/latest/plugins/inputs/) +- [Input Plugins](https://docs.influxdata.com/telegraf/latest/plugins/#input-plugins) +- [Output Plugins](https://docs.influxdata.com/telegraf/latest/plugins/#output-plugins) +- [Processor Plugins](https://docs.influxdata.com/telegraf/latest/plugins/#processor-plugins) +- [Aggregator Plugins](https://docs.influxdata.com/telegraf/latest/plugins/#aggregator-plugins) -- [Output Plugins](https://docs.influxdata.com/telegraf/latest/plugins/outputs/) +# Examples -### Monitoring the Docker Engine Host +## Monitoring the Docker Engine Host One common use case for Telegraf is to monitor the Docker Engine Host from within a container. The recommended technique is to mount the host filesystems into the container and use environment variables to instruct Telegraf where to locate the filesystems. @@ -191,7 +81,7 @@ $ docker run -d --name=telegraf \ %%IMAGE%% ``` -### Monitoring docker containers +## Monitoring docker containers To monitor other docker containers, you can use the docker plugin and mount the docker socket into the container. An example configuration is below: @@ -212,7 +102,7 @@ $ docker run -d --name=telegraf \ Refer to the docker [plugin documentation](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/docker/README.md) for more information. -### Install Additional Packages +## Install Additional Packages Some plugins require additional packages to be installed. For example, the `ntpq` plugin requires `ntpq` command. It is recommended to create a custom derivative image to install any needed commands. diff --git a/telegraf/logo.png b/telegraf/logo.png index 814b2d78b596..79a22fa97edd 100644 Binary files a/telegraf/logo.png and b/telegraf/logo.png differ