Documentation
¶
Index ¶
- type AppHistoryPoint
- type DaySummary
- type IngestionRecord
- type Storage
- func (s *Storage) CanonicalKeys() (map[string]string, error)
- func (s *Storage) Close() error
- func (s *Storage) GetAppHistory(appKey string, days int) ([]AppHistoryPoint, error)
- func (s *Storage) GetAppsForDay(dayDate string, sortBy string) ([]TrafficRecord, error)
- func (s *Storage) GetDaySummary(dayDate string) (*DaySummary, error)
- func (s *Storage) GetExternalAppHistory(appKey string, days int) ([]AppHistoryPoint, error)
- func (s *Storage) GetExternalAppsForDay(dayDate string, sortBy string) ([]TrafficRecord, error)
- func (s *Storage) GetExternalDaySummary(dayDate string) (*DaySummary, error)
- func (s *Storage) ListIdentities() ([]*identity.AppIdentity, error)
- func (s *Storage) PruneOldHistory(retentionDays int) (int64, error)
- func (s *Storage) RecordInterfaceStats(ifname string, rxBytes, txBytes uint64) error
- func (s *Storage) RecordUsage(records []IngestionRecord, localLoc *time.Location) error
- type TrafficRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppHistoryPoint ¶
type AppHistoryPoint struct {
Date string `json:"date"`
BytesIn int64 `json:"bytes_in"`
BytesOut int64 `json:"bytes_out"`
TotalBytes int64 `json:"total_bytes"`
}
AppHistoryPoint represents usage on a single day for an app
type DaySummary ¶
type DaySummary struct {
DayDate string `json:"day_date"`
TotalBytesIn int64 `json:"total_bytes_in"`
TotalBytesOut int64 `json:"total_bytes_out"`
TotalBytes int64 `json:"total_bytes"`
ExternalBytes int64 `json:"external_bytes"`
PrivateBytes int64 `json:"private_bytes"`
LoopbackBytes int64 `json:"loopback_bytes"`
UnknownBytes int64 `json:"unknown_bytes"`
ActiveAppCount int `json:"active_app_count"` // Deprecated: use recorded_app_count.
RecordedAppCount int `json:"recorded_app_count"`
UnattributedBytes int64 `json:"unattributed_bytes"`
}
DaySummary aggregates total traffic for a given calendar day
type IngestionRecord ¶
type IngestionRecord struct {
Identity *identity.AppIdentity
ObservedAt time.Time
Category int
BytesIn uint64
BytesOut uint64
PacketsIn uint64
PacketsOut uint64
}
IngestionRecord represents an incoming usage delta mapped to an AppIdentity
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage manages SQLite persistence and metrics storage
func NewStorage ¶
NewStorage opens SQLite database, sets WAL mode, and applies migrations
func (*Storage) CanonicalKeys ¶
CanonicalKeys is also used to sum live rates for command-name aliases.
func (*Storage) GetAppHistory ¶
func (s *Storage) GetAppHistory(appKey string, days int) ([]AppHistoryPoint, error)
GetAppHistory returns daily usage for an application over the past N days
func (*Storage) GetAppsForDay ¶
func (s *Storage) GetAppsForDay(dayDate string, sortBy string) ([]TrafficRecord, error)
GetAppsForDay returns ranked applications for a given day
func (*Storage) GetDaySummary ¶
func (s *Storage) GetDaySummary(dayDate string) (*DaySummary, error)
GetDaySummary returns aggregated day totals
func (*Storage) GetExternalAppHistory ¶ added in v1.1.3
func (s *Storage) GetExternalAppHistory(appKey string, days int) ([]AppHistoryPoint, error)
GetExternalAppHistory excludes local and unclassified traffic, including historical records.
func (*Storage) GetExternalAppsForDay ¶ added in v1.1.3
func (s *Storage) GetExternalAppsForDay(dayDate string, sortBy string) ([]TrafficRecord, error)
GetExternalAppsForDay excludes local and unclassified traffic, including historical records.
func (*Storage) GetExternalDaySummary ¶ added in v1.1.3
func (s *Storage) GetExternalDaySummary(dayDate string) (*DaySummary, error)
GetExternalDaySummary excludes local and unclassified traffic, including historical records.
func (*Storage) ListIdentities ¶
func (s *Storage) ListIdentities() ([]*identity.AppIdentity, error)
func (*Storage) PruneOldHistory ¶
PruneOldHistory removes fine-grained hourly history older than retentionDays
func (*Storage) RecordInterfaceStats ¶
RecordInterfaceStats records raw interface counters for reconciliation
func (*Storage) RecordUsage ¶
func (s *Storage) RecordUsage(records []IngestionRecord, localLoc *time.Location) error
RecordUsage writes aggregated flow deltas to SQLite inside an atomic transaction
type TrafficRecord ¶
type TrafficRecord struct {
AppID int64 `json:"app_id"`
Identity *identity.AppIdentity `json:"identity"`
Category int `json:"category"`
CategoryStr string `json:"category_str"`
BytesIn int64 `json:"bytes_in"`
BytesOut int64 `json:"bytes_out"`
TotalBytes int64 `json:"total_bytes"`
PacketsIn int64 `json:"packets_in"`
PacketsOut int64 `json:"packets_out"`
}
TrafficRecord represents an aggregated usage record for an application