github.com/influxdata/influxdb/v2@v2.7.6/usage.go (about) 1 package influxdb 2 3 import ( 4 "context" 5 "time" 6 7 "github.com/influxdata/influxdb/v2/kit/platform" 8 ) 9 10 // UsageMetric used to track classes of usage. 11 type UsageMetric string 12 13 const ( 14 // UsageWriteRequestCount is the name of the metrics for tracking write request count. 15 UsageWriteRequestCount UsageMetric = "usage_write_request_count" 16 // UsageWriteRequestBytes is the name of the metrics for tracking the number of write bytes. 17 UsageWriteRequestBytes UsageMetric = "usage_write_request_bytes" 18 19 // UsageValues is the name of the metrics for tracking the number of values. 20 UsageValues UsageMetric = "usage_values" 21 // UsageSeries is the name of the metrics for tracking the number of series written. 22 UsageSeries UsageMetric = "usage_series" 23 24 // UsageQueryRequestCount is the name of the metrics for tracking query request count. 25 UsageQueryRequestCount UsageMetric = "usage_query_request_count" 26 // UsageQueryRequestBytes is the name of the metrics for tracking the number of query bytes. 27 UsageQueryRequestBytes UsageMetric = "usage_query_request_bytes" 28 ) 29 30 // Usage is a metric associated with the utilization of a particular resource. 31 type Usage struct { 32 OrganizationID *platform.ID `json:"organizationID,omitempty"` 33 BucketID *platform.ID `json:"bucketID,omitempty"` 34 Type UsageMetric `json:"type"` 35 Value float64 `json:"value"` 36 } 37 38 // UsageService is a service for accessing usage statistics. 39 type UsageService interface { 40 GetUsage(ctx context.Context, filter UsageFilter) (map[UsageMetric]*Usage, error) 41 } 42 43 // UsageFilter is used to filter usage. 44 type UsageFilter struct { 45 OrgID *platform.ID 46 BucketID *platform.ID 47 Range *Timespan 48 } 49 50 // Timespan represents a range of time. 51 type Timespan struct { 52 Start time.Time `json:"start"` 53 Stop time.Time `json:"stop"` 54 }