zerodoc

package
v0.0.0-...-b8a1a0e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppTRIFFIC_RRT_MAX = iota
	AppTRIFFIC_RRT_SUM
	AppTRIFFIC_RRT_COUNT
)
View Source
const (
	APPLATENCY_RRT_MAX = iota
	APPLATENCY_RRT_SUM
	APPLATENCY_RRT_COUNT
)
View Source
const (
	APPANOMALY_CLIENT_ERROR = iota
	APPANOMALY_SERVER_ERROR
	APPANOMALY_TIMEOUT
	APPANOMALY_ERROR
)
View Source
const (
	TRAFFIC_PACKET_TX = iota
	TRAFFIC_PACKET_RX
	TRAFFIC_PACKET

	TRAFFIC_BYTE_TX
	TRAFFIC_BYTE_RX
	TRAFFIC_BYTE

	TRAFFIC_L3_BYTE_TX
	TRAFFIC_L3_BYTE_RX
	TRAFFIC_L4_BYTE_TX
	TRAFFIC_L4_BYTE_RX

	TRAFFIC_NEW_FLOW
	TRAFFIC_CLOSED_FLOW

	TRAFFIC_L7_REQUEST
	TRAFFIC_L7_RESPONSE

	TRAFFIC_SYN_COUNT
	TRAFFIC_SYNACK_COUNT
)
View Source
const (
	LATENCY_RTT = iota
	LATENCY_RTT_CLIENT
	LATENCY_RTT_SERVER
	LATENCY_SRT
	LATENCY_ART
	LATENCY_RRT
	LATENCY_CIT
)
View Source
const (
	PERF_RETRANS_TX = iota
	PERF_RETRANS_RX
	PERF_RETRANS

	PERF_ZERO_WIN_TX
	PERF_ZERO_WIN_RX
	PERF_ZERO_WIN

	PERF_RETRANS_SYN
	PERF_RETRANS_SYNACK
)
View Source
const (
	ANOMALY_CLIENT_RST_FLOW = iota
	ANOMALY_SERVER_RST_FLOW

	ANOMALY_CLIENT_SYN_REPEAT
	ANOMALY_SERVER_SYN_ACK_REPEAT

	ANOMALY_CLIENT_HALF_CLOSE_FLOW
	ANOMALY_SERVER_HALF_CLOSE_FLOW

	ANOMALY_CLIENT_SOURCE_PORT_REUSE
	ANOMALY_SERVER_RESET
	ANOMALY_SERVER_QUEUE_LACK

	ANOMALY_CLIENT_ESTABLISH_OTHER_RST
	ANOMALY_SERVER_ESTABLISH_OTHER_RST

	ANOMALY_TCP_TIMEOUT

	ANOMALY_CLIENT_ESTABLISH_FAIL
	ANOMALY_SERVER_ESTABLISH_FAIL
	ANOMALY_TCP_ESTABLISH_FAIL

	ANOMALY_TRANSFER_FAIL
	ANOMALY_RST_FAIL
)
View Source
const (
	ANOMALY_L7_CLIENT_ERROR = iota
	ANOMALY_L7_SERVER_ERROR
	ANOMALY_L7_TIMEOUT
	ANOMALY_L7_ERROR
)
View Source
const (
	FLOW_SECOND_ID uint8 = iota
	FLOW_ID

	ACL_ID // 目前meter的ACL_ID和PACKET_ID内容一致
	APP_ID

	MAX_APP_ID
)
View Source
const (
	MAIN uint8 = iota

	MAX_MEASUREMENT_ID
)
View Source
const (
	ClientToServer = 1 << iota
	ServerToClient
	LocalToLocal

	// 以下类型为转换tapside而增加,在写入db时均记为c2s或s2c
	ClientNodeToServer              = ClientToServer | DirectionEnum(NodeSide)              // 客户端容器节点,路由、SNAT、隧道
	ServerNodeToClient              = ServerToClient | DirectionEnum(NodeSide)              // 服务端容器节点,路由、SNAT、隧道
	ClientHypervisorToServer        = ClientToServer | DirectionEnum(HypervisorSide)        // 客户端宿主机,隧道
	ServerHypervisorToClient        = ServerToClient | DirectionEnum(HypervisorSide)        // 服务端宿主机,隧道
	ClientGatewayHypervisorToServer = ClientToServer | DirectionEnum(GatewayHypervisorSide) // 客户端网关宿主机
	ServerGatewayHypervisorToClient = ServerToClient | DirectionEnum(GatewayHypervisorSide) // 服务端网关宿主机
	ClientGatewayToServer           = ClientToServer | DirectionEnum(GatewaySide)           // 客户端网关(特指VIP机制的SLB,例如微软云MUX等), Mac地址对应的接口为vip设备
	ServerGatewayToClient           = ServerToClient | DirectionEnum(GatewaySide)           // 服务端网关(特指VIP机制的SLB,例如微软云MUX等), Mac地址对应的接口为vip设备
	ClientProcessToServer           = ClientToServer | DirectionEnum(ProcessSide)           // 客户端进程
	ServerProcessToClient           = ServerToClient | DirectionEnum(ProcessSide)           // 服务端进程
	ClientAppToServer               = ClientToServer | DirectionEnum(AppSide)               // 客户端应用
	ServerAppToClient               = ServerToClient | DirectionEnum(AppSide)               // 服务端应用
)
View Source
const (
	Client TAPSideEnum = 1 << iota
	Server
	Local
	ClientNode              = Client | TAPSideEnum(NodeSide)
	ServerNode              = Server | TAPSideEnum(NodeSide)
	ClientHypervisor        = Client | TAPSideEnum(HypervisorSide)
	ServerHypervisor        = Server | TAPSideEnum(HypervisorSide)
	ClientGatewayHypervisor = Client | TAPSideEnum(GatewayHypervisorSide)
	ServerGatewayHypervisor = Server | TAPSideEnum(GatewayHypervisorSide)
	ClientGateway           = Client | TAPSideEnum(GatewaySide)
	ServerGateway           = Server | TAPSideEnum(GatewaySide)
	ClientProcess           = Client | TAPSideEnum(ProcessSide)
	ServerProcess           = Server | TAPSideEnum(ProcessSide)
	ClientApp               = Client | TAPSideEnum(AppSide)
	ServerApp               = Server | TAPSideEnum(AppSide)
	App                     = TAPSideEnum(AppSide)
	Rest                    = 0
)
View Source
const (
	ID_OTHER    = -1
	ID_INTERNET = -2
)
View Source
const (
	SUFFIX_ACL = 1 + iota
	SUFFIX_EDGE
	SUFFIX_ACL_EDGE
	SUFFIX_PORT
	SUFFIX_ACL_PORT
	SUFFIX_EDGE_PORT
	SUFFIX_ACL_EDGE_PORT
)
View Source
const (
	USAGE_PACKET_TX = iota
	USAGE_PACKET_RX
	USAGE_PACKET

	USAGE_BYTE_TX
	USAGE_BYTE_RX
	USAGE_BYTE

	USAGE_L3_BYTE_TX
	USAGE_L3_BYTE_RX
	USAGE_L4_BYTE_TX
	USAGE_L4_BYTE_RX
)
View Source
const (
	FLOW_LOAD = iota
)
View Source
const (
	MAX_STRING_LENGTH = 2048
)
View Source
const (
	MINI_FIELD_FULL_CODES = IP | IPPath | L3EpcID | L3EpcIDPath | VTAPID | Protocol | ServerPort |
		MAC | MACPath | Direction | TAPType | ACLGID | L7Protocol | TagType | TagValue
)
View Source
const (
	TAG_TYPE_TUNNEL_IP_ID
)
View Source
const TAP_PORT_STR_LEN = 8

