Skip to content

Commit

Permalink
feat: migrate input plugins to new sample config format (A-L)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Spaink committed Apr 6, 2022
1 parent 57dc749 commit 3ace280
Show file tree
Hide file tree
Showing 225 changed files with 2,314 additions and 3,948 deletions.
32 changes: 2 additions & 30 deletions plugins/inputs/activemq/activemq.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:generate go run ../../../tools/generate_plugindata/main.go
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
package activemq

import (
Expand Down Expand Up @@ -82,36 +84,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
6 changes: 6 additions & 0 deletions plugins/inputs/activemq/activemq_sample_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
package activemq

func (a *ActiveMQ) SampleConfig() string {
return `{{ .SampleConfig }}`
}
52 changes: 2 additions & 50 deletions plugins/inputs/aerospike/aerospike.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:generate go run ../../../tools/generate_plugindata/main.go
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
package aerospike

import (
Expand Down Expand Up @@ -42,48 +44,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 +52,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
6 changes: 6 additions & 0 deletions plugins/inputs/aerospike/aerospike_sample_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// 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
116 changes: 2 additions & 114 deletions plugins/inputs/aliyuncms/aliyuncms.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:generate go run ../../../tools/generate_plugindata/main.go
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
package aliyuncms

import (
Expand All @@ -20,110 +22,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 +105,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
6 changes: 6 additions & 0 deletions plugins/inputs/aliyuncms/aliyuncms_sample_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// DON'T EDIT; This file is used as a template by tools/generate_plugindata
package aliyuncms

func (s *AliyunCMS) SampleConfig() string {
return `{{ .SampleConfig }}`
}
20 changes: 2 additions & 18 deletions plugins/inputs/amd_rocm_smi/amd_rocm_smi.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:generate go run ../../../tools/generate_plugindata/main.go
//go:generate go run ../../../tools/generate_plugindata/main.go --clean
package amd_rocm_smi

import (
Expand All @@ -22,24 +24,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
6 changes: 6 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,6 @@
// 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 }}`
}
2 changes: 2 additions & 0 deletions plugins/inputs/amqp_consumer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ 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
Expand Down
Loading

0 comments on commit 3ace280

Please sign in to comment.