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

style: Add deprecation notices to plugin options #10616

Merged
merged 15 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from 12 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
3 changes: 1 addition & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ type AgentConfig struct {
// TODO(cam): Remove UTC and parameter, they are no longer
// valid for the agent config. Leaving them here for now for backwards-
// compatibility
// Deprecated: 1.0.0 after, has no effect
UTC bool `toml:"utc"`
UTC bool `toml:"utc" deprecated:"1.0.0;option is ignored"`
srebhan marked this conversation as resolved.
Show resolved Hide resolved
Hipska marked this conversation as resolved.
Show resolved Hide resolved

// Debug is the option for running in debug mode
Debug bool `toml:"debug"`
Expand Down
8 changes: 1 addition & 7 deletions plugins/common/kafka/config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package kafka

import (
"log"

"github.com/Shopify/sarama"
"github.com/influxdata/telegraf/plugins/common/tls"
)
Expand Down Expand Up @@ -53,18 +51,14 @@ type Config struct {
ClientID string `toml:"client_id"`
CompressionCodec int `toml:"compression_codec"`

// EnableTLS deprecated
EnableTLS *bool `toml:"enable_tls"`
EnableTLS *bool `toml:"enable_tls" deprecated:"1.17.0;option is ignored"`

// Disable full metadata fetching
MetadataFull *bool `toml:"metadata_full"`
}

// SetConfig on the sarama.Config object from the Config struct.
func (k *Config) SetConfig(config *sarama.Config) error {
if k.EnableTLS != nil {
log.Printf("W! [kafka] enable_tls is deprecated, and the setting does nothing, you can safely remove it from the config")
}
if k.Version != "" {
version, err := sarama.ParseKafkaVersion(k.Version)
if err != nil {
Expand Down
7 changes: 3 additions & 4 deletions plugins/common/tls/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ type ClientConfig struct {
InsecureSkipVerify bool `toml:"insecure_skip_verify"`
ServerName string `toml:"tls_server_name"`

// Deprecated in 1.7; use TLS variables above
SSLCA string `toml:"ssl_ca"`
SSLCert string `toml:"ssl_cert"`
SSLKey string `toml:"ssl_key"`
SSLCA string `toml:"ssl_ca" deprecated:"1.7.0;use 'tls_ca' instead"`
SSLCert string `toml:"ssl_cert" deprecated:"1.7.0;use 'tls_cert' instead"`
SSLKey string `toml:"ssl_key" deprecated:"1.7.0;use 'tls_key' instead"`
}

// ServerConfig represents the standard server TLS config.
Expand Down
9 changes: 2 additions & 7 deletions plugins/inputs/activemq/activemq.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
)

type ActiveMQ struct {
Server string `toml:"server"`
Port int `toml:"port"`
Server string `toml:"server" deprecated:"1.11.0;use 'url' instead"`
Port int `toml:"port" deprecated:"1.11.0;use 'url' instead"`
URL string `toml:"url"`
Username string `toml:"username"`
Password string `toml:"password"`
Expand Down Expand Up @@ -86,11 +86,6 @@ var sampleConfig = `
## ActiveMQ WebConsole URL
url = "http://127.0.0.1:8161"

## Required ActiveMQ Endpoint
## deprecated in 1.11; use the url option
# server = "127.0.0.1"
# port = 8161

## Credentials for basic HTTP authentication
# username = "admin"
# password = "admin"
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/aerospike/aerospike.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Aerospike struct {
Password string `toml:"password"`

EnableTLS bool `toml:"enable_tls"`
EnableSSL bool `toml:"enable_ssl"` // deprecated in 1.7; use enable_tls
EnableSSL bool `toml:"enable_ssl" deprecated:"1.7.0;use 'enable_tls' instead"`
tlsint.ClientConfig

initialized bool
Expand Down
6 changes: 1 addition & 5 deletions plugins/inputs/amqp_consumer/amqp_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type semaphore chan empty

// AMQPConsumer is the top level struct for this plugin
type AMQPConsumer struct {
URL string `toml:"url" deprecated:"1.7.0;use brokers"`
URL string `toml:"url" deprecated:"1.7.0;use 'brokers' instead"`
Brokers []string `toml:"brokers"`
Username string `toml:"username"`
Password string `toml:"password"`
Expand Down Expand Up @@ -90,10 +90,6 @@ const (

func (a *AMQPConsumer) SampleConfig() string {
return `
## 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
2 changes: 1 addition & 1 deletion plugins/inputs/consul/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Consul struct {
Token string
Username string
Password string
Datacentre string // deprecated in 1.10; use Datacenter
Datacentre string `toml:"datacentre" deprecated:"1.10.0;use 'datacenter' instead"`
Datacenter string
tls.ClientConfig
TagDelimiter string
Expand Down
12 changes: 8 additions & 4 deletions plugins/inputs/deprecations.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ var Deprecations = map[string]telegraf.DeprecationInfo{
Since: "1.7.0",
Notice: "use 'inputs.jolokia2' with the 'cassandra.conf' example configuration instead",
},
"io": {
Since: "0.10.0",
RemovalIn: "2.0.0",
Notice: "use 'inputs.diskio' instead",
"http_listener": {
Since: "1.9.0",
Notice: "has been renamed to 'influxdb_listener', use 'inputs.influxdb_listener' or 'inputs.http_listener_v2' instead",
},
"httpjson": {
Since: "1.6.0",
Notice: "use 'inputs.http' instead",
},
"io": {
Since: "0.10.0",
RemovalIn: "2.0.0",
Notice: "use 'inputs.diskio' instead",
},
"jolokia": {
Since: "1.5.0",
Notice: "use 'inputs.jolokia2' instead",
Expand Down
32 changes: 3 additions & 29 deletions plugins/inputs/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ import (
// Docker object
type Docker struct {
Endpoint string
ContainerNames []string // deprecated in 1.4; use container_name_include
ContainerNames []string `toml:"container_names" deprecated:"1.4.0;use 'container_name_include' instead"`

GatherServices bool `toml:"gather_services"`

Timeout config.Duration
PerDevice bool `toml:"perdevice"`
PerDevice bool `toml:"perdevice" deprecated:"1.18.0;use 'perdevice_include' instead"`
PerDeviceInclude []string `toml:"perdevice_include"`
Total bool `toml:"total"`
Total bool `toml:"total" deprecated:"1.18.0;use 'total_include' instead"`
TotalInclude []string `toml:"total_include"`
TagEnvironment []string `toml:"tag_env"`
LabelInclude []string `toml:"docker_label_include"`
Expand Down Expand Up @@ -74,14 +74,6 @@ const (
PB = 1000 * TB

defaultEndpoint = "unix:///var/run/docker.sock"

perDeviceIncludeDeprecationWarning = "'perdevice' setting is set to 'true' so 'blkio' and 'network' metrics will " +
"be collected. Please set it to 'false' and use 'perdevice_include' instead to control this behaviour as " +
"'perdevice' will be deprecated"

totalIncludeDeprecationWarning = "'total' setting is set to 'false' so 'blkio' and 'network' metrics will not be " +
"collected. Please set it to 'true' and use 'total_include' instead to control this behaviour as 'total' " +
"will be deprecated"
)

var (
Expand All @@ -100,9 +92,6 @@ var sampleConfig = `
## Set to true to collect Swarm metrics(desired_replicas, running_replicas)
gather_services = false

## Only collect metrics for these containers, collect all if empty
container_names = []

## Set the source tag for the metrics to the container ID hostname, eg first 12 chars
source_tag = false

Expand All @@ -121,24 +110,11 @@ var sampleConfig = `
## Timeout for docker list, info, and stats commands
timeout = "5s"

## Whether to report for each container per-device blkio (8:0, 8:1...),
## network (eth0, eth1, ...) and cpu (cpu0, cpu1, ...) stats or not.
## Usage of this setting is discouraged since it will be deprecated in favor of 'perdevice_include'.
## Default value is 'true' for backwards compatibility, please set it to 'false' so that 'perdevice_include' setting
## is honored.
perdevice = true

## Specifies for which classes a per-device metric should be issued
## Possible values are 'cpu' (cpu0, cpu1, ...), 'blkio' (8:0, 8:1, ...) and 'network' (eth0, eth1, ...)
## Please note that this setting has no effect if 'perdevice' is set to 'true'
# perdevice_include = ["cpu"]

## Whether to report for each container total blkio and network stats or not.
## Usage of this setting is discouraged since it will be deprecated in favor of 'total_include'.
## Default value is 'false' for backwards compatibility, please set it to 'true' so that 'total_include' setting
## is honored.
total = false

## Specifies for which classes a total metric should be issued. Total is an aggregated of the 'perdevice' values.
## Possible values are 'cpu', 'blkio' and 'network'
## Total 'cpu' is reported directly by Docker daemon, and 'network' and 'blkio' totals are aggregated by this plugin.
Expand Down Expand Up @@ -182,7 +158,6 @@ func (d *Docker) Init() error {

// Temporary logic needed for backwards compatibility until 'perdevice' setting is removed.
if d.PerDevice {
d.Log.Warn(perDeviceIncludeDeprecationWarning)
if !choice.Contains("network", d.PerDeviceInclude) {
d.PerDeviceInclude = append(d.PerDeviceInclude, "network")
}
Expand All @@ -193,7 +168,6 @@ func (d *Docker) Init() error {

// Temporary logic needed for backwards compatibility until 'total' setting is removed.
if !d.Total {
d.Log.Warn(totalIncludeDeprecationWarning)
if choice.Contains("cpu", d.TotalInclude) {
d.TotalInclude = []string{"cpu"}
} else {
Expand Down
6 changes: 1 addition & 5 deletions plugins/inputs/filecount/filecount.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ import (
)

const sampleConfig = `
## Directory to gather stats about.
## deprecated in 1.9; use the directories option
# directory = "/var/cache/apt/archives"

## Directories to gather stats about.
## This accept standard unit glob matching rules, but with the addition of
## ** as a "super asterisk". ie:
Expand Down Expand Up @@ -51,7 +47,7 @@ const sampleConfig = `
`

type FileCount struct {
Directory string // deprecated in 1.9
Directory string `toml:"directory" deprecated:"1.9.0;use 'directories' instead"`
Directories []string
Name string
Recursive bool
Expand Down
6 changes: 1 addition & 5 deletions plugins/inputs/http_listener_v2/http_listener_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type TimeFunc func() time.Time
// HTTPListenerV2 is an input plugin that collects external metrics sent via HTTP
type HTTPListenerV2 struct {
ServiceAddress string `toml:"service_address"`
Path string `toml:"path"`
Path string `toml:"path" deprecated:"1.20.0;use 'paths' instead"`
Paths []string `toml:"paths"`
PathTag bool `toml:"path_tag"`
Methods []string `toml:"methods"`
Expand Down Expand Up @@ -71,10 +71,6 @@ const sampleConfig = `
## Address and port to host HTTP listener on
service_address = ":8080"

## Path to listen to.
## This option is deprecated and only available for backward-compatibility. Please use paths instead.
# path = ""

## Paths to listen to.
# paths = ["/telegraf"]

Expand Down
5 changes: 0 additions & 5 deletions plugins/inputs/http_response/http_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ func (h *HTTPResponse) Description() string {
}

var sampleConfig = `
## Deprecated in 1.12, use 'urls'
## Server address (default http://localhost)
# address = "http://localhost"

## List of urls to query.
# urls = ["http://localhost"]

Expand Down Expand Up @@ -425,7 +421,6 @@ func (h *HTTPResponse) Gather(acc telegraf.Accumulator) error {
if h.Address == "" {
h.URLs = []string{"http://localhost"}
} else {
h.Log.Warn("'address' deprecated in telegraf 1.12, please use 'urls'")
h.URLs = []string{h.Address}
}
}
Expand Down
8 changes: 1 addition & 7 deletions plugins/inputs/httpjson/httpjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (

// HTTPJSON struct
type HTTPJSON struct {
Name string
Name string `toml:"name" deprecated:"1.3.0;use 'name_override', 'name_suffix', 'name_prefix' instead"`
Servers []string
Method string
TagKeys []string
Expand Down Expand Up @@ -70,12 +70,6 @@ var sampleConfig = `
## NOTE This plugin only reads numerical measurements, strings and booleans
## will be ignored.

## Name for the service being polled. Will be appended to the name of the
## measurement e.g. httpjson_webserver_stats
##
## Deprecated (1.3.0): Use name_override, name_suffix, name_prefix instead.
name = "webserver_stats"

## URL of each server in the service's cluster
servers = [
"http://localhost:9999/stats/",
Expand Down
6 changes: 1 addition & 5 deletions plugins/inputs/influxdb_listener/influxdb_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type InfluxDBListener struct {
ReadTimeout config.Duration `toml:"read_timeout"`
WriteTimeout config.Duration `toml:"write_timeout"`
MaxBodySize config.Size `toml:"max_body_size"`
MaxLineSize config.Size `toml:"max_line_size"` // deprecated in 1.14; ignored
MaxLineSize config.Size `toml:"max_line_size" deprecated:"1.14.0;parser now handles lines of unlimited length and option is ignored"`
BasicUsername string `toml:"basic_username"`
BasicPassword string `toml:"basic_password"`
DatabaseTag string `toml:"database_tag"`
Expand Down Expand Up @@ -142,10 +142,6 @@ func (h *InfluxDBListener) Init() error {
h.MaxBodySize = config.Size(defaultMaxBodySize)
}

if h.MaxLineSize != 0 {
h.Log.Warnf("Use of deprecated configuration: 'max_line_size'; parser now handles lines of unlimited length and option is ignored")
}

if h.ReadTimeout < config.Duration(time.Second) {
h.ReadTimeout = config.Duration(time.Second * 10)
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/inputs/mongodb/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ type MongoDB struct {
}

type Ssl struct {
Enabled bool
CaCerts []string `toml:"cacerts"`
Enabled bool `toml:"ssl_enabled" deprecated:"1.3.0;use 'tls_*' options instead"`
CaCerts []string `toml:"cacerts" deprecated:"1.3.0;use 'tls_ca' instead"`
}

var sampleConfig = `
Expand Down
6 changes: 4 additions & 2 deletions plugins/inputs/mqtt_consumer/mqtt_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ type MQTTConsumer struct {
ConnectionTimeout config.Duration `toml:"connection_timeout"`
MaxUndeliveredMessages int `toml:"max_undelivered_messages"`
parser parsers.Parser
// Legacy metric buffer support; deprecated in v0.10.3
MetricBuffer int

MetricBuffer int `toml:"metric_buffer" deprecated:"0.10.3;2.0.0;option is ignored"`
powersj marked this conversation as resolved.
Show resolved Hide resolved
PersistentSession bool
ClientID string `toml:"client_id"`

tls.ClientConfig

Log telegraf.Logger
clientFactory ClientFactory
client Client
Expand Down
4 changes: 1 addition & 3 deletions plugins/inputs/nats_consumer/nats_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ type natsConsumer struct {
PendingBytesLimit int `toml:"pending_bytes_limit"`

MaxUndeliveredMessages int `toml:"max_undelivered_messages"`

// Legacy metric buffer support; deprecated in v0.10.3
MetricBuffer int
MetricBuffer int `toml:"metric_buffer" deprecated:"0.10.3;2.0.0;option is ignored"`

conn *nats.Conn
subs []*nats.Subscription
Expand Down
5 changes: 1 addition & 4 deletions plugins/inputs/nsq_consumer/nsq_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (l *logger) Output(_ int, s string) error {

//NSQConsumer represents the configuration of the plugin
type NSQConsumer struct {
Server string `toml:"server"`
Server string `toml:"server" deprecated:"1.5.0;use 'nsqd' instead"`
Nsqd []string `toml:"nsqd"`
Nsqlookupd []string `toml:"nsqlookupd"`
Topic string `toml:"topic"`
Expand All @@ -50,9 +50,6 @@ type NSQConsumer struct {
}

var sampleConfig = `
## Server option still works but is deprecated, we just prepend it to the nsqd array.
# server = "localhost:4150"

## An array representing the NSQD TCP HTTP Endpoints
nsqd = ["localhost:4150"]

Expand Down
4 changes: 2 additions & 2 deletions plugins/inputs/openldap/openldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (
type Openldap struct {
Host string
Port int
SSL string `toml:"ssl"` // Deprecated in 1.7; use TLS
SSL string `toml:"ssl" deprecated:"1.7.0;use 'tls' instead"`
TLS string `toml:"tls"`
InsecureSkipVerify bool
SSLCA string `toml:"ssl_ca"` // Deprecated in 1.7; use TLSCA
SSLCA string `toml:"ssl_ca" deprecated:"1.7.0;use 'tls_ca' instead"`
TLSCA string `toml:"tls_ca"`
BindDn string
BindPassword string
Expand Down
Loading