Variables

View Source
var DatabaseSuffix = [...]string{
	0:                    "",
	SUFFIX_ACL:           "_acl",
	SUFFIX_EDGE:          "_edge",
	SUFFIX_ACL_EDGE:      "_acl_edge",
	SUFFIX_PORT:          "_port",
	SUFFIX_ACL_PORT:      "_acl_port",
	SUFFIX_EDGE_PORT:     "_edge_port",
	SUFFIX_ACL_EDGE_PORT: "_acl_edge_port",
}
View Source
var MeasurementNames [MAX_MEASUREMENT_ID]string = [MAX_MEASUREMENT_ID]string{
	"main",
}
View Source
var MeasurementNamesToID map[string]uint8
View Source
var MeterNamesToID map[string]uint8
View Source
var MeterVTAPNames [MAX_APP_ID]string = [MAX_APP_ID]string{
	"vtap_flow",
	"vtap_flow",
	"vtap_wan",
	"vtap_packet",
	"vtap_acl",
	"vtap_app",
}
View Source
var TAPSideEnumsString = []string{
	Rest:                    "rest",
	Client:                  "c",
	Server:                  "s",
	Local:                   "local",
	ClientNode:              "c-nd",
	ServerNode:              "s-nd",
	ClientHypervisor:        "c-hv",
	ServerHypervisor:        "s-hv",
	ClientGatewayHypervisor: "c-gw-hv",
	ServerGatewayHypervisor: "s-gw-hv",
	ClientGateway:           "c-gw",
	ServerGateway:           "s-gw",
	ClientProcess:           "c-p",
	ServerProcess:           "s-p",
	ClientApp:               "c-app",
	ServerApp:               "s-app",
	App:                     "app",
}

Functions

func AnomalyColumns

func AnomalyColumns() []*ckdb.Column

Columns列和WriteBlock的列需要按顺序一一对应

func AppAnomalyColumns

func AppAnomalyColumns() []*ckdb.Column

Columns列和WriteBlock的列需要按顺序一一对应

func AppLatencyColumns

func AppLatencyColumns() []*ckdb.Column

Columns列和WriteBlock的列需要按顺序一一对应

func AppMeterColumns

func AppMeterColumns() []*ckdb.Column

func AppTrafficColumns

func AppTrafficColumns() []*ckdb.Column

Columns列和WriteBlock的列需要按顺序一一对应

func EncodeAppMeterToMetrics

func EncodeAppMeterToMetrics(meter *AppMeter) map[string]float64

func EncodeCustomTagToPromLabels

func EncodeCustomTagToPromLabels(tag *CustomTag) []prompb.Label

EncodeCustomTagToPromLabels 将 CustomTag 编码成 prom Label

func EncodeMiniTagToPromLabels

func EncodeMiniTagToPromLabels(tag *MiniTag) []prompb.Label

EncodeMiniTagToPromLabels 将 MiniTag 转换成 prom Label

func EncodeTSDBRow

func EncodeTSDBRow(encoder *codec.SimpleEncoder, timestamp uint64, columnValues []interface{}, isTag []bool, isNil []bool)

func EncodeTagToPromLabels

func EncodeTagToPromLabels(tag *Tag) []prompb.Label

EncodeTagToPromLabels 将 Tag 编码成 prom Label

func FlowLoadColumns

func FlowLoadColumns() []*ckdb.Column

func FlowMeterColumns

