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

chore: Embed sample configurations into README for inputs #11136

Merged
merged 29 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
247fc73
Allow parallel generation of sample-configs.
srebhan May 12, 2022
b3e68dd
Add generator to embedd sample-configs into the README.md.
srebhan May 13, 2022
b2fb4d1
Ensure we build the readme embedding generator.
srebhan May 13, 2022
6297204
Convert Modbus over to the new generator.
srebhan May 13, 2022
103fc31
Simplify ipmi_sensor initialization.
srebhan May 18, 2022
26e6105
Cleanup diskio initialization procedure.
srebhan May 18, 2022
0482793
Cleanup multifile initialization procedure.
srebhan May 18, 2022
03b5c50
Simplify iptables initialization.
srebhan May 18, 2022
32129f2
Simplify pf initialization.
srebhan May 18, 2022
524d82d
Simplify sysstat initialization and tests.
srebhan May 18, 2022
a2e0a37
Simplify sensors initialization.
srebhan May 18, 2022
6e4d508
Simplify sysstat initialization.
srebhan May 18, 2022
a0ba5a2
Simplify fail2ban initialization and tests.
srebhan May 18, 2022
3947a77
Use the newly created 'sample.conf' files and embed them in the code.
srebhan May 18, 2022
0c686d7
Add the include tag(s) to the README.md files.
srebhan May 18, 2022
9d7da1b
Add generated README for modbus.
srebhan May 18, 2022
88feccd
Switch generation of README for inputs to using 'sample.conf' as a si…
srebhan May 18, 2022
6dabfd5
Fix README.md include statement that were added to the wrong toml sec…
srebhan May 18, 2022
af690f8
Add generator statements to the input plugins.
srebhan May 18, 2022
2ec17b5
Ignore the generator binary in GIT.
srebhan May 18, 2022
e8c50a8
Fix linter issues.
srebhan May 18, 2022
e706d44
Fix ethtool SampleConfig().
srebhan May 18, 2022
c399fc0
Fix linter issues.
srebhan May 19, 2022
c7d1b22
Fix markdown linter issues.
srebhan May 19, 2022
e9919c1
Fix processes plugin.
srebhan May 19, 2022
40dc9bc
Remove unused variable.
srebhan May 20, 2022
4def2b2
Fix markdown linter issue.
srebhan May 23, 2022
f6c7cc4
Update cpu sample.conf with new option.
srebhan May 23, 2022
218589f
Update intel_powerstat sample.conf.
srebhan May 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/telegraf
/telegraf.exe
/telegraf.gz
/tools/readme_config_includer/generator
/vendor
.DS_Store
process.yml
Expand Down
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,22 @@ versioninfo:
go run scripts/generate_versioninfo/main.go; \
go generate cmd/telegraf/telegraf_windows.go; \

.PHONY: build_generator
build_generator:
go build -o ./tools/readme_config_includer/generator ./tools/readme_config_includer/generator.go

insert_config_to_readme_%: build_generator
go generate -run="readme_config_includer/generator$$" ./plugins/$*/...

generate_plugins_%: build_generator
go generate -run="plugindata/main.go$$" ./plugins/$*/...

.PHONY: generate
generate:
go generate -run="plugindata/main.go$$" ./plugins/inputs/... ./plugins/outputs/... ./plugins/processors/... ./plugins/aggregators/...
generate: insert_config_to_readme_inputs generate_plugins_outputs generate_plugins_processors generate_plugins_aggregators

.PHONY: generate-clean
generate-clean:
go generate -run="plugindata/main.go --clean" ./plugins/inputs/... ./plugins/outputs/... ./plugins/processors/... ./plugins/aggregators/...
go generate -run="plugindata/main.go --clean" ./plugins/outputs/... ./plugins/processors/... ./plugins/aggregators/...
sspaink marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: build
build:
Expand Down Expand Up @@ -223,6 +232,8 @@ clean:
rm -f telegraf
rm -f telegraf.exe
rm -rf build
rm -rf tools/readme_config_includer/generator
rm -rf tools/readme_config_includer/generator.exe

.PHONY: docker-image
docker-image:
Expand Down
2 changes: 1 addition & 1 deletion docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ The inverse of `tagpass`. If a match is found the metric is discarded. This
is tested on metrics after they have passed the `tagpass` test.

> NOTE: Due to the way TOML is parsed, `tagpass` and `tagdrop` parameters must be
defined at the *_end_* of the plugin definition, otherwise subsequent plugin config
defined at the **end** of the plugin definition, otherwise subsequent plugin config
options will be interpreted as part of the tagpass/tagdrop tables.

### Modifiers
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/activemq/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This plugin gather queues, topics & subscribers metrics using ActiveMQ Console A

## Configuration

```toml
```toml @sample.conf
# Gather ActiveMQ metrics
[[inputs.activemq]]
## ActiveMQ WebConsole URL
Expand Down
10 changes: 10 additions & 0 deletions plugins/inputs/activemq/activemq.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package activemq

import (
_ "embed"
"encoding/xml"
"fmt"
"io"
Expand All @@ -17,6 +19,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs"
)

// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string

type ActiveMQ struct {
Server string `toml:"server" deprecated:"1.11.0;use 'url' instead"`
Port int `toml:"port" deprecated:"1.11.0;use 'url' instead"`
Expand Down Expand Up @@ -98,6 +104,10 @@ func (a *ActiveMQ) createHTTPClient() (*http.Client, error) {
return client, nil
}

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

func (a *ActiveMQ) Init() error {
if a.ResponseTimeout < config.Duration(time.Second) {
a.ResponseTimeout = config.Duration(time.Second * 5)
Expand Down
8 changes: 0 additions & 8 deletions plugins/inputs/activemq/activemq_sample_config.go

This file was deleted.

2 changes: 1 addition & 1 deletion plugins/inputs/aerospike/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ All metrics are attempted to be cast to integers, then booleans, then strings.

## Configuration

```toml
```toml @sample.conf
# Read stats from aerospike server(s)
[[inputs.aerospike]]
## Aerospike servers to connect to (with port)
Expand Down
10 changes: 10 additions & 0 deletions plugins/inputs/aerospike/aerospike.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package aerospike

import (
"crypto/tls"
_ "embed"
"fmt"
"math"
"strconv"
Expand All @@ -16,6 +18,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs"
)

// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string

type Aerospike struct {
Servers []string `toml:"servers"`

Expand Down Expand Up @@ -50,6 +56,10 @@ var protectedHexFields = map[string]bool{
"paxos_principal": true,
}

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

func (a *Aerospike) Gather(acc telegraf.Accumulator) error {
if !a.initialized {
tlsConfig, err := a.ClientConfig.TLSConfig()
Expand Down
8 changes: 0 additions & 8 deletions plugins/inputs/aerospike/aerospike_sample_config.go

This file was deleted.

2 changes: 1 addition & 1 deletion plugins/inputs/aliyuncms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ In the following order the plugin will attempt to authenticate.

## Configuration

```toml
```toml @sample.conf
# Pull Metric Statistics from Aliyun CMS
[[inputs.aliyuncms]]
## Aliyun Credentials
Expand Down
15 changes: 13 additions & 2 deletions plugins/inputs/aliyuncms/aliyuncms.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package aliyuncms

import (
_ "embed"
"encoding/json"
"fmt"
"strconv"
Expand All @@ -11,15 +13,20 @@ import (
"github.com/aliyun/alibaba-cloud-sdk-go/sdk"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/providers"
"github.com/aliyun/alibaba-cloud-sdk-go/services/cms"
"github.com/jmespath/go-jmespath"
"github.com/pkg/errors"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/internal/limiter"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/jmespath/go-jmespath"
"github.com/pkg/errors"
)

// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string

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

func (*AliyunCMS) SampleConfig() string {
return sampleConfig
}

// Init perform checks of plugin inputs and initialize internals
func (s *AliyunCMS) Init() error {
if s.Project == "" {
Expand Down
8 changes: 0 additions & 8 deletions plugins/inputs/aliyuncms/aliyuncms_sample_config.go

This file was deleted.

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 @@ -4,7 +4,7 @@ This plugin uses a query on the [`rocm-smi`](https://github.com/RadeonOpenComput

## Configuration

```toml
```toml @sample.conf
# 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
Expand Down
10 changes: 10 additions & 0 deletions plugins/inputs/amd_rocm_smi/amd_rocm_smi.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package amd_rocm_smi

import (
_ "embed"
"encoding/json"
"fmt"
"os"
Expand All @@ -15,13 +17,21 @@ import (
"github.com/influxdata/telegraf/plugins/inputs"
)

// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string

const measurement = "amd_rocm_smi"

type ROCmSMI struct {
BinPath string
Timeout config.Duration
}

func (*ROCmSMI) SampleConfig() string {
return sampleConfig
}

// 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: 0 additions & 8 deletions plugins/inputs/amd_rocm_smi/amd_rocm_smi_sample_config.go

This file was deleted.

2 changes: 1 addition & 1 deletion plugins/inputs/amqp_consumer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ For an introduction to AMQP see:

The following defaults are known to work with RabbitMQ:

```toml
```toml @sample.conf
# AMQP consumer plugin
[[inputs.amqp_consumer]]
## Brokers to consume from. If multiple brokers are specified a random broker
Expand Down
10 changes: 10 additions & 0 deletions plugins/inputs/amqp_consumer/amqp_consumer.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package amqp_consumer

import (
"context"
_ "embed"
"errors"
"fmt"
"math/rand"
Expand All @@ -18,6 +20,10 @@ import (
"github.com/influxdata/telegraf/plugins/parsers"
)

// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string

const (
defaultMaxUndeliveredMessages = 1000
)
Expand Down Expand Up @@ -88,6 +94,10 @@ const (
DefaultPrefetchCount = 50
)

func (*AMQPConsumer) SampleConfig() string {
return sampleConfig
}

func (a *AMQPConsumer) SetParser(parser parsers.Parser) {
a.parser = parser
}
Expand Down
8 changes: 0 additions & 8 deletions plugins/inputs/amqp_consumer/amqp_consumer_sample_config.go

This file was deleted.

2 changes: 1 addition & 1 deletion plugins/inputs/apache/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Typically, the `mod_status` module is configured to expose a page at the `/serve

## Configuration

```toml
```toml @sample.conf
# Read Apache status information (mod_status)
[[inputs.apache]]
## An array of URLs to gather from, must be directed at the machine
Expand Down
10 changes: 10 additions & 0 deletions plugins/inputs/apache/apache.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package apache

import (
"bufio"
_ "embed"
"fmt"
"net"
"net/http"
Expand All @@ -17,6 +19,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs"
)

// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string

type Apache struct {
Urls []string
Username string
Expand All @@ -27,6 +33,10 @@ type Apache struct {
client *http.Client
}

func (*Apache) SampleConfig() string {
return sampleConfig
}

func (n *Apache) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup

Expand Down
8 changes: 0 additions & 8 deletions plugins/inputs/apache/apache_sample_config.go

This file was deleted.

2 changes: 1 addition & 1 deletion plugins/inputs/apcupsd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ apcupsd should be installed and it's daemon should be running.

## Configuration

```toml
```toml @sample.conf
# Monitor APC UPSes connected to apcupsd
[[inputs.apcupsd]]
# A list of running apcupsd server to connect to.
Expand Down
Loading