mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
Port: Telemetry For Lease Expiration Times (#10375)
* port lease metrics * go mod vendor * caught a bug
This commit is contained in:
@@ -30,6 +30,10 @@ func TestLoadConfigFileIntegerAndBooleanValuesJson(t *testing.T) {
|
||||
testLoadConfigFileIntegerAndBooleanValuesJson(t)
|
||||
}
|
||||
|
||||
func TestLoadConfigFileWithLeaseMetricTelemetry(t *testing.T) {
|
||||
testLoadConfigFileLeaseMetrics(t)
|
||||
}
|
||||
|
||||
func TestLoadConfigDir(t *testing.T) {
|
||||
testLoadConfigDir(t)
|
||||
}
|
||||
|
||||
@@ -62,14 +62,17 @@ func testLoadConfigFile_topLevel(t *testing.T, entropy *configutil.Entropy) {
|
||||
},
|
||||
|
||||
Telemetry: &configutil.Telemetry{
|
||||
StatsdAddr: "bar",
|
||||
StatsiteAddr: "foo",
|
||||
DisableHostname: false,
|
||||
DogStatsDAddr: "127.0.0.1:7254",
|
||||
DogStatsDTags: []string{"tag_1:val_1", "tag_2:val_2"},
|
||||
PrometheusRetentionTime: 30 * time.Second,
|
||||
UsageGaugePeriod: 5 * time.Minute,
|
||||
MaximumGaugeCardinality: 125,
|
||||
StatsdAddr: "bar",
|
||||
StatsiteAddr: "foo",
|
||||
DisableHostname: false,
|
||||
DogStatsDAddr: "127.0.0.1:7254",
|
||||
DogStatsDTags: []string{"tag_1:val_1", "tag_2:val_2"},
|
||||
PrometheusRetentionTime: 30 * time.Second,
|
||||
UsageGaugePeriod: 5 * time.Minute,
|
||||
MaximumGaugeCardinality: 125,
|
||||
LeaseMetricsEpsilon: time.Hour,
|
||||
NumLeaseMetricsTimeBuckets: 168,
|
||||
LeaseMetricsNameSpaceLabels: false,
|
||||
},
|
||||
|
||||
DisableMlock: true,
|
||||
@@ -192,6 +195,9 @@ func testLoadConfigFile_json2(t *testing.T, entropy *configutil.Entropy) {
|
||||
CirconusBrokerID: "0",
|
||||
CirconusBrokerSelectTag: "dc:sfo",
|
||||
PrometheusRetentionTime: 30 * time.Second,
|
||||
LeaseMetricsEpsilon: time.Hour,
|
||||
NumLeaseMetricsTimeBuckets: 168,
|
||||
LeaseMetricsNameSpaceLabels: false,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -371,15 +377,18 @@ func testLoadConfigFile(t *testing.T) {
|
||||
},
|
||||
|
||||
Telemetry: &configutil.Telemetry{
|
||||
StatsdAddr: "bar",
|
||||
StatsiteAddr: "foo",
|
||||
DisableHostname: false,
|
||||
UsageGaugePeriod: 5 * time.Minute,
|
||||
MaximumGaugeCardinality: 100,
|
||||
DogStatsDAddr: "127.0.0.1:7254",
|
||||
DogStatsDTags: []string{"tag_1:val_1", "tag_2:val_2"},
|
||||
PrometheusRetentionTime: configutil.PrometheusDefaultRetentionTime,
|
||||
MetricsPrefix: "myprefix",
|
||||
StatsdAddr: "bar",
|
||||
StatsiteAddr: "foo",
|
||||
DisableHostname: false,
|
||||
UsageGaugePeriod: 5 * time.Minute,
|
||||
MaximumGaugeCardinality: 100,
|
||||
DogStatsDAddr: "127.0.0.1:7254",
|
||||
DogStatsDTags: []string{"tag_1:val_1", "tag_2:val_2"},
|
||||
PrometheusRetentionTime: configutil.PrometheusDefaultRetentionTime,
|
||||
MetricsPrefix: "myprefix",
|
||||
LeaseMetricsEpsilon: time.Hour,
|
||||
NumLeaseMetricsTimeBuckets: 168,
|
||||
LeaseMetricsNameSpaceLabels: false,
|
||||
},
|
||||
|
||||
DisableMlock: true,
|
||||
@@ -477,6 +486,9 @@ func testLoadConfigFile_json(t *testing.T) {
|
||||
CirconusBrokerID: "",
|
||||
CirconusBrokerSelectTag: "",
|
||||
PrometheusRetentionTime: configutil.PrometheusDefaultRetentionTime,
|
||||
LeaseMetricsEpsilon: time.Hour,
|
||||
NumLeaseMetricsTimeBuckets: 168,
|
||||
LeaseMetricsNameSpaceLabels: false,
|
||||
},
|
||||
|
||||
PidFile: "./pidfile",
|
||||
@@ -540,12 +552,15 @@ func testLoadConfigDir(t *testing.T) {
|
||||
},
|
||||
|
||||
Telemetry: &configutil.Telemetry{
|
||||
StatsiteAddr: "qux",
|
||||
StatsdAddr: "baz",
|
||||
DisableHostname: true,
|
||||
UsageGaugePeriod: 5 * time.Minute,
|
||||
MaximumGaugeCardinality: 100,
|
||||
PrometheusRetentionTime: configutil.PrometheusDefaultRetentionTime,
|
||||
StatsiteAddr: "qux",
|
||||
StatsdAddr: "baz",
|
||||
DisableHostname: true,
|
||||
UsageGaugePeriod: 5 * time.Minute,
|
||||
MaximumGaugeCardinality: 100,
|
||||
PrometheusRetentionTime: configutil.PrometheusDefaultRetentionTime,
|
||||
LeaseMetricsEpsilon: time.Hour,
|
||||
NumLeaseMetricsTimeBuckets: 168,
|
||||
LeaseMetricsNameSpaceLabels: false,
|
||||
},
|
||||
ClusterName: "testcluster",
|
||||
},
|
||||
@@ -668,6 +683,9 @@ func testConfig_Sanitized(t *testing.T) {
|
||||
"stackdriver_debug_logs": false,
|
||||
"statsd_address": "bar",
|
||||
"statsite_address": "",
|
||||
"lease_metrics_epsilon": time.Hour,
|
||||
"num_lease_metrics_buckets": 168,
|
||||
"add_lease_metrics_namespace_labels": false,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -787,3 +805,93 @@ func testParseSeals(t *testing.T) {
|
||||
}
|
||||
require.Equal(t, config, expected)
|
||||
}
|
||||
|
||||
func testLoadConfigFileLeaseMetrics(t *testing.T) {
|
||||
config, err := LoadConfigFile("./test-fixtures/config5.hcl")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
expected := &Config{
|
||||
SharedConfig: &configutil.SharedConfig{
|
||||
Listeners: []*configutil.Listener{
|
||||
{
|
||||
Type: "tcp",
|
||||
Address: "127.0.0.1:443",
|
||||
},
|
||||
},
|
||||
|
||||
Telemetry: &configutil.Telemetry{
|
||||
StatsdAddr: "bar",
|
||||
StatsiteAddr: "foo",
|
||||
DisableHostname: false,
|
||||
UsageGaugePeriod: 5 * time.Minute,
|
||||
MaximumGaugeCardinality: 100,
|
||||
DogStatsDAddr: "127.0.0.1:7254",
|
||||
DogStatsDTags: []string{"tag_1:val_1", "tag_2:val_2"},
|
||||
PrometheusRetentionTime: configutil.PrometheusDefaultRetentionTime,
|
||||
MetricsPrefix: "myprefix",
|
||||
LeaseMetricsEpsilon: time.Hour,
|
||||
NumLeaseMetricsTimeBuckets: 2,
|
||||
LeaseMetricsNameSpaceLabels: true,
|
||||
},
|
||||
|
||||
DisableMlock: true,
|
||||
|
||||
Entropy: nil,
|
||||
|
||||
PidFile: "./pidfile",
|
||||
|
||||
ClusterName: "testcluster",
|
||||
},
|
||||
|
||||
Storage: &Storage{
|
||||
Type: "consul",
|
||||
RedirectAddr: "foo",
|
||||
Config: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
|
||||
HAStorage: &Storage{
|
||||
Type: "consul",
|
||||
RedirectAddr: "snafu",
|
||||
Config: map[string]string{
|
||||
"bar": "baz",
|
||||
},
|
||||
DisableClustering: true,
|
||||
},
|
||||
|
||||
ServiceRegistration: &ServiceRegistration{
|
||||
Type: "consul",
|
||||
Config: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
|
||||
DisableCache: true,
|
||||
DisableCacheRaw: true,
|
||||
DisablePrintableCheckRaw: true,
|
||||
DisablePrintableCheck: true,
|
||||
EnableUI: true,
|
||||
EnableUIRaw: true,
|
||||
|
||||
EnableRawEndpoint: true,
|
||||
EnableRawEndpointRaw: true,
|
||||
|
||||
DisableSealWrap: true,
|
||||
DisableSealWrapRaw: true,
|
||||
|
||||
MaxLeaseTTL: 10 * time.Hour,
|
||||
MaxLeaseTTLRaw: "10h",
|
||||
DefaultLeaseTTL: 10 * time.Hour,
|
||||
DefaultLeaseTTLRaw: "10h",
|
||||
}
|
||||
|
||||
addExpectedEntConfig(expected, []string{})
|
||||
|
||||
config.Listeners[0].RawConfig = nil
|
||||
if diff := deep.Equal(config, expected); diff != nil {
|
||||
t.Fatal(diff)
|
||||
}
|
||||
}
|
||||
|
||||
51
command/server/test-fixtures/config5.hcl
Normal file
51
command/server/test-fixtures/config5.hcl
Normal file
@@ -0,0 +1,51 @@
|
||||
disable_cache = true
|
||||
disable_mlock = true
|
||||
|
||||
ui = true
|
||||
|
||||
listener "tcp" {
|
||||
address = "127.0.0.1:443"
|
||||
allow_stuff = true
|
||||
}
|
||||
|
||||
backend "consul" {
|
||||
foo = "bar"
|
||||
advertise_addr = "foo"
|
||||
}
|
||||
|
||||
ha_backend "consul" {
|
||||
bar = "baz"
|
||||
advertise_addr = "snafu"
|
||||
disable_clustering = "true"
|
||||
}
|
||||
|
||||
service_registration "consul" {
|
||||
foo = "bar"
|
||||
}
|
||||
|
||||
telemetry {
|
||||
statsd_address = "bar"
|
||||
usage_gauge_period = "5m"
|
||||
maximum_gauge_cardinality = 100
|
||||
|
||||
statsite_address = "foo"
|
||||
dogstatsd_addr = "127.0.0.1:7254"
|
||||
dogstatsd_tags = ["tag_1:val_1", "tag_2:val_2"]
|
||||
metrics_prefix = "myprefix"
|
||||
|
||||
lease_metrics_epsilon = "1h"
|
||||
num_lease_metrics_buckets = 2
|
||||
add_lease_metrics_namespace_labels = true
|
||||
}
|
||||
|
||||
sentinel {
|
||||
additional_enabled_modules = []
|
||||
}
|
||||
|
||||
max_lease_ttl = "10h"
|
||||
default_lease_ttl = "10h"
|
||||
cluster_name = "testcluster"
|
||||
pid_file = "./pidfile"
|
||||
raw_storage_endpoint = true
|
||||
disable_sealwrap = true
|
||||
disable_printable_check = true
|
||||
Reference in New Issue
Block a user