func FlowMeterColumns() []*ckdb.Column

func GenTagColumns

func GenTagColumns(code Code) []*ckdb.Column

顺序需要和WriteBlock中一致, 目前time排第一位,其他按字段名字典排序

func GenUniversalTagColumns

func GenUniversalTagColumns(columns []*ckdb.Column) []*ckdb.Column

Note: The order of append() must be consistent with the order of Write() in WriteBlock. Currently all fields are sorted lexicographically by name.

func GetMeasurementID

func GetMeasurementID(name string) uint8

func GetMeterID

func GetMeterID(name string) uint8

func GetMetricsTables

func GetMetricsTables(engine ckdb.EngineType, version, cluster, storagePolicy string, flowMinuteTtl, flowSecondTtl, appMinuteTtl, appSecondTtl int, coldStorages map[string]*ckdb.ColdStorage) []*ckdb.Table

func LatencyColumns

func LatencyColumns() []*ckdb.Column

Columns列和WriteBlock的列需要按顺序一一对应

func MarshalInt32WithSpecialID

func MarshalInt32WithSpecialID(v int32) int32

func PerformanceColumns

func PerformanceColumns() []*ckdb.Column

Columns列和WriteBlock的列需要按顺序一一对应

func ReleaseField

func ReleaseField(field *Field)

func ReleaseMiniField

func ReleaseMiniField(miniField *MiniField)

func ReleaseMiniTag

func ReleaseMiniTag(miniTag *MiniTag)

ReleaseMiniTag 需要释放Tag拥有的Field

func ReleaseTag

func ReleaseTag(tag *Tag)

ReleaseTag 需要释放Tag拥有的Field

func TrafficColumns

func TrafficColumns() []*ckdb.Column

Columns列和WriteBlock的列需要按顺序一一对应

func UsageMeterColumns

func UsageMeterColumns() []*ckdb.Column

Columns列和WriteBlock的列需要一一对应

Types

type Anomaly

type Anomaly struct {
	ClientRstFlow       uint64 `db:"client_rst_flow"`
	ServerRstFlow       uint64 `db:"server_rst_flow"`
	ClientSynRepeat     uint64 `db:"client_syn_repeat"`
	ServerSYNACKRepeat  uint64 `db:"server_syn_ack_repeat"`
	ClientHalfCloseFlow uint64 `db:"client_half_close_flow"`
	ServerHalfCloseFlow uint64 `db:"server_half_close_flow"`

	ClientSourcePortReuse uint64 `db:"client_source_port_reuse"`
	ClientEstablishReset  uint64 `db:"client_establish_other_rst"`
	ServerReset           uint64 `db:"server_reset"`
	ServerQueueLack       uint64 `db:"server_queue_lack"`
	ServerEstablishReset  uint64 `db:"server_establish_other_rst"`
	TCPTimeout            uint64 `db:"tcp_timeout"`

	L7ClientError uint32 `db:"l7_client_error"`
	L7ServerError uint32 `db:"l7_server_error"`
	L7Timeout     uint32 `db:"l7_timeout"`
}

func (*Anomaly) ConcurrentMerge

func (a *Anomaly) ConcurrentMerge(other *Anomaly)

func (*Anomaly) MarshalTo

func (a *Anomaly) MarshalTo(b []byte) int

func (*Anomaly) ReadFromPB

func (a *Anomaly) ReadFromPB(p *pb.Anomaly)

func (*Anomaly) Reverse

func (_ *Anomaly) Reverse()

func (*Anomaly) SequentialMerge

func (a *Anomaly) SequentialMerge(other *Anomaly)

func (*Anomaly) WriteBlock

func (a *Anomaly) WriteBlock(block *ckdb.Block)

WriteBlock的列和AnomalyColumns需要按顺序一一对应

func (*Anomaly) WriteToPB

func (a *Anomaly) WriteToPB(p *pb.Anomaly)

type AppAnomaly

type AppAnomaly struct {
	ClientError uint32 `db:"client_error"`
	ServerError uint32 `db:"server_error"`
	Timeout     uint32 `db:"timeout"`
}

func (*AppAnomaly) ConcurrentMerge

func (a *AppAnomaly) ConcurrentMerge(other *AppAnomaly)

func (*AppAnomaly) MarshalTo

func (a *AppAnomaly) MarshalTo(b []byte) int

func (*AppAnomaly) ReadFromPB

func (a *AppAnomaly) ReadFromPB(p *pb.AppAnomaly)

func (*AppAnomaly) Reverse

func (_ *AppAnomaly) Reverse()

func (*AppAnomaly) SequentialMerge

func (a *AppAnomaly) SequentialMerge(other *AppAnomaly)

func (*AppAnomaly) WriteBlock

func (a *AppAnomaly) WriteBlock(block *ckdb.Block)

WriteBlock的列和AnomalyColumns需要按顺序一一对应

func (*AppAnomaly) WriteToPB

func (a *AppAnomaly) WriteToPB(p *pb.AppAnomaly)

type AppLatency

type AppLatency struct {
	RRTMax   uint32 `db:"rrt_max"` // us
	RRTSum   uint64 `db:"rrt_sum"` // us
	RRTCount uint32 `db:"rrt_count"`
}

func (*AppLatency) ConcurrentMerge

func (l *AppLatency) ConcurrentMerge(other *AppLatency)

func (*AppLatency) MarshalTo

func (l *AppLatency) MarshalTo(b []byte) int

func (*AppLatency) ReadFromPB

func (l *AppLatency) ReadFromPB(p *pb.AppLatency)

func (*AppLatency) Reverse

func (_ *AppLatency) Reverse()

func (*AppLatency) SequentialMerge

func (l *AppLatency) SequentialMerge(other *AppLatency)

func (*AppLatency) WriteBlock

func (l *AppLatency) WriteBlock(block *ckdb.Block)

WriteBlock和LatencyColumns的列需要按顺序一一对应

func (*AppLatency) WriteToPB

func (l *AppLatency) WriteToPB(p *pb.AppLatency)

type AppMeter

type AppMeter struct {
	AppTraffic
	AppLatency
	AppAnomaly
}

func (*AppMeter) ConcurrentMerge

func (m *AppMeter) ConcurrentMerge(other Meter)

func (*AppMeter) ID

func (m *AppMeter) ID() uint8

func (*AppMeter) MarshalTo

func (m *AppMeter) MarshalTo(b []byte) int

func (*AppMeter) Name

func (m *AppMeter) Name() string

func (*AppMeter) ReadFromPB

func (m *AppMeter) ReadFromPB(p *pb.AppMeter)

func (*AppMeter) Reverse

func (m *AppMeter) Reverse()

func (*AppMeter) SequentialMerge

func (m *AppMeter) SequentialMerge(other Meter)

func (*AppMeter) SortKey

func (m *AppMeter) SortKey() uint64

func (*AppMeter) ToKVString

func (m *AppMeter) ToKVString() string

func (*AppMeter) VTAPName

func (m *AppMeter) VTAPName() string

func (*AppMeter) WriteBlock

func (m *AppMeter) WriteBlock(block *ckdb.Block)

func (*AppMeter) WriteToPB

func (m *AppMeter) WriteToPB(p *pb.AppMeter)

type AppTraffic

type AppTraffic struct {
	Request        uint32 `db:"request"`
	Response       uint32 `db:"response"`
	DirectionScore uint8  `db:"direction_score"`
}

func (*AppTraffic) ConcurrentMerge

func (t *AppTraffic) ConcurrentMerge(other *AppTraffic)

func (*AppTraffic) MarshalTo

func (t *AppTraffic) MarshalTo(b []byte) int

func (*AppTraffic) ReadFromPB

func (t *AppTraffic) ReadFromPB(p *pb.AppTraffic)

func (*AppTraffic) Reverse

func (_ *AppTraffic) Reverse()

func (*AppTraffic) SequentialMerge

func (t *AppTraffic) SequentialMerge(other *AppTraffic)

func (*AppTraffic) WriteBlock

func (t *AppTraffic) WriteBlock(block *ckdb.Block)

WriteBlock和LatencyColumns的列需要按顺序一一对应

func (*AppTraffic) WriteToPB

func (t *AppTraffic) WriteToPB(p *pb.AppTraffic)

type Code

type Code uint64
const (
	IP Code = 0x1 << iota
	L3EpcID
	L3Device
	SubnetID
	RegionID
	PodNodeID
	HostID
	AZID
	PodGroupID
	PodNSID
	PodID
	MAC
	PodClusterID
	ServiceID
	Resource // 1<< 14
	GPID     // 1<< 15

)
const (
	IPPath Code = 0x100000 << iota // 1 << 20
	L3EpcIDPath
	L3DevicePath
	SubnetIDPath
	RegionIDPath
	PodNodeIDPath
	HostIDPath
	AZIDPath
	PodGroupIDPath
	PodNSIDPath
	PodIDPath
	MACPath
	PodClusterIDPath
	ServiceIDPath
	ResourcePath // 1<< 34
	GPIDPath     // 1<< 35

)
const (
	Direction Code = 0x10000000000 << iota // 1 << 40
	ACLGID
	Protocol
	ServerPort

	TAPType

	VTAPID
	TAPSide
	TAPPort
	IsKeyService
	L7Protocol
	SignalSource
)
const (
	TagType  Code = 1 << 62
	TagValue Code = 1 << 63
)

func (Code) HasEdgeTagField

func (c Code) HasEdgeTagField() bool

type CustomMeter

type CustomMeter struct {
	Meta *CustomMeterMeta

	Values []uint64
}

func (*CustomMeter) Decode

func (m *CustomMeter) Decode(decoder *codec.SimpleDecoder)

func (*CustomMeter) Encode

func (m *CustomMeter) Encode(encoder *codec.SimpleEncoder)

type CustomMeterMeta

type CustomMeterMeta struct {
	Names []string
	Types []CustomMeterType
	// contains filtered or unexported fields
}

func (*CustomMeterMeta) IndexOf

func (m *CustomMeterMeta) IndexOf(name string) int

func (*CustomMeterMeta) PopulateCache

func (m *CustomMeterMeta) PopulateCache()

func (*CustomMeterMeta) Validate

func (m *CustomMeterMeta) Validate(cm *CustomMeter) bool

type CustomMeterType

type CustomMeterType uint8
const (
	CUSTOM_METER_U64 CustomMeterType = iota
	CUSTOM_METER_U32
)

type CustomTag

type CustomTag struct {
	Meta *CustomTagMeta

	Values []string
	// 每一位表示对应index下的Values[i]有意义
	// 如 Code=3时Values[0]和Values[1]有意义
	Code uint64

	pool.ReferenceCount
	// contains filtered or unexported fields
}

func AcquireCustomTag

func AcquireCustomTag() *CustomTag

func (*CustomTag) Clone

func (t *CustomTag) Clone() Tagger

func (*CustomTag) Decode

func (t *CustomTag) Decode(decoder *codec.SimpleDecoder)

func (*CustomTag) Encode

func (t *CustomTag) Encode(encoder *codec.SimpleEncoder)

func (*CustomTag) EncodeWithCode

func (t *CustomTag) EncodeWithCode(code uint64, encoder *codec.SimpleEncoder)

func (*CustomTag) GetCode

func (t *CustomTag) GetCode() uint64

func (*CustomTag) GetID

func (t *CustomTag) GetID(encoder *codec.SimpleEncoder) string

func (*CustomTag) GetTAPType

func (t *CustomTag) GetTAPType() uint8

func (*CustomTag) MarshalTo

func (t *CustomTag) MarshalTo(b []byte) int

func (*CustomTag) PseudoClone

func (t *CustomTag) PseudoClone() Tagger

func (*CustomTag) Release

func (t *CustomTag) Release()

func (*CustomTag) SetCode

func (t *CustomTag) SetCode(code uint64)

func (*CustomTag) SetID

func (t *CustomTag) SetID(id string)

func (*CustomTag) String

func (t *CustomTag) String() string

func (*CustomTag) ToKVString

func (t *CustomTag) ToKVString() string

type CustomTagMeta

type CustomTagMeta struct {
	Names []string
	// contains filtered or unexported fields
}

func (*CustomTagMeta) IndexOf

func (m *CustomTagMeta) IndexOf(name string) int

func (*CustomTagMeta) PopulateCache

func (m *CustomTagMeta) PopulateCache()

func (*CustomTagMeta) Validate

func (m *CustomTagMeta) Validate(ct *CustomTag) bool

type CustomTagMeterMeta

type CustomTagMeterMeta struct {
	Tag   CustomTagMeta
	Meter CustomMeterMeta
}

func (*CustomTagMeterMeta) Decode

func (t *CustomTagMeterMeta) Decode(decoder *codec.SimpleDecoder)

func (*CustomTagMeterMeta) Encode

func (t *CustomTagMeterMeta) Encode(encoder *codec.SimpleEncoder)

type DeviceType

type DeviceType uint8
const (
	VMDevice DeviceType

	ThirdPartyDevice // 3

	VGatewayDevice // 5
	HostDevice
	NetworkDevice
	FloatingIPDevice
	DHCPDevice
)

type DirectionEnum

type DirectionEnum uint8

func (DirectionEnum) IsClientToServer

func (d DirectionEnum) IsClientToServer() bool

func (DirectionEnum) IsGateway

func (d DirectionEnum) IsGateway() bool

func (DirectionEnum) IsServerToClient

func (d DirectionEnum) IsServerToClient() bool

func (DirectionEnum) ToTAPSide

func (d DirectionEnum) ToTAPSide() TAPSideEnum

type Field

type Field struct {

	// 用于区分不同的trident及其不同的pipeline,用于如下场景:
	//   - agent和ingester之间的数据传输
	//   - ingester写入clickhouse,作用类似_id,序列化为_tid
	GlobalThreadID uint8

	IP6              net.IP // FIXME: 合并IP6和IP
	MAC              uint64
	IP               uint32
	L3EpcID          int32 // (8B)
	L3DeviceID       uint32
	L3DeviceType     DeviceType
	RegionID         uint16
	SubnetID         uint16
	HostID           uint16
	PodNodeID        uint32
	AZID             uint16
	PodGroupID       uint32
	PodNSID          uint16
	PodID            uint32
	PodClusterID     uint16
	ServiceID        uint32
	AutoInstanceID   uint32
	AutoInstanceType uint8
	AutoServiceID    uint32
	AutoServiceType  uint8
	GPID             uint32

	MAC1              uint64
	IP61              net.IP // FIXME: 合并IP61和IP1
	IP1               uint32
	L3EpcID1          int32 // (8B)
	L3DeviceID1       uint32
	L3DeviceType1     DeviceType // (+1B=8B)
	RegionID1         uint16
	SubnetID1         uint16 // (8B)
	HostID1           uint16
	PodNodeID1        uint32
	AZID1             uint16
	PodGroupID1       uint32
	PodNSID1          uint16
	PodID1            uint32
	PodClusterID1     uint16
	ServiceID1        uint32
	AutoInstanceID1   uint32
	AutoInstanceType1 uint8
	AutoServiceID1    uint32
	AutoServiceType1  uint8
	GPID1             uint32

	ACLGID       uint16
	Direction    DirectionEnum
	Protocol     layers.IPProtocol
	ServerPort   uint16
	VTAPID       uint16
	TAPPort      datatype.TapPort
	TAPSide      TAPSideEnum
	TAPType      TAPTypeEnum
	IsIPv6       uint8 // (8B) 与IP/IP6是共生字段
	IsKeyService uint8
	L7Protocol   datatype.L7Protocol
	AppService   string
	AppInstance  string
	Endpoint     string
	SignalSource uint16

	TagSource, TagSource1 uint8

	TagType  uint8
	TagValue uint16
}

func AcquireField

func AcquireField() *Field

func CloneField

func CloneField(field *Field) *Field

func (*Field) NewTag

func (f *Field) NewTag(c Code) *Tag

type FlowLoad

type FlowLoad struct {
	Load uint64 `db:"flow_load"`
}

func (*FlowLoad) ConcurrentMerge

func (l *FlowLoad) ConcurrentMerge(other *FlowLoad)

func (*FlowLoad) MarshalTo

func (l *FlowLoad) MarshalTo(b []byte) int

func (*FlowLoad) ReadFromPB

func (l *FlowLoad) ReadFromPB(p *pb.FlowLoad)

func (*FlowLoad) Reverse

func (l *FlowLoad) Reverse()

func (*FlowLoad) SequentialMerge

