diff --git a/changelog/20086.txt b/changelog/20086.txt new file mode 100644 index 000000000000..9511c97b66e3 --- /dev/null +++ b/changelog/20086.txt @@ -0,0 +1,4 @@ +```release-note:improvement +api: `/sys/internal/counters/config` endpoint now contains read-only +`reporting_enabled` and `billing_start_timestamp` fields. +``` diff --git a/vault/activity_log_test.go b/vault/activity_log_test.go index 8f29113cd41d..5ffbbb18b3dd 100644 --- a/vault/activity_log_test.go +++ b/vault/activity_log_test.go @@ -834,10 +834,12 @@ func TestActivityLog_API_ConfigCRUD(t *testing.T) { t.Fatalf("err: %v", err) } defaults := map[string]interface{}{ - "default_report_months": 12, - "retention_months": 24, - "enabled": activityLogEnabledDefaultValue, - "queries_available": false, + "default_report_months": 12, + "retention_months": 24, + "enabled": activityLogEnabledDefaultValue, + "queries_available": false, + "reporting_enabled": core.censusLicensingEnabled, + "billing_start_timestamp": core.GetBillingStart(), } if diff := deep.Equal(resp.Data, defaults); len(diff) > 0 { @@ -915,10 +917,12 @@ func TestActivityLog_API_ConfigCRUD(t *testing.T) { t.Fatalf("err: %v", err) } expected := map[string]interface{}{ - "default_report_months": 1, - "retention_months": 2, - "enabled": "enable", - "queries_available": false, + "default_report_months": 1, + "retention_months": 2, + "enabled": "enable", + "queries_available": false, + "reporting_enabled": false, + "billing_start_timestamp": core.GetBillingStart(), } if diff := deep.Equal(resp.Data, expected); len(diff) > 0 { @@ -951,10 +955,12 @@ func TestActivityLog_API_ConfigCRUD(t *testing.T) { } defaults := map[string]interface{}{ - "default_report_months": 12, - "retention_months": 24, - "enabled": activityLogEnabledDefaultValue, - "queries_available": false, + "default_report_months": 12, + "retention_months": 24, + "enabled": activityLogEnabledDefaultValue, + "queries_available": false, + "reporting_enabled": false, + "billing_start_timestamp": core.GetBillingStart(), } if diff := deep.Equal(resp.Data, defaults); len(diff) > 0 { diff --git a/vault/census.go b/vault/census.go index 2312b3b54ef1..603fbf48175d 100644 --- a/vault/census.go +++ b/vault/census.go @@ -2,5 +2,9 @@ package vault +import "time" + // CensusAgent is a stub for OSS -type CensusAgent struct{} +type CensusAgent struct { + billingStart time.Time +} diff --git a/vault/core.go b/vault/core.go index 8f2503a16046..ec4452499e9d 100644 --- a/vault/core.go +++ b/vault/core.go @@ -4015,3 +4015,14 @@ func (c *Core) GetRaftAutopilotState(ctx context.Context) (*raft.AutopilotState, func (c *Core) Events() *eventbus.EventBus { return c.events } + +// GetBillingStart gets the billing start timestamp from the configured Census +// Agent, handling a nil agent. +func (c *Core) GetBillingStart() time.Time { + var billingStart time.Time + if c.censusAgent != nil { + billingStart = c.censusAgent.billingStart + } + + return billingStart +} diff --git a/vault/logical_system_activity.go b/vault/logical_system_activity.go index b4cdb0d666d8..fce5f0acfe2f 100644 --- a/vault/logical_system_activity.go +++ b/vault/logical_system_activity.go @@ -267,10 +267,12 @@ func (b *SystemBackend) handleActivityConfigRead(ctx context.Context, req *logic return &logical.Response{ Data: map[string]interface{}{ - "default_report_months": config.DefaultReportMonths, - "retention_months": config.RetentionMonths, - "enabled": config.Enabled, - "queries_available": qa, + "default_report_months": config.DefaultReportMonths, + "retention_months": config.RetentionMonths, + "enabled": config.Enabled, + "queries_available": qa, + "reporting_enabled": b.Core.censusLicensingEnabled, + "billing_start_timestamp": b.Core.GetBillingStart(), }, }, nil } diff --git a/website/content/api-docs/system/internal-counters.mdx b/website/content/api-docs/system/internal-counters.mdx index 5ea156e31aa4..6c1077c056a1 100644 --- a/website/content/api-docs/system/internal-counters.mdx +++ b/website/content/api-docs/system/internal-counters.mdx @@ -924,7 +924,9 @@ $ curl \ "default_report_months": 12, "enabled": "default-enabled", "queries_available": true, - "retention_months": 24 + "retention_months": 24, + "reporting_enabled": false, + "billing_start_timestamp": "2022-03-01T00:00:00Z", }, "warnings": null }