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

feat: migrate input plugins to new sample config format (A-L) #10924

Merged
merged 24 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/inputs/activemq/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This plugin gather queues, topics & subscribers metrics using ActiveMQ Console A
## Configuration

```toml
# Description
# Gather ActiveMQ metrics
[[inputs.activemq]]
## ActiveMQ WebConsole URL
url = "http://127.0.0.1:8161"
Expand Down
30 changes: 0 additions & 30 deletions plugins/inputs/activemq/activemq.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,36 +82,6 @@ type Stats struct {
DequeueCounter int `xml:"dequeueCounter,attr"`
}

var sampleConfig = `
## ActiveMQ WebConsole URL
url = "http://127.0.0.1:8161"

## Credentials for basic HTTP authentication
# username = "admin"
# password = "admin"

## Required ActiveMQ webadmin root path
# webadmin = "admin"

## Maximum time to receive response.
# response_timeout = "5s"

## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify = false
`

func (a *ActiveMQ) Description() string {
return "Gather ActiveMQ metrics"
}

func (a *ActiveMQ) SampleConfig() string {
return sampleConfig
}

func (a *ActiveMQ) createHTTPClient() (*http.Client, error) {
tlsCfg, err := a.ClientConfig.TLSConfig()
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions plugins/inputs/activemq/activemq_sample_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:generate go run ../../../tools/generate_plugindata/main.go
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
package activemq

func (a *ActiveMQ) SampleConfig() string {
return `{{ .SampleConfig }}`
}
50 changes: 0 additions & 50 deletions plugins/inputs/aerospike/aerospike.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,48 +42,6 @@ type Aerospike struct {
NumberHistogramBuckets int `toml:"num_histogram_buckets"`
}

var sampleConfig = `
## Aerospike servers to connect to (with port)
## This plugin will query all namespaces the aerospike
## server has configured and get stats for them.
servers = ["localhost:3000"]

# username = "telegraf"
# password = "pa$$word"

## Optional TLS Config
# enable_tls = false
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
# tls_name = "tlsname"
## If false, skip chain & host verification
# insecure_skip_verify = true

# Feature Options
# Add namespace variable to limit the namespaces executed on
# Leave blank to do all
# disable_query_namespaces = true # default false
# namespaces = ["namespace1", "namespace2"]

# Enable set level telemetry
# query_sets = true # default: false
# Add namespace set combinations to limit sets executed on
# Leave blank to do all sets
# sets = ["namespace1/set1", "namespace1/set2", "namespace3"]

# Histograms
# enable_ttl_histogram = true # default: false
# enable_object_size_linear_histogram = true # default: false

# by default, aerospike produces a 100 bucket histogram
# this is not great for most graphing tools, this will allow
# the ability to squash this to a smaller number of buckets
# To have a balanced histogram, the number of buckets chosen
# should divide evenly into 100.
# num_histogram_buckets = 100 # default: 10
`

// On the random chance a hex value is all digits
// these are fields that can contain hex and should always be strings
var protectedHexFields = map[string]bool{
Expand All @@ -92,14 +50,6 @@ var protectedHexFields = map[string]bool{
"paxos_principal": true,
}

func (a *Aerospike) SampleConfig() string {
return sampleConfig
}

func (a *Aerospike) Description() string {
return "Read stats from aerospike server(s)"
}

func (a *Aerospike) Gather(acc telegraf.Accumulator) error {
if !a.initialized {
tlsConfig, err := a.ClientConfig.TLSConfig()
Expand Down
8 changes: 8 additions & 0 deletions plugins/inputs/aerospike/aerospike_sample_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:generate go run ../../../tools/generate_plugindata/main.go
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
package aerospike

func (a *Aerospike) SampleConfig() string {
return `{{ .SampleConfig }}`
}
2 changes: 2 additions & 0 deletions plugins/inputs/aliyuncms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ In the following order the plugin will attempt to authenticate.
## Configuration

```toml
# Pull Metric Statistics from Aliyun CMS
[[inputs.aliyuncms]]
## Aliyun Credentials
## Credentials are loaded in the following order
## 1) Ram RoleArn credential
Expand Down
114 changes: 0 additions & 114 deletions plugins/inputs/aliyuncms/aliyuncms.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,110 +20,6 @@ import (
"github.com/pkg/errors"
)

const (
description = "Pull Metric Statistics from Aliyun CMS"
sampleConfig = `
## Aliyun Credentials
## Credentials are loaded in the following order
## 1) Ram RoleArn credential
## 2) AccessKey STS token credential
## 3) AccessKey credential
## 4) Ecs Ram Role credential
## 5) RSA keypair credential
## 6) Environment variables credential
## 7) Instance metadata credential

# access_key_id = ""
# access_key_secret = ""
# access_key_sts_token = ""
# role_arn = ""
# role_session_name = ""
# private_key = ""
# public_key_id = ""
# role_name = ""

## Specify the ali cloud region list to be queried for metrics and objects discovery
## If not set, all supported regions (see below) would be covered, it can provide a significant load on API, so the recommendation here
## is to limit the list as much as possible. Allowed values: https://www.alibabacloud.com/help/zh/doc-detail/40654.htm
## Default supported regions are:
## 21 items: cn-qingdao,cn-beijing,cn-zhangjiakou,cn-huhehaote,cn-hangzhou,cn-shanghai,cn-shenzhen,
## cn-heyuan,cn-chengdu,cn-hongkong,ap-southeast-1,ap-southeast-2,ap-southeast-3,ap-southeast-5,
## ap-south-1,ap-northeast-1,us-west-1,us-east-1,eu-central-1,eu-west-1,me-east-1
##
## From discovery perspective it set the scope for object discovery, the discovered info can be used to enrich
## the metrics with objects attributes/tags. Discovery is supported not for all projects (if not supported, then
## it will be reported on the start - for example for 'acs_cdn' project:
## 'E! [inputs.aliyuncms] Discovery tool is not activated: no discovery support for project "acs_cdn"' )
## Currently, discovery supported for the following projects:
## - acs_ecs_dashboard
## - acs_rds_dashboard
## - acs_slb_dashboard
## - acs_vpc_eip
regions = ["cn-hongkong"]

# The minimum period for AliyunCMS metrics is 1 minute (60s). However not all
# metrics are made available to the 1 minute period. Some are collected at
# 3 minute, 5 minute, or larger intervals.
# See: https://help.aliyun.com/document_detail/51936.html?spm=a2c4g.11186623.2.18.2bc1750eeOw1Pv
# Note that if a period is configured that is smaller than the minimum for a
# particular metric, that metric will not be returned by the Aliyun OpenAPI
# and will not be collected by Telegraf.
#
## Requested AliyunCMS aggregation Period (required - must be a multiple of 60s)
period = "5m"

## Collection Delay (required - must account for metrics availability via AliyunCMS API)
delay = "1m"

## Recommended: use metric 'interval' that is a multiple of 'period' to avoid
## gaps or overlap in pulled data
interval = "5m"

## Metric Statistic Project (required)
project = "acs_slb_dashboard"

## Maximum requests per second, default value is 200
ratelimit = 200

## How often the discovery API call executed (default 1m)
#discovery_interval = "1m"

## Metrics to Pull (Required)
[[inputs.aliyuncms.metrics]]
## Metrics names to be requested,
## described here (per project): https://help.aliyun.com/document_detail/28619.html?spm=a2c4g.11186623.6.690.1938ad41wg8QSq
names = ["InstanceActiveConnection", "InstanceNewConnection"]

## Dimension filters for Metric (these are optional).
## This allows to get additional metric dimension. If dimension is not specified it can be returned or
## the data can be aggregated - it depends on particular metric, you can find details here: https://help.aliyun.com/document_detail/28619.html?spm=a2c4g.11186623.6.690.1938ad41wg8QSq
##
## Note, that by default dimension filter includes the list of discovered objects in scope (if discovery is enabled)
## Values specified here would be added into the list of discovered objects.
## You can specify either single dimension:
#dimensions = '{"instanceId": "p-example"}'

## Or you can specify several dimensions at once:
#dimensions = '[{"instanceId": "p-example"},{"instanceId": "q-example"}]'

## Enrichment tags, can be added from discovery (if supported)
## Notation is <measurement_tag_name>:<JMES query path (https://jmespath.org/tutorial.html)>
## To figure out which fields are available, consult the Describe<ObjectType> API per project.
## For example, for SLB: https://api.aliyun.com/#/?product=Slb&version=2014-05-15&api=DescribeLoadBalancers&params={}&tab=MOCK&lang=GO
#tag_query_path = [
# "address:Address",
# "name:LoadBalancerName",
# "cluster_owner:Tags.Tag[?TagKey=='cs.cluster.name'].TagValue | [0]"
# ]
## The following tags added by default: regionId (if discovery enabled), userId, instanceId.

## Allow metrics without discovery data, if discovery is enabled. If set to true, then metric without discovery
## data would be emitted, otherwise dropped. This cane be of help, in case debugging dimension filters, or partial coverage
## of discovery scope vs monitoring scope
#allow_dps_without_discovery = false
`
)

type (
// AliyunCMS is aliyun cms config info.
AliyunCMS struct {
Expand Down Expand Up @@ -207,16 +103,6 @@ var aliyunRegionList = []string{
"me-east-1",
}

// SampleConfig implements telegraf.Inputs interface
func (s *AliyunCMS) SampleConfig() string {
return sampleConfig
}

// Description implements telegraf.Inputs interface
func (s *AliyunCMS) Description() string {
return description
}

// Init perform checks of plugin inputs and initialize internals
func (s *AliyunCMS) Init() error {
if s.Project == "" {
Expand Down
8 changes: 8 additions & 0 deletions plugins/inputs/aliyuncms/aliyuncms_sample_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:generate go run ../../../tools/generate_plugindata/main.go
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
package aliyuncms

func (s *AliyunCMS) SampleConfig() string {
return `{{ .SampleConfig }}`
}
2 changes: 1 addition & 1 deletion plugins/inputs/amd_rocm_smi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This plugin uses a query on the [`rocm-smi`](https://github.com/RadeonOpenComput
## Configuration

```toml
# Pulls statistics from AMD GPUs attached to the host
# Query statistics from AMD Graphics cards using rocm-smi binary
[[inputs.amd_rocm_smi]]
## Optional: path to rocm-smi binary, defaults to $PATH via exec.LookPath
# bin_path = "/opt/rocm/bin/rocm-smi"
Expand Down
18 changes: 0 additions & 18 deletions plugins/inputs/amd_rocm_smi/amd_rocm_smi.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,6 @@ type ROCmSMI struct {
Timeout config.Duration
}

// Description returns the description of the ROCmSMI plugin
func (rsmi *ROCmSMI) Description() string {
return "Query statistics from AMD Graphics cards using rocm-smi binary"
}

var ROCmSMIConfig = `
## Optional: path to rocm-smi binary, defaults to $PATH via exec.LookPath
# bin_path = "/opt/rocm/bin/rocm-smi"

## Optional: timeout for GPU polling
# timeout = "5s"
`

// SampleConfig returns the sample configuration for the ROCmSMI plugin
func (rsmi *ROCmSMI) SampleConfig() string {
return ROCmSMIConfig
}

// Gather implements the telegraf interface
func (rsmi *ROCmSMI) Gather(acc telegraf.Accumulator) error {
if _, err := os.Stat(rsmi.BinPath); os.IsNotExist(err) {
Expand Down
8 changes: 8 additions & 0 deletions plugins/inputs/amd_rocm_smi/amd_rocm_smi_sample_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:generate go run ../../../tools/generate_plugindata/main.go
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
package amd_rocm_smi

func (rsmi *ROCmSMI) SampleConfig() string {
return `{{ .SampleConfig }}`
}
7 changes: 3 additions & 4 deletions plugins/inputs/amqp_consumer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ For an introduction to AMQP see:
- [amqp - concepts](https://www.rabbitmq.com/tutorials/amqp-concepts.html)
- [rabbitmq: getting started](https://www.rabbitmq.com/getstarted.html)

## Configuration

The following defaults are known to work with RabbitMQ:

```toml
# AMQP consumer plugin
[[inputs.amqp_consumer]]
## Broker to consume from.
## deprecated in 1.7; use the brokers option
# url = "amqp://localhost:5672/influxdb"

## Brokers to consume from. If multiple brokers are specified a random broker
## will be selected anytime a connection is established. This can be
## helpful for load balancing when not using a dedicated load balancer.
Expand Down
Loading