example

package
v1.28.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 9 Imported by: 0

README

Example Input Plugin

The example plugin gathers metrics about example things. This description explains at a high level what the plugin does and provides links to where additional information can be found.

Telegraf minimum version: Telegraf x.x Plugin minimum tested version: x.x

Global configuration options

In addition to the plugin-specific configuration settings, plugins support additional global and plugin configuration settings. These settings are used to modify metrics, tags, and field or create aliases and configure ordering, etc. See the CONFIGURATION.md for more details.

Configuration

# This is an example plugin
[[inputs.example]]
  example_option = "example_value"

Running telegraf --usage <plugin-name> also gives the sample TOML configuration.

example_option

A more in depth description of an option can be provided here, but only do so if the option cannot be fully described in the sample config.

Metrics

Here you should add an optional description and links to where the user can get more information about the measurements.

If the output is determined dynamically based on the input source, or there are more metrics than can reasonably be listed, describe how the input is mapped to the output.

  • measurement1

    • tags:
      • tag1 (optional description)
      • tag2
    • fields:
      • field1 (type, unit)
      • field2 (float, percent)
  • measurement2

    • tags:
      • tag3
    • fields:
      • field3 (integer, bytes)
      • field4 (integer, green=1 yellow=2 red=3)
      • field5 (string)
      • field6 (float)
      • field7 (boolean)

Sample Queries

This section can contain some useful InfluxDB queries that can be used to get started with the plugin or to generate dashboards. For each query listed, describe at a high level what data is returned.

Get the max, mean, and min for the measurement in the last hour:

SELECT max(field1), mean(field1), min(field1) FROM measurement1 WHERE tag1=bar AND time > now() - 1h GROUP BY tag

Troubleshooting

This optional section can provide basic troubleshooting steps that a user can perform.

Example Output

This section shows example output in Line Protocol format. You can often use telegraf --input-filter <plugin-name> --test or use the file output to get this information.

measurement1,tag1=foo,tag2=bar field1=1i,field2=2.1 1453831884664956455
measurement2,tag1=foo,tag2=bar,tag3=baz field3=1i 1453831884664956455

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Example

type Example struct {
	// Example for a mandatory option to set a tag
	DeviceName string `toml:"device_name"`

	// Config options are converted to the correct type automatically
	NumberFields int64 `toml:"number_fields"`

	// We can also use booleans and have diverging names between user-configuration options and struct members
	EnableRandomVariable bool `toml:"enable_random"`

	// Example of passing a duration option allowing the format of e.g. "100ms", "5m" or "1h"
	Timeout config.Duration `toml:"timeout"`

	// Example of passing a password/token/username or other sensitive data with the secret-store
	UserName config.Secret `toml:"username"`
	Password config.Secret `toml:"password"`

	// Telegraf logging facility
	// The exact name is important to allow automatic initialization by telegraf.
	Log telegraf.Logger `toml:"-"`
	// contains filtered or unexported fields
}

Example struct should be named the same as the Plugin

func (*Example) Gather

func (m *Example) Gather(acc telegraf.Accumulator) error

Gather defines what data the plugin will gather.

func (*Example) Init

func (m *Example) Init() error

Init can be implemented to do one-time processing stuff like initializing variables

func (*Example) SampleConfig

func (*Example) SampleConfig() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL