You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.1 KiB
97 lines
2.1 KiB
package internal
|
|
|
|
import (
|
|
"io"
|
|
"net"
|
|
"time"
|
|
)
|
|
|
|
const ISO8601 = "2006-01-02 15:04:05.999"
|
|
|
|
var (
|
|
Domain = LogAggregateColumn("domain")
|
|
ClientIP = LogAggregateColumn("clientIp")
|
|
RecurseIP = LogAggregateColumn("recurseUpStreamIP")
|
|
Protocol = LogAggregateColumn("protocol")
|
|
Status = LogAggregateColumn("status")
|
|
LookupError = LogAggregateColumn("error")
|
|
|
|
AggregateKeys = map[string]LogAggregateColumn{
|
|
"domain": Domain,
|
|
"clientIp": ClientIP,
|
|
"recurseUpStreamIP": RecurseIP,
|
|
"protocol": Protocol,
|
|
"status": Status,
|
|
}
|
|
|
|
CountMetric = "Count"
|
|
TotalTimeMetric = "TotalTimeMs"
|
|
ErrorMetric = "Errors"
|
|
RecurseTimeMetric = "RecurseTimeMs"
|
|
)
|
|
|
|
type LogAggregateInput struct {
|
|
IntervalSeconds int
|
|
Start time.Time
|
|
End time.Time
|
|
Column string
|
|
}
|
|
|
|
type StatsDataPoint struct {
|
|
Header string
|
|
Value float64
|
|
Count int
|
|
Time time.Time
|
|
}
|
|
|
|
type Storage interface {
|
|
io.Closer
|
|
Open() error
|
|
AddRecursors(net.IP, int, int, int) error
|
|
GetRecursors() ([]RecursorRow, error)
|
|
UpdateRecursor(int, RecursorRow) error
|
|
DeleteRecursors(int) error
|
|
|
|
AddRule(RuleRow) error
|
|
GetRule(int) (RuleRow, error)
|
|
GetRules() ([]RuleRow, error)
|
|
UpdateRule(int, RuleRow) error
|
|
DeleteRule(int) error
|
|
|
|
Log(QueryLog) error
|
|
GetLog(GetLogInput) (GetLogResult, error)
|
|
GetLogAggregate(LogAggregateInput) (LogAggregate, error)
|
|
}
|
|
|
|
type RecursorRow struct {
|
|
ID int `json:"id"`
|
|
IpAddress string `json:"ipAddress"`
|
|
TimeoutMs int `json:"timeoutMs"`
|
|
Weight int `json:"weight"`
|
|
}
|
|
|
|
type GetLogInput struct {
|
|
Start time.Time `json:"start"`
|
|
End time.Time `json:"end"`
|
|
DomainFilter string `json:"rawfilter"`
|
|
Limit int `json:"pageSize"`
|
|
Page int `json:"page"`
|
|
}
|
|
|
|
type RuleRow struct {
|
|
ID int `json:"id"`
|
|
Weight int `json:"weight"`
|
|
Enabled bool `json:"enabled"`
|
|
Created time.Time `json:"created"`
|
|
Rule
|
|
}
|
|
|
|
type GetLogResult struct {
|
|
GetLogInput
|
|
TotalResults int `json:"total"`
|
|
PageCount int `json:"pageCount"`
|
|
Logs []QueryLog `json:"logs"`
|
|
}
|
|
|
|
type LogAggregateColumn string
|