From e84c2b2edd769070f1d1a2e23725d448220a0336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Schr=C3=B6der?= Date: Wed, 27 Sep 2017 02:49:55 +0200 Subject: [PATCH] Metrics service prefix (#3498) * metrics: replace statsite_prefix with service_prefix The metrics prefix isn't statsite specific and is in fact used for all metrics providers. Since we are deprecating fields anyway we should fix this one as well. Fixes #3293 * Updates docs and sorts telemetry section. * Renames to "metrics_prefix" to disambiguate with Consul services. * Updates the change log. --- CHANGELOG.md | 3 +- agent/config/builder.go | 2 +- agent/config/config.go | 2 +- agent/config/default.go | 2 +- agent/config/doc.go | 3 +- agent/config/runtime.go | 2 +- agent/config/runtime_test.go | 8 +-- command/agent.go | 2 +- website/source/docs/agent/options.html.md | 88 +++++++++++------------ 9 files changed, 57 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 170405ba2a..f74aac771a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,8 +47,9 @@ BREAKING CHANGES: | /v1/session/node | GET | | /v1/status/leader | GET | | /v1/status/peers | GET | - + +* **Renamed `statsite_prefix` to `metrics_prefix` in Telemetry Configuration:** Since the `statsite_prefix` applied to all telemetry providers, `statsite_prefix` was renamed to [`metrics_prefix`](https://www.consul.io/docs/agent/options.html#telemetry-metrics_prefix). Configuration files will need to be updated when upgrading to this version of Consul. [GH-3498] FEATURES: diff --git a/agent/config/builder.go b/agent/config/builder.go index a98ab39585..98c2aefeb3 100644 --- a/agent/config/builder.go +++ b/agent/config/builder.go @@ -539,9 +539,9 @@ func (b *Builder) Build() (rt RuntimeConfig, err error) { TelemetryFilterDefault: b.boolVal(c.Telemetry.FilterDefault), TelemetryAllowedPrefixes: telemetryAllowedPrefixes, TelemetryBlockedPrefixes: telemetryBlockedPrefixes, + TelemetryMetricsPrefix: b.stringVal(c.Telemetry.MetricsPrefix), TelemetryStatsdAddr: b.stringVal(c.Telemetry.StatsdAddr), TelemetryStatsiteAddr: b.stringVal(c.Telemetry.StatsiteAddr), - TelemetryStatsitePrefix: b.stringVal(c.Telemetry.StatsitePrefix), // Agent AdvertiseAddrLAN: advertiseAddrLAN, diff --git a/agent/config/config.go b/agent/config/config.go index 916031e928..1acbd0ccf1 100644 --- a/agent/config/config.go +++ b/agent/config/config.go @@ -365,9 +365,9 @@ type Telemetry struct { DogstatsdTags []string `json:"dogstatsd_tags,omitempty" hcl:"dogstatsd_tags" mapstructure:"dogstatsd_tags"` FilterDefault *bool `json:"filter_default,omitempty" hcl:"filter_default" mapstructure:"filter_default"` PrefixFilter []string `json:"prefix_filter,omitempty" hcl:"prefix_filter" mapstructure:"prefix_filter"` + MetricsPrefix *string `json:"metrics_prefix,omitempty" hcl:"metrics_prefix" mapstructure:"metrics_prefix"` StatsdAddr *string `json:"statsd_address,omitempty" hcl:"statsd_address" mapstructure:"statsd_address"` StatsiteAddr *string `json:"statsite_address,omitempty" hcl:"statsite_address" mapstructure:"statsite_address"` - StatsitePrefix *string `json:"statsite_prefix,omitempty" hcl:"statsite_prefix" mapstructure:"statsite_prefix"` } type Ports struct { diff --git a/agent/config/default.go b/agent/config/default.go index 9bb8ea81df..765232bbfc 100644 --- a/agent/config/default.go +++ b/agent/config/default.go @@ -76,7 +76,7 @@ func DefaultSource() Source { server = ` + strconv.Itoa(consul.DefaultRPCPort) + ` } telemetry = { - statsite_prefix = "consul" + metrics_prefix = "consul" filter_default = true } `, diff --git a/agent/config/doc.go b/agent/config/doc.go index bea218c92a..b695c1c769 100644 --- a/agent/config/doc.go +++ b/agent/config/doc.go @@ -66,7 +66,8 @@ // * "recursor" is deprecated. Please use "recursors" instead. // * "statsd_addr" is deprecated. Please use "telemetry.statsd_addr" instead. // * "statsite_addr" is deprecated. Please use "telemetry.statsite_addr" instead. -// * "statsite_prefix" is deprecated. Please use "telemetry.statsite_prefix" instead. +// * "statsite_prefix" is deprecated. Please use "telemetry.metrics_prefix" instead. +// * "telemetry.statsite_prefix" is deprecated. Please use "telemetry.metrics_prefix" instead. // * "retry_join_azure" is deprecated. Please use "retry_join" instead. // * "retry_join_ec2" is deprecated. Please use "retry_join" instead. // * "retry_join_gce" is deprecated. Please use "retry_join" instead. diff --git a/agent/config/runtime.go b/agent/config/runtime.go index 6248bc910f..b06cdc2447 100644 --- a/agent/config/runtime.go +++ b/agent/config/runtime.go @@ -100,9 +100,9 @@ type RuntimeConfig struct { TelemetryFilterDefault bool TelemetryAllowedPrefixes []string TelemetryBlockedPrefixes []string + TelemetryMetricsPrefix string TelemetryStatsdAddr string TelemetryStatsiteAddr string - TelemetryStatsitePrefix string AdvertiseAddrLAN *net.IPAddr AdvertiseAddrWAN *net.IPAddr diff --git a/agent/config/runtime_test.go b/agent/config/runtime_test.go index 29c3fb1f1e..a199ba6656 100644 --- a/agent/config/runtime_test.go +++ b/agent/config/runtime_test.go @@ -2254,9 +2254,9 @@ func TestFullConfig(t *testing.T) { "dogstatsd_tags": [ "3N81zSUB","Xtj8AnXZ" ], "filter_default": true, "prefix_filter": [ "+oJotS8XJ","-cazlEhGn" ], + "metrics_prefix": "ftO6DySn", "statsd_address": "drce87cy", - "statsite_address": "HpFwKB8R", - "statsite_prefix": "ftO6DySn" + "statsite_address": "HpFwKB8R" }, "tls_cipher_suites": "TLS_RSA_WITH_RC4_128_SHA,TLS_RSA_WITH_3DES_EDE_CBC_SHA", "tls_min_version": "pAOWafkR", @@ -2674,9 +2674,9 @@ func TestFullConfig(t *testing.T) { dogstatsd_tags = [ "3N81zSUB","Xtj8AnXZ" ] filter_default = true prefix_filter = [ "+oJotS8XJ","-cazlEhGn" ] + metrics_prefix = "ftO6DySn" statsd_address = "drce87cy" statsite_address = "HpFwKB8R" - statsite_prefix = "ftO6DySn" } tls_cipher_suites = "TLS_RSA_WITH_RC4_128_SHA,TLS_RSA_WITH_3DES_EDE_CBC_SHA" tls_min_version = "pAOWafkR" @@ -3213,9 +3213,9 @@ func TestFullConfig(t *testing.T) { TelemetryFilterDefault: true, TelemetryAllowedPrefixes: []string{"oJotS8XJ"}, TelemetryBlockedPrefixes: []string{"cazlEhGn"}, + TelemetryMetricsPrefix: "ftO6DySn", TelemetryStatsdAddr: "drce87cy", TelemetryStatsiteAddr: "HpFwKB8R", - TelemetryStatsitePrefix: "ftO6DySn", TLSCipherSuites: []uint16{tls.TLS_RSA_WITH_RC4_128_SHA, tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA}, TLSMinVersion: "pAOWafkR", TLSPreferServerCipherSuites: true, diff --git a/command/agent.go b/command/agent.go index a01de8f7e3..580f32ef41 100644 --- a/command/agent.go +++ b/command/agent.go @@ -220,7 +220,7 @@ func startupTelemetry(conf *config.RuntimeConfig) (*metrics.InmemSink, error) { // metrics over stderr when there is a SIGUSR1 received. memSink := metrics.NewInmemSink(10*time.Second, time.Minute) metrics.DefaultInmemSignal(memSink) - metricsConf := metrics.DefaultConfig(conf.TelemetryStatsitePrefix) + metricsConf := metrics.DefaultConfig(conf.TelemetryMetricsPrefix) metricsConf.EnableHostname = !conf.TelemetryDisableHostname metricsConf.FilterDefault = conf.TelemetryFilterDefault diff --git a/website/source/docs/agent/options.html.md b/website/source/docs/agent/options.html.md index c249a87fcf..4c1ee14fb8 100644 --- a/website/source/docs/agent/options.html.md +++ b/website/source/docs/agent/options.html.md @@ -1139,50 +1139,6 @@ Consul will not enable TLS for the HTTP API unless the `https` port has been ass * `telemetry` This is a nested object that configures where Consul sends its runtime telemetry, and contains the following keys: - * `statsd_address` This provides the - address of a statsd instance in the format `host:port`. If provided, Consul will send various telemetry information to that instance for - aggregation. This can be used to capture runtime information. This sends UDP packets only and can be used with - statsd or statsite. - - * `statsite_address` This provides - the address of a statsite instance in the format `host:port`. If provided, Consul will stream various telemetry information to that instance - for aggregation. This can be used to capture runtime information. This streams via TCP and can only be used with - statsite. - - * `statsite_prefix` - The prefix used while writing all telemetry data to statsite. By default, this is set to "consul". - - * `dogstatsd_addr` This provides the - address of a DogStatsD instance in the format `host:port`. DogStatsD is a protocol-compatible flavor of - statsd, with the added ability to decorate metrics with tags and event information. If provided, Consul will - send various telemetry information to that instance for aggregation. This can be used to capture runtime - information. - - * `dogstatsd_tags` This provides a list of global tags - that will be added to all telemetry packets sent to DogStatsD. It is a list of strings, where each string - looks like "my_tag_name:my_tag_value". - - * `disable_hostname` - This controls whether or not to prepend runtime telemetry with the machine's hostname, defaults to false. - - * `prefix_filter` - This is a list of filter rules to apply for allowing/blocking metrics by prefix in the following format: - - ```javascript - [ - "+consul.raft.apply", - "-consul.http", - "+consul.http.GET" - ] - ``` - A leading "+" will enable any metrics with the given prefix, and a leading "-" will block them. If there - is overlap between two rules, the more specific rule will take precedence. Blocking will take priority if the same - prefix is listed multiple times. - - * `filter_default` - This controls whether to allow metrics that have not been specified by the filter. Defaults to `true`, which will - allow all metrics when no filters are provided. When set to `false` with no filters, no metrics will be sent. - * `circonus_api_token` A valid API Token used to create/manage check. If provided, metric management is enabled. @@ -1222,6 +1178,50 @@ Consul will not enable TLS for the HTTP API unless the `https` port has been ass * `circonus_broker_select_tag` A special tag which will be used to select a Circonus Broker when a Broker ID is not provided. The best use of this is to as a hint for which broker should be used based on *where* this particular instance is running (e.g. a specific geo location or datacenter, dc:sfo). By default, this is left blank and not used. + * `disable_hostname` + This controls whether or not to prepend runtime telemetry with the machine's hostname, defaults to false. + + * `dogstatsd_addr` This provides the + address of a DogStatsD instance in the format `host:port`. DogStatsD is a protocol-compatible flavor of + statsd, with the added ability to decorate metrics with tags and event information. If provided, Consul will + send various telemetry information to that instance for aggregation. This can be used to capture runtime + information. + + * `dogstatsd_tags` This provides a list of global tags + that will be added to all telemetry packets sent to DogStatsD. It is a list of strings, where each string + looks like "my_tag_name:my_tag_value". + + * `filter_default` + This controls whether to allow metrics that have not been specified by the filter. Defaults to `true`, which will + allow all metrics when no filters are provided. When set to `false` with no filters, no metrics will be sent. + + * `metrics_prefix` + The prefix used while writing all telemetry data. By default, this is set to "consul". + + * `prefix_filter` + This is a list of filter rules to apply for allowing/blocking metrics by prefix in the following format: + + ```javascript + [ + "+consul.raft.apply", + "-consul.http", + "+consul.http.GET" + ] + ``` + A leading "+" will enable any metrics with the given prefix, and a leading "-" will block them. If there + is overlap between two rules, the more specific rule will take precedence. Blocking will take priority if the same + prefix is listed multiple times. + + * `statsd_address` This provides the + address of a statsd instance in the format `host:port`. If provided, Consul will send various telemetry information to that instance for + aggregation. This can be used to capture runtime information. This sends UDP packets only and can be used with + statsd or statsite. + + * `statsite_address` This provides + the address of a statsite instance in the format `host:port`. If provided, Consul will stream various telemetry information to that instance + for aggregation. This can be used to capture runtime information. This streams via TCP and can only be used with + statsite. + * `statsd_addr` Deprecated, see the telemetry structure