api: Add reporting fields to activitylog config endpoint (#20086)
This PR adds the internal reporting state to the `internal/counters/config` read endpoint: * reporting_enabled * billing_start_timestamp
This commit is contained in:
parent
8458154fc3
commit
1b5d527521
|
@ -0,0 +1,4 @@
|
|||
```release-note:improvement
|
||||
api: `/sys/internal/counters/config` endpoint now contains read-only
|
||||
`reporting_enabled` and `billing_start_timestamp` fields.
|
||||
```
|
|
@ -838,6 +838,8 @@ func TestActivityLog_API_ConfigCRUD(t *testing.T) {
|
|||
"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 {
|
||||
|
@ -919,6 +921,8 @@ func TestActivityLog_API_ConfigCRUD(t *testing.T) {
|
|||
"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 {
|
||||
|
@ -955,6 +959,8 @@ func TestActivityLog_API_ConfigCRUD(t *testing.T) {
|
|||
"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 {
|
||||
|
|
|
@ -2,5 +2,9 @@
|
|||
|
||||
package vault
|
||||
|
||||
import "time"
|
||||
|
||||
// CensusAgent is a stub for OSS
|
||||
type CensusAgent struct{}
|
||||
type CensusAgent struct {
|
||||
billingStart time.Time
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -271,6 +271,8 @@ func (b *SystemBackend) handleActivityConfigRead(ctx context.Context, req *logic
|
|||
"retention_months": config.RetentionMonths,
|
||||
"enabled": config.Enabled,
|
||||
"queries_available": qa,
|
||||
"reporting_enabled": b.Core.censusLicensingEnabled,
|
||||
"billing_start_timestamp": b.Core.GetBillingStart(),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue