Documentation
¶
Index ¶
- Constants
- Variables
- type Config
- type Counter
- type LineChartData
- type LineData
- type MatcherCounter
- type MatcherCounterStat
- func (c *MatcherCounterStat) DBValues(sid string) []MdnsMatcherCounter
- func (c *MatcherCounterStat) GetTopValues(upstream string, mtype int, count int) []MatcherCounter
- func (c *MatcherCounterStat) Incr(upstream string, name string, tag string, mtype int)
- func (c *MatcherCounterStat) MtypeValues(mtype int) []MatcherCounter
- func (c *MatcherCounterStat) Values(upstream string, mtype int) []MatcherCounter
- type MdnsDomain
- type MdnsLog
- type MdnsMatcher
- type MdnsMatcherCounter
- type MdnsMetricCounter
- type MdnsNetwork
- type MdnsQueryCounter
- type MetricCounter
- type MetricCounterStat
- func (c *MetricCounterStat) DBValues(sid string) []MdnsMetricCounter
- func (c *MetricCounterStat) GetTopValues(metric, count int) []MetricCounter
- func (c *MetricCounterStat) GetValue(metric int, name string) int64
- func (c *MetricCounterStat) Incr(metric int, name string)
- func (c *MetricCounterStat) Values(metric int) []MetricCounter
- type QueryCounter
- type QueryCounterStat
- type TsDB
- func (t *TsDB) ClearHistory() error
- func (t *TsDB) Config() *Config
- func (t *TsDB) DropAll()
- func (t *TsDB) GetDB() *gorm.DB
- func (t *TsDB) Migrate()
- func (t *TsDB) QueryDnsQtypeMetricSumValH24(name string) int64
- func (t *TsDB) QueryGlobalMetricSumValH24(name string) int64
- func (t *TsDB) QueryMatcherNameCounter(start, end time.Time) ([]Counter, error)
- func (t *TsDB) QueryMatcherNameLine(start, end time.Time) (*LineChartData, error)
- func (t *TsDB) QueryMatcherTagCounter(start, end time.Time, mtype int) ([]Counter, error)
- func (t *TsDB) QueryMatcherTagLine(start, end time.Time, mtype int) (*LineChartData, error)
- func (t *TsDB) QueryMetricSumVal(start, end time.Time, metric int, name string) int64
- func (t *TsDB) QueryRequestTop(start, end time.Time, statType, count int) ([]Counter, error)
- func (t *TsDB) Reconnect() error
- func (t *TsDB) Sid() string
- func (t *TsDB) UpdateMdnsLog(data []MdnsLog) error
- func (t *TsDB) UpdateMdnsMatcherCounter(data []MdnsMatcherCounter) error
- func (t *TsDB) UpdateMdnsMetricCounter(data []MdnsMetricCounter) error
- func (t *TsDB) UpdateMdnsQueryCounter(data []MdnsQueryCounter) error
Constants ¶
View Source
const ( MatcherClientIp = 0 MatcherQueryName = 1 MatcherAnswerIp = 2 MatcherAnswerCname = 3 StatTypeQname = 0 StatTypeClient = 1 MetricTypeGlobal = 0 MetricTypeDNSQType = 1 MetricsStatDnsQuery = "dnsquery" MetricsStatEcsHits = "ecshits" MetricsStatNxdomain = "nxdomain" )
Variables ¶
View Source
var DBNotConnect = errors.New("database not connect")
Functions ¶
This section is empty.
Types ¶
type LineChartData ¶
type LineChartData struct {
Title string `json:"title"`
YaxisName string `json:"yaxis_name"`
Datas []LineData `json:"datas"`
}
func NewLineChartData ¶
func NewLineChartData(title string, yaxisName string) *LineChartData
func (*LineChartData) Add ¶
func (d *LineChartData) Add(line ...LineData)
type LineData ¶
type LineData struct {
Name string `json:"name"`
Values [][2]interface{} `json:"values"`
}
func NewLineData ¶
type MatcherCounter ¶
type MatcherCounter struct {
Upstream string `json:"upstream"`
Name string `json:"name"`
Tag string `json:"tag"`
Mtype int `json:"mtype"`
Value int64 `json:"value"`
}
func NewMatcherCounter ¶
func NewMatcherCounter(upstream string, name string, tag string, mtype int) *MatcherCounter
func (*MatcherCounter) Incr ¶
func (d *MatcherCounter) Incr()
func (*MatcherCounter) Val ¶
func (d *MatcherCounter) Val() int64
type MatcherCounterStat ¶
func NewMatcherCounterStat ¶
func NewMatcherCounterStat() *MatcherCounterStat
func (*MatcherCounterStat) DBValues ¶
func (c *MatcherCounterStat) DBValues(sid string) []MdnsMatcherCounter
func (*MatcherCounterStat) GetTopValues ¶
func (c *MatcherCounterStat) GetTopValues(upstream string, mtype int, count int) []MatcherCounter
func (*MatcherCounterStat) Incr ¶
func (c *MatcherCounterStat) Incr(upstream string, name string, tag string, mtype int)
func (*MatcherCounterStat) MtypeValues ¶
func (c *MatcherCounterStat) MtypeValues(mtype int) []MatcherCounter
func (*MatcherCounterStat) Values ¶
func (c *MatcherCounterStat) Values(upstream string, mtype int) []MatcherCounter
type MdnsDomain ¶
type MdnsDomain struct {
ID string `gorm:"primaryKey" json:"id" form:"id"`
Domain string `gorm:"uniqueindex" json:"domain" form:"domain"`
Tag string `json:"tag" form:"tag"`
Mode string `json:"mode" form:"mode"`
Isp string `json:"isp" form:"isp"`
Remark string `json:"remark" form:"remark"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type MdnsLog ¶
type MdnsLog struct {
Timestamp time.Time `gorm:"primaryKey" json:"timestamp"`
Sid string `gorm:"primaryKey" json:"sid"`
MsgId uint16 `gorm:"primaryKey" json:"msg_id"`
Upstream string `json:"upstream"`
Upserver string `json:"upserver"`
Matcher string `json:"matcher"`
QType string `json:"qtype"`
Qname string `json:"qname"`
QnameTag string `json:"qname_tag"`
Client string `json:"client"`
ClientTag string `json:"client_tag"`
ClientLoc string `json:"client_loc"`
Ecs string `json:"ecs"`
EcsLoc string `json:"ecs_loc"`
AnswerIps string `json:"answer_ips"`
AnswerLoc string `json:"answer_loc"`
LocSync int `json:"LocSync"` // GEO 位置同步状态 0 | 1
Rcode int `json:"rcode"`
RcodeStr string `json:"rcode_str"`
Cast int64 `json:"cast"`
Response string `json:"response"`
}
func (MdnsLog) MarshalJSON ¶
type MdnsMatcher ¶
type MdnsMatcher struct {
ID string `gorm:"primaryKey" json:"id" form:"id"`
Enabled int `json:"enabled" form:"enabled"`
Upstream string `json:"upstream" form:"upstream"`
Name string `json:"name" form:"name"`
To string `json:"to" form:"to"`
ClientIps string `json:"client_ips" form:"client_ips"`
AnwserIps string `json:"anwser_ips" form:"anwser_ips"`
QueryNames string `json:"query_names" form:"query_names"`
AnwserCnames string `json:"anwser_cnames" form:"anwser_cnames"`
Notify string `json:"notify" form:"notify"`
Ipset string `json:"ipset" form:"ipset"`
Nxdomain int `json:"nxdomain" form:"nxdomain"`
Remark string `json:"remark" form:"remark"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type MdnsMatcherCounter ¶
type MdnsMatcherCounter struct {
Sid string `gorm:"primaryKey" json:"sid"`
Timestamp time.Time `gorm:"primaryKey;type:timestamp" json:"timestamp"`
Upstream string `gorm:"primaryKey" json:"upstream"`
Name string `gorm:"primaryKey" json:"name"`
Tag string `json:"tag"`
Mtype int `json:"mtype"`
Value int64 `json:"value"`
}
MdnsMatcherCounter 应用匹配统计
type MdnsMetricCounter ¶
type MdnsMetricCounter struct {
Sid string `gorm:"primaryKey" json:"sid"`
Timestamp time.Time `gorm:"primaryKey;type:timestamp" json:"timestamp"`
MetricType int `gorm:"primaryKey" json:"metric_type"`
Name string `gorm:"primaryKey" json:"name"`
Value int64 `json:"value"`
}
MdnsMetricCounter 指标统计
type MdnsNetwork ¶
type MdnsNetwork struct {
ID string `gorm:"primaryKey" json:"id" form:"id"`
Network string `gorm:"uniqueindex" json:"network" form:"network"`
Tag string `json:"tag" form:"tag"`
Isp string `json:"isp" form:"isp"`
Remark string `json:"remark" form:"remark"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type MdnsQueryCounter ¶
type MdnsQueryCounter struct {
Sid string `gorm:"primaryKey" json:"sid"`
Timestamp time.Time `gorm:"primaryKey;type:timestamp" json:"timestamp"`
Upstream string `gorm:"primaryKey" json:"upstream"`
Name string `gorm:"primaryKey" json:"name"`
StatType int `json:"stat_type"` // qname | client
Value int64 `json:"value"`
}
MdnsQueryCounter 查询域名统计
type MetricCounter ¶
type MetricCounter struct {
Metric int `json:"metric"`
Name string `json:"name"`
Value int64 `json:"value"`
}
func NewMetricCounter ¶
func NewMetricCounter(metric int, name string) *MetricCounter
func (*MetricCounter) Incr ¶
func (d *MetricCounter) Incr()
func (*MetricCounter) Val ¶
func (d *MetricCounter) Val() int64
type MetricCounterStat ¶
func NewMetricCounterStat ¶
func NewMetricCounterStat() *MetricCounterStat
func (*MetricCounterStat) DBValues ¶
func (c *MetricCounterStat) DBValues(sid string) []MdnsMetricCounter
func (*MetricCounterStat) GetTopValues ¶
func (c *MetricCounterStat) GetTopValues(metric, count int) []MetricCounter
func (*MetricCounterStat) GetValue ¶
func (c *MetricCounterStat) GetValue(metric int, name string) int64
func (*MetricCounterStat) Incr ¶
func (c *MetricCounterStat) Incr(metric int, name string)
func (*MetricCounterStat) Values ¶
func (c *MetricCounterStat) Values(metric int) []MetricCounter
type QueryCounter ¶
type QueryCounter struct {
Upstream string `json:"upstream"`
Name string `json:"name"`
StatType int `json:"stat_type"` // qname | client
Value int64 `json:"value"`
}
func NewQueryCounter ¶
func NewQueryCounter(upstream, name string, statType int) *QueryCounter
func (*QueryCounter) Incr ¶
func (d *QueryCounter) Incr()
func (*QueryCounter) Val ¶
func (d *QueryCounter) Val() int64
type QueryCounterStat ¶
func NewQueryCounterStat ¶
func NewQueryCounterStat() *QueryCounterStat
func (*QueryCounterStat) DBValues ¶
func (c *QueryCounterStat) DBValues(sid string) []MdnsQueryCounter
func (*QueryCounterStat) GetTopValues ¶
func (c *QueryCounterStat) GetTopValues(statType, count int) []QueryCounter
func (*QueryCounterStat) Incr ¶
func (c *QueryCounterStat) Incr(upstream, name string, statType int)
func (*QueryCounterStat) Values ¶
func (c *QueryCounterStat) Values(statType int) []QueryCounter
type TsDB ¶
type TsDB struct {
// contains filtered or unexported fields
}
func NewLocalDB ¶
func NewLocalDB() *TsDB
func (*TsDB) ClearHistory ¶
func (*TsDB) QueryDnsQtypeMetricSumValH24 ¶
func (*TsDB) QueryGlobalMetricSumValH24 ¶
func (*TsDB) QueryMatcherNameCounter ¶
QueryMatcherNameCounter 查询指定时间范围内统计应用规则计数器列表 如果时间未指定, 默认最近24小时
func (*TsDB) QueryMatcherNameLine ¶
func (t *TsDB) QueryMatcherNameLine(start, end time.Time) (*LineChartData, error)
QueryMatcherNameLine 统计应用规则匹配趋势 如果时间未指定, 默认最近24小时
func (*TsDB) QueryMatcherTagCounter ¶
QueryMatcherTagCounter 查询指定时间范围内统计标签计数器列表 如果时间未指定, 默认最近24小时
mtype: MatcherClientIp = 0 MatcherQueryName = 1 MatcherAnswerIp = 2 MatcherAnswerCname = 3
func (*TsDB) QueryMatcherTagLine ¶
QueryMatcherTagLine 统计应用规则匹配标签趋势 如果时间未指定, 默认最近24小时
mtype MatcherClientIp = 0 MatcherQueryName = 1 MatcherAnswerIp = 2 MatcherAnswerCname = 3
func (*TsDB) QueryMetricSumVal ¶
QueryMetricSumVal 查询指定时间范围内某个指标的总数 如果时间未指定, 默认最近24小时
@param metric MetricTypeGlobal = 0 MetricTypeDNSQType = 1
func (*TsDB) QueryRequestTop ¶
QueryRequestTop 查询指定时间范围内统计类型排名 如果时间未指定, 默认最近24小时
statType: StatTypeQname = 0 StatTypeClient = 1
func (*TsDB) Reconnect ¶
Reconnect dsl "host=%s user=%s password=%s dbname=%s port=%d sslmode=disable TimeZone=Asia/Shanghai"
func (*TsDB) UpdateMdnsLog ¶
func (*TsDB) UpdateMdnsMatcherCounter ¶
func (t *TsDB) UpdateMdnsMatcherCounter(data []MdnsMatcherCounter) error
func (*TsDB) UpdateMdnsMetricCounter ¶
func (t *TsDB) UpdateMdnsMetricCounter(data []MdnsMetricCounter) error
func (*TsDB) UpdateMdnsQueryCounter ¶
func (t *TsDB) UpdateMdnsQueryCounter(data []MdnsQueryCounter) error
Click to show internal directories.
Click to hide internal directories.