func (l *FlowLoad) SequentialMerge(other *FlowLoad)

func (*FlowLoad) WriteBlock

func (l *FlowLoad) WriteBlock(block *ckdb.Block)

func (*FlowLoad) WriteToPB

func (l *FlowLoad) WriteToPB(p *pb.FlowLoad)

type FlowMeter

type FlowMeter struct {
	Traffic
	Latency
	Performance
	Anomaly
	FlowLoad
}

func (*FlowMeter) ConcurrentMerge

func (m *FlowMeter) ConcurrentMerge(other Meter)

func (*FlowMeter) ID

func (m *FlowMeter) ID() uint8

func (*FlowMeter) MarshalTo

func (m *FlowMeter) MarshalTo(b []byte) int

func (*FlowMeter) Name

func (m *FlowMeter) Name() string

func (*FlowMeter) ReadFromPB

func (m *FlowMeter) ReadFromPB(p *pb.FlowMeter)

func (*FlowMeter) Reverse

func (m *FlowMeter) Reverse()

func (*FlowMeter) SequentialMerge

func (m *FlowMeter) SequentialMerge(other Meter)

func (*FlowMeter) SortKey

func (m *FlowMeter) SortKey() uint64

func (*FlowMeter) ToKVString

func (m *FlowMeter) ToKVString() string

func (*FlowMeter) VTAPName

func (m *FlowMeter) VTAPName() string

func (*FlowMeter) WriteBlock

func (m *FlowMeter) WriteBlock(block *ckdb.Block)

func (*FlowMeter) WriteToPB

func (m *FlowMeter) WriteToPB(p *pb.FlowMeter)

type Latency

type Latency struct {
	RTTMax       uint32 `db:"rtt_max"`        // us,Trident保证时延最大值不会超过3600s,能容纳在u32内
	RTTClientMax uint32 `db:"rtt_client_max"` // us
	RTTServerMax uint32 `db:"rtt_server_max"` // us
	SRTMax       uint32 `db:"srt_max"`        // us
	ARTMax       uint32 `db:"art_max"`        // us
	RRTMax       uint32 `db:"rrt_max"`        // us
	CITMax       uint32 `db:"cit_max"`        // client idle time max

	RTTSum       uint64 `db:"rtt_sum"`        // us
	RTTClientSum uint64 `db:"rtt_client_sum"` // us
	RTTServerSum uint64 `db:"rtt_server_sum"` // us
	SRTSum       uint64 `db:"srt_sum"`        // us
	ARTSum       uint64 `db:"art_sum"`        // us
	RRTSum       uint64 `db:"rrt_sum"`        // us
	CITSum       uint64 `db:"cit_sum"`

	RTTCount       uint32 `db:"rtt_count"`
	RTTClientCount uint32 `db:"rtt_client_count"`
	RTTServerCount uint32 `db:"rtt_server_count"`
	SRTCount       uint32 `db:"srt_count"`
	ARTCount       uint32 `db:"art_count"`
	RRTCount       uint32 `db:"rrt_count"`
	CITCount       uint32 `db:"cit_count"`
}

func (*Latency) ConcurrentMerge

func (l *Latency) ConcurrentMerge(other *Latency)

func (*Latency) MarshalTo

func (l *Latency) MarshalTo(b []byte) int

func (*Latency) ReadFromPB

func (l *Latency) ReadFromPB(p *pb.Latency)

func (*Latency) Reverse

func (_ *Latency) Reverse()

func (*Latency) SequentialMerge

func (l *Latency) SequentialMerge(other *Latency)

func (*Latency) WriteBlock

func (l *Latency) WriteBlock(block *ckdb.Block)

WriteBlock和LatencyColumns的列需要按顺序一一对应

func (*Latency) WriteToPB

func (l *Latency) WriteToPB(p *pb.Latency)

type Meter

type Meter interface {
	ID() uint8
	Name() string
	VTAPName() string
	ConcurrentMerge(Meter)
	SequentialMerge(Meter)
	ToKVString() string
	MarshalTo([]byte) int
	SortKey() uint64
	Clone() Meter
	Release()
	Reverse()
	ToReversed() Meter
	WriteBlock(block *ckdb.Block) // 写入clickhouse的block
}

type MetricsTableID

type MetricsTableID uint8
const (
	VTAP_FLOW_PORT_1M MetricsTableID = iota
	VTAP_FLOW_EDGE_PORT_1M

	VTAP_APP_PORT_1M
	VTAP_APP_EDGE_PORT_1M

	VTAP_ACL_1M

	VTAP_FLOW_PORT_1S
	VTAP_FLOW_EDGE_PORT_1S

	VTAP_APP_PORT_1S
	VTAP_APP_EDGE_PORT_1S

	VTAP_TABLE_ID_MAX
)

func MetricsTableNameToID

func MetricsTableNameToID(name string) MetricsTableID

func (MetricsTableID) TableCode

func (i MetricsTableID) TableCode() Code

func (MetricsTableID) TableName

func (i MetricsTableID) TableName() string

type MiniField

type MiniField struct {

	// 用于区分不同的agent及其不同的pipeline,用于如下场景:
	//   - agent和ingester之间的数据传输
	//   - ingester写入clickhouse,作用类似_id,序列化为_tid
	GlobalThreadID uint8
	IsIPv6         uint8 // 与IP/IP6是共生字段
	L3EpcID        int16
	L3EpcID1       int16

	MAC, MAC1  uint64
	Direction  DirectionEnum
	Protocol   layers.IPProtocol // (8B)
	ACLGID     uint16
	ServerPort uint16
	VTAPID     uint16
	TAPPort    datatype.TapPort
	TAPType    TAPTypeEnum
	L7Protocol datatype.L7Protocol

	TagType  uint8 // (8B)
	TagValue uint16

	AppService  string
	AppInstance string
	// contains filtered or unexported fields
}

func AcquireMiniField

func AcquireMiniField() *MiniField

func CloneMiniField

func CloneMiniField(miniField *MiniField) *MiniField

func (*MiniField) IP

func (f *MiniField) IP() net.IP

func (*MiniField) IP1

func (f *MiniField) IP1() net.IP

func (*MiniField) SetIP

func (f *MiniField) SetIP(ip net.IP)

func (*MiniField) SetIP1

func (f *MiniField) SetIP1(ip net.IP)

func (*MiniField) WriteToPB

func (f *MiniField) WriteToPB(p *pb.MiniField)

type MiniTag

type MiniTag struct {
	*MiniField
	Code
	// contains filtered or unexported fields
}

func AcquireMiniTag

func AcquireMiniTag() *MiniTag

func CloneMiniTag

func CloneMiniTag(miniTag *MiniTag) *MiniTag

CloneMiniTag 需要复制Tag拥有的Field

func (*MiniTag) Clone

func (t *MiniTag) Clone() Tagger

func (*MiniTag) Decode

func (t *MiniTag) Decode(_ *codec.SimpleDecoder)

func (*MiniTag) GetCode

func (t *MiniTag) GetCode() uint64

func (*MiniTag) GetTAPType

func (t *MiniTag) GetTAPType() uint8

func (*MiniTag) MarshalTo

func (t *MiniTag) MarshalTo(b []byte) int

注意: 必须要按tag字段的字典顺序进行处理

func (*MiniTag) Release

func (t *MiniTag) Release()

func (*MiniTag) SetCode

func (t *MiniTag) SetCode(code uint64)

func (*MiniTag) SetID

func (t *MiniTag) SetID(id string)

func (*MiniTag) SetTID

func (t *MiniTag) SetTID(tid uint8)

func (*MiniTag) String

func (t *MiniTag) String() string

func (*MiniTag) ToKVString

func (t *MiniTag) ToKVString() string

只用于调试

func (*MiniTag) WriteToPB

func (t *MiniTag) WriteToPB(p *pb.MiniTag)

type Performance

type Performance struct {
	RetransTx     uint64 `db:"retrans_tx"`
	RetransRx     uint64 `db:"retrans_rx"`
	ZeroWinTx     uint64 `db:"zero_win_tx"`
	ZeroWinRx     uint64 `db:"zero_win_rx"`
	RetransSyn    uint32 `db:"retrans_syn"`
	RetransSynack uint32 `db:"retrans_synack"`
}

func (*Performance) ConcurrentMerge

func (a *Performance) ConcurrentMerge(other *Performance)

func (*Performance) MarshalTo

func (a *Performance) MarshalTo(b []byte) int

func (*Performance) ReadFromPB

func (a *Performance) ReadFromPB(p *pb.Performance)

func (*Performance) Reverse

func (a *Performance) Reverse()

func (*Performance) SequentialMerge

func (a *Performance) SequentialMerge(other *Performance)

func (*Performance) WriteBlock

func (a *Performance) WriteBlock(block *ckdb.Block)

WriteBlock的列和PerformanceColumns需要按顺序一一对应

func (*Performance) WriteToPB

func (a *Performance) WriteToPB(p *pb.Performance)

type SideType

type SideType uint8
const (
	NodeSide SideType = (iota + 1) << 3
	HypervisorSide
	GatewayHypervisorSide
	GatewaySide
	ProcessSide
	AppSide
)

type TAPSideEnum

type TAPSideEnum uint8

func (TAPSideEnum) String

func (s TAPSideEnum) String() string

type TAPTypeEnum

type TAPTypeEnum uint8

TAP: Traffic Access Point

Indicates the flow data collection location. Currently supports 255 acquisition locations. The traffic in cloud is uniformly represented by a special value `3`, and the other values represent the traffic collected from optical splitting and mirroring at different locations in the IDC.

Note: For historical reasons, we use the confusing term VTAP to refer to observatrace-agent, and vtap_id to represent the id of a observatrace-agent.

const (
	IDC_MIN TAPTypeEnum = 1 // 1~2, 4~255: IDC
	CLOUD   TAPTypeEnum = 3
)

type Tag

type Tag struct {
	*Field
	Code
	// contains filtered or unexported fields
}

func AcquireTag

func AcquireTag() *Tag

func CloneTag

func CloneTag(tag *Tag) *Tag

CloneTag 需要复制Tag拥有的Field

func (*Tag) Clone

func (t *Tag) Clone() Tagger

func (*Tag) DatabaseSuffix

func (t *Tag) DatabaseSuffix() string

func (*Tag) DatabaseSuffixID

func (t *Tag) DatabaseSuffixID() int

func (*Tag) GetCode

func (t *Tag) GetCode() uint64

func (*Tag) GetTAPType

func (t *Tag) GetTAPType() uint8

func (*Tag) MarshalTo

func (t *Tag) MarshalTo(b []byte) int

注意: 必须要按tag字段的字典顺序进行处理

func (*Tag) ReadFromPB

func (t *Tag) ReadFromPB(p *pb.MiniTag)

func (*Tag) Release

func (t *Tag) Release()

func (*Tag) SetCode

func (t *Tag) SetCode(code uint64)

func (*Tag) SetID

func (t *Tag) SetID(id string)

func (*Tag) SetTID

func (t *Tag) SetTID(tid uint8)

func (*Tag) String

func (t *Tag) String() string

func (*Tag) TableID

func (t *Tag) TableID(isSecond bool) (uint8, error)

func (*Tag) ToKVString

func (t *Tag) ToKVString() string

func (*Tag) WriteBlock

func (t *Tag) WriteBlock(block *ckdb.Block, time uint32)

顺序需要和GenTagColumns的一致

type TagSource

type TagSource uint8
const (
	GpId  TagSource = 1 << iota // if the GpId exists but the podId does not exist, first obtain the podId through the GprocessId table delivered by the Controller
	PodId                       // use vtapId + podId to match first
	Mac                         // if vtapId + podId cannot be matched, finally use Mac/EpcIP to match resources
	EpcIP
	Peer           // Multicast, filled with peer information
	None TagSource = 0
)

type Tagger

type Tagger interface {
	SetID(string)
	GetCode() uint64
	SetCode(uint64)
	GetTAPType() uint8
	ToKVString() string
	MarshalTo([]byte) int
	String() string
	Clone() Tagger
	Release()
}

type Traffic

type Traffic struct {
	PacketTx   uint64 `db:"packet_tx"`
	PacketRx   uint64 `db:"packet_rx"`
	ByteTx     uint64 `db:"byte_tx"`
	ByteRx     uint64 `db:"byte_rx"`
	L3ByteTx   uint64 `db:"l3_byte_tx"`
	L3ByteRx   uint64 `db:"l3_byte_rx"`
	L4ByteTx   uint64 `db:"l4_byte_tx"`
	L4ByteRx   uint64 `db:"l4_byte_rx"`
	NewFlow    uint64 `db:"new_flow"`
	ClosedFlow uint64 `db:"closed_flow"`

	L7Request   uint32 `db:"l7_request"`
	L7Response  uint32 `db:"l7_response"`
	SynCount    uint32 `db:"syn_count"`
	SynackCount uint32 `db:"synack_count"`

	DirectionScore uint8 `db:"direction_score"`
}

func (*Traffic) ConcurrentMerge

func (t *Traffic) ConcurrentMerge(other *Traffic)

func (*Traffic) MarshalTo

func (t *Traffic) MarshalTo(b []byte) int

func (*Traffic) ReadFromPB

func (t *Traffic) ReadFromPB(p *pb.Traffic)

func (*Traffic) Reverse

func (t *Traffic) Reverse()

func (*Traffic) SequentialMerge

func (t *Traffic) SequentialMerge(other *Traffic)

func (*Traffic) WriteBlock

func (t *Traffic) WriteBlock(block *ckdb.Block)

WriteBlock的列需和Columns 按顺序一一对应

func (*Traffic) WriteToPB

func (t *Traffic) WriteToPB(p *pb.Traffic)

type UniversalTag

type UniversalTag struct {
	IP6            net.IP // FIXME: merge IP6 and IP
	IP             uint32
	L3EpcID        int32 // (8B)
	L3DeviceID     uint32
	RegionID       uint16
	SubnetID       uint16
	HostID         uint16
	AZID           uint16
	PodClusterID   uint16
	PodNSID        uint16
	PodID          uint32
	PodNodeID      uint32
	PodGroupID     uint32
	ServiceID      uint32
	AutoInstanceID uint32
	AutoServiceID  uint32
	GPID           uint32

	IsIPv6           uint8
	L3DeviceType     DeviceType
	AutoInstanceType uint8
	AutoServiceType  uint8

	VTAPID uint16
}

func (*UniversalTag) WriteBlock

func (t *UniversalTag) WriteBlock(block *ckdb.Block)

Note: The order of Write() must be consistent with the order of append() in GenUniversalTagColumns. Currently all fields are sorted lexicographically by name.

type UsageMeter

type UsageMeter struct {
	PacketTx uint64 `db:"packet_tx"`
	PacketRx uint64 `db:"packet_rx"`
	ByteTx   uint64 `db:"byte_tx"`
	ByteRx   uint64 `db:"byte_rx"`
	L3ByteTx uint64 `db:"l3_byte_tx"`
	L3ByteRx uint64 `db:"l3_byte_rx"`
	L4ByteTx uint64 `db:"l4_byte_tx"`
	L4ByteRx uint64 `db:"l4_byte_rx"`
}

func (*UsageMeter) ConcurrentMerge

func (m *UsageMeter) ConcurrentMerge(other Meter)

func (*UsageMeter) ID

func (m *UsageMeter) ID() uint8

func (*UsageMeter) MarshalTo

func (m *UsageMeter) MarshalTo(b []byte) int

func (*UsageMeter) Merge

func (m *UsageMeter) Merge(other *UsageMeter)

func (*UsageMeter) Name

func (m *UsageMeter) Name() string

func (*UsageMeter) ReadFromPB

func (m *UsageMeter) ReadFromPB(p *pb.UsageMeter)

func (*UsageMeter) Reverse

func (m *UsageMeter) Reverse()

func (*UsageMeter) SequentialMerge

func (m *UsageMeter) SequentialMerge(other Meter)

func (*UsageMeter) SortKey

func (m *UsageMeter) SortKey() uint64

func (*UsageMeter) ToKVString

func (m *UsageMeter) ToKVString() string

func (*UsageMeter) VTAPName

func (m *UsageMeter) VTAPName() string

func (*UsageMeter) WriteBlock

func (m *UsageMeter) WriteBlock(block *ckdb.Block)

WriteBlock需要和Colums的列一一对应

func (*UsageMeter) WriteToPB

func (m *UsageMeter) WriteToPB(p *pb.UsageMeter)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL