mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
Add support for telemetry option metrics_prefix (#8340)
When set, instead of starting with `vault_`, metrics will start with `${prefix}_`.
This commit is contained in:
@@ -2320,7 +2320,12 @@ func (c *ServerCommand) setupTelemetry(config *server.Config) (*metricsutil.Metr
|
|||||||
telConfig = &server.Telemetry{}
|
telConfig = &server.Telemetry{}
|
||||||
}
|
}
|
||||||
|
|
||||||
metricsConf := metrics.DefaultConfig("vault")
|
serviceName := "vault"
|
||||||
|
if telConfig.MetricsPrefix != "" {
|
||||||
|
serviceName = telConfig.MetricsPrefix
|
||||||
|
}
|
||||||
|
|
||||||
|
metricsConf := metrics.DefaultConfig(serviceName)
|
||||||
metricsConf.EnableHostname = !telConfig.DisableHostname
|
metricsConf.EnableHostname = !telConfig.DisableHostname
|
||||||
metricsConf.EnableHostnameLabel = telConfig.EnableHostnameLabel
|
metricsConf.EnableHostnameLabel = telConfig.EnableHostnameLabel
|
||||||
|
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ type Telemetry struct {
|
|||||||
|
|
||||||
DisableHostname bool `hcl:"disable_hostname"`
|
DisableHostname bool `hcl:"disable_hostname"`
|
||||||
EnableHostnameLabel bool `hcl:"enable_hostname_label"`
|
EnableHostnameLabel bool `hcl:"enable_hostname_label"`
|
||||||
|
MetricsPrefix string `hcl:"metrics_prefix"`
|
||||||
|
|
||||||
// Circonus: see https://github.com/circonus-labs/circonus-gometrics
|
// Circonus: see https://github.com/circonus-labs/circonus-gometrics
|
||||||
// for more details on the various configuration options.
|
// for more details on the various configuration options.
|
||||||
@@ -1099,6 +1100,7 @@ func (c *Config) Sanitized() map[string]interface{} {
|
|||||||
"statsite_address": c.Telemetry.StatsiteAddr,
|
"statsite_address": c.Telemetry.StatsiteAddr,
|
||||||
"statsd_address": c.Telemetry.StatsdAddr,
|
"statsd_address": c.Telemetry.StatsdAddr,
|
||||||
"disable_hostname": c.Telemetry.DisableHostname,
|
"disable_hostname": c.Telemetry.DisableHostname,
|
||||||
|
"metrics_prefix": c.Telemetry.MetricsPrefix,
|
||||||
"circonus_api_token": "",
|
"circonus_api_token": "",
|
||||||
"circonus_api_app": c.Telemetry.CirconusAPIApp,
|
"circonus_api_app": c.Telemetry.CirconusAPIApp,
|
||||||
"circonus_api_url": c.Telemetry.CirconusAPIURL,
|
"circonus_api_url": c.Telemetry.CirconusAPIURL,
|
||||||
|
|||||||
@@ -321,6 +321,7 @@ func testLoadConfigFile(t *testing.T) {
|
|||||||
DogStatsDAddr: "127.0.0.1:7254",
|
DogStatsDAddr: "127.0.0.1:7254",
|
||||||
DogStatsDTags: []string{"tag_1:val_1", "tag_2:val_2"},
|
DogStatsDTags: []string{"tag_1:val_1", "tag_2:val_2"},
|
||||||
PrometheusRetentionTime: prometheusDefaultRetentionTime,
|
PrometheusRetentionTime: prometheusDefaultRetentionTime,
|
||||||
|
MetricsPrefix: "myprefix",
|
||||||
},
|
},
|
||||||
|
|
||||||
DisableCache: true,
|
DisableCache: true,
|
||||||
@@ -554,6 +555,7 @@ func testConfig_Sanitized(t *testing.T) {
|
|||||||
"circonus_check_tags": "",
|
"circonus_check_tags": "",
|
||||||
"circonus_submission_interval": "",
|
"circonus_submission_interval": "",
|
||||||
"disable_hostname": false,
|
"disable_hostname": false,
|
||||||
|
"metrics_prefix": "pfx",
|
||||||
"dogstatsd_addr": "",
|
"dogstatsd_addr": "",
|
||||||
"dogstatsd_tags": []string(nil),
|
"dogstatsd_tags": []string(nil),
|
||||||
"prometheus_retention_time": 24 * time.Hour,
|
"prometheus_retention_time": 24 * time.Hour,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ telemetry {
|
|||||||
statsite_address = "foo"
|
statsite_address = "foo"
|
||||||
dogstatsd_addr = "127.0.0.1:7254"
|
dogstatsd_addr = "127.0.0.1:7254"
|
||||||
dogstatsd_tags = ["tag_1:val_1", "tag_2:val_2"]
|
dogstatsd_tags = ["tag_1:val_1", "tag_2:val_2"]
|
||||||
|
metrics_prefix = "myprefix"
|
||||||
}
|
}
|
||||||
|
|
||||||
max_lease_ttl = "10h"
|
max_lease_ttl = "10h"
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ service_registration "consul" {
|
|||||||
telemetry {
|
telemetry {
|
||||||
statsd_address = "bar"
|
statsd_address = "bar"
|
||||||
circonus_api_token = "baz"
|
circonus_api_token = "baz"
|
||||||
|
metrics_prefix = "pfx"
|
||||||
}
|
}
|
||||||
|
|
||||||
seal "awskms" {
|
seal "awskms" {
|
||||||
|
|||||||
Reference in New Issue
Block a user