config

package
v1.6.65 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultExportQueueCount     = 4
	DefaultExportQueueSize      = 100000
	DefaultExportOtlpBatchSize  = 32
	DefaultExportOtherBatchSize = 1024
	SecurityProtocol            = "SASL_SSL"

	CATEGORY_K8S_LABEL = "$k8s.label"
	CATEGORY_TAG       = "$tag"
	CATEGORY_METRICS   = "$metrics"

	TOPIC_PREFIX = "deepflow."
)
View Source
const (
	PERF_EVENT = DataSourceID(flow_metrics.METRICS_TABLE_ID_MAX) + 1 + iota
	L4_FLOW_LOG
	L7_FLOW_LOG

	MAX_DATASOURCE_ID
)
View Source
const (
	ConditionOr  = "or"
	ConditionAnd = "and"
)
View Source
const (
	UNKNOWN_CATEGORY = 0

	// tags
	FLOW_INFO uint64 = 1 << iota
	UNIVERSAL_TAG
	CUSTOM_TAG
	NATIVE_TAG
	NETWORK_LAYER
	TUNNEL_INFO
	TRANSPORT_LAYER
	APPLICATION_LAYER
	SERVICE_INFO
	TRACING_INFO
	CAPTURE_INFO
	EVENT_INFO // perf_event only
	DATA_LINK_LAYER

	// metrics
	L3_THROUGHPUT // network*/l4_flow_log
	L4_THROUGHPUT // network*/l4_flow_log
	TCP_SLOW      // network*/l4_flow_log
	TCP_ERROR     // network*/l4_flow_log
	APPLICATION   // network*/l4_flow_log
	THROUGHPUT    // application*/l7_flow_log
	ERROR         // application*/l7_flow_log
	DELAY         // all network/application/flow_log

	K8S_LABEL
	TAG     = FLOW_INFO | UNIVERSAL_TAG | CUSTOM_TAG | NATIVE_TAG | NETWORK_LAYER | TUNNEL_INFO | TRANSPORT_LAYER | APPLICATION_LAYER | SERVICE_INFO | TRACING_INFO | CAPTURE_INFO | DATA_LINK_LAYER
	METRICS = L3_THROUGHPUT | L4_THROUGHPUT | TCP_SLOW | TCP_ERROR | APPLICATION | THROUGHPUT | ERROR | DELAY
)

Variables

View Source
var DefaultExportCategory = []string{"$service_info", "$tracing_info", "$network_layer", "$flow_info", "$transport_layer", "$application_layer", "$metrics"}

Functions

func CategoryBitsToString

func CategoryBitsToString(bits uint64) string

func FlowLogMessageToDataSourceID

func FlowLogMessageToDataSourceID(messageType datatype.MessageType) uint32

func GetK8sLabelConfigs

func GetK8sLabelConfigs(strs []string) []string

func StringToCategoryBit

func StringToCategoryBit(str string) uint64

func StringsToCategoryBits

func StringsToCategoryBits(strs []string) uint64

func StringsToDataSourceBits

func StringsToDataSourceBits(strs []string) uint32

func TagStringToDataSourceBits

func TagStringToDataSourceBits(s string) uint32

'n|nm|a|am' used to distinguish different datasources under flow metrics.*

Types

type AndConditionHandler

type AndConditionHandler struct {
	// contains filtered or unexported fields
}

func (*AndConditionHandler) Decision

func (a *AndConditionHandler) Decision(val bool) (bool, bool)

func (*AndConditionHandler) Init

func (a *AndConditionHandler) Init()

type ConditionHandler

type ConditionHandler interface {
	Init()
	Decision(bool) (bool, bool)
}

type Config

type Config struct {
	Base      *config.Config
	Exporters []ExporterCfg `yaml:"exporters"`
}

func Load

func Load(base *config.Config, path string) *Config

func (*Config) Validate

func (c *Config) Validate() error

type DataSourceID

type DataSourceID uint32

func ToDataSourceID

func ToDataSourceID(str string) (DataSourceID, error)

func (DataSourceID) IsMap

func (d DataSourceID) IsMap() bool

func (DataSourceID) String

func (d DataSourceID) String() string

func (DataSourceID) TopicString

func (d DataSourceID) TopicString() string

type ExportProtocol

type ExportProtocol uint8
const (
	PROTOCOL_OTLP ExportProtocol = iota
	PROTOCOL_PROMETHEUS
	PROTOCOL_KAFKA

	MAX_PROTOCOL_ID
)

func (ExportProtocol) String

func (p ExportProtocol) String() string

type ExporterCfg

type ExporterCfg struct {
	Protocol        string         `yaml:"protocol"`
	Enabled         bool           `yaml:"enabled"`
	ExportProtocol  ExportProtocol // gen by `Protocol`
	DataSources     []string       `yaml:"data-sources"`
	DataSourceBits  uint32         // gen by `DataSources`
	Endpoints       []string       `yaml:"endpoints"`
	RandomEndpoints []string       // gen by `Endpoints`     `

	QueueCount  int `yaml:"queue-count"`
	QueueSize   int `yaml:"queue-size"`
	BatchSize   int `yaml:"batch-size"`
	FlusTimeout int `yaml:"flush-timeout"`

	ExportEmptyTag                      bool `yaml:"export-empty-tag"`
	ExportEmptyMetricsDisabled          bool `yaml:"export-empty-metrics-disabled"`
	EnumTranslateToNameDisabled         bool `yaml:"enum-translate-to-name-disabled"`
	UniversalTagTranslateToNameDisabled bool `yaml:"universal-tag-translate-to-name-disabled"`

	TagFilterCondition      TagFilterCondition `yaml:"tag-filter-condition"`
	TagFilters              []TagFilter        `yaml:"tag-filters"`
	ExportFields            []string           `yaml:"export-fields"`
	ExportFieldCategoryBits uint64             // gen by `ExportFields`
	ExportFieldNames        []string           // gen by `ExportFields`
	ExportFieldK8s          []string           // gen by `ExportFields`

	ExportFieldStructTags [MAX_DATASOURCE_ID][]StructTags // gen by `ExportFields` and init when exporting item first time
	TagFieltertStructTags [MAX_DATASOURCE_ID][]StructTags // gen by `TagFilters`  and init when exporting item first time

	// private configuration
	ExtraHeaders map[string]string `yaml:"extra-headers"`

	// kafka private configuration
	Sasl  Sasl   `yaml:"sasl"`
	Topic string `yaml:"topic"`
}

ExporterCfg holds configs of different exporters.

func (*ExporterCfg) Validate

func (cfg *ExporterCfg) Validate() error

type ExportersConfig

type ExportersConfig struct {
	Exporters Config `yaml:"ingester"`
}

type OperatorID

type OperatorID uint8
const (
	EQ OperatorID = iota
	NEQ
	IN
	NOT_IN
	WILDCARD_EQ
	WILDCARD_NEQ
	REGEXP_EQ
	REGEXP_NEQ

	INVALID_OPERATOR_ID
)

func (OperatorID) String

func (o OperatorID) String() string

type OrConditionHandler

type OrConditionHandler struct {
	// contains filtered or unexported fields
}

func (*OrConditionHandler) Decision

func (o *OrConditionHandler) Decision(val bool) (bool, bool)

func (*OrConditionHandler) Init

func (o *OrConditionHandler) Init()

type Sasl

type Sasl struct {
	Enabled          bool   `yaml:"enabled"`
	SecurityProtocol string `yaml:"security-protocol"` // only support 'SASL_SSL'
	Mechanism        string `yaml:"sasl-mechanism"`    // only support 'PLAIN'
	Username         string `yaml:"username"`
	Password         string `yaml:"password"`
}

func (*Sasl) Validate

func (s *Sasl) Validate() error

type StructTags

type StructTags struct {
	DataSourceID      uint32            // get from interface DataSource()
	Name              string            // tag: 'json'
	MapName           string            // tag: 'map_json'
	FieldName         string            // field name, get from reflect
	Offset            uintptr           // get from reflect
	Category          string            // tag: 'category'
	CategoryBit       uint64            // gen from tag: 'category'
	SubCategoryBit    uint64            // gen from tag: 'sub'
	ToStringFuncName  string            // tag: 'to_string'
	ToStringFunc      reflect.Value     // gen from 'to_string'
	DataKind          reflect.Kind      // get from reflect
	DataTypeStr       string            // tag: 'data_type'. if 'DataKind' cannot determine the field type, it uses 'DataType' to determine
	DataType          utils.DataType    // gen from 'DataTypeStr'
	EnumFile          string            // tag: 'enumfile': as l7_protocol, from server/querier/db_descriptions/clickhouse/tag/enum/*
	EnumIntMap        map[int]string    // gen from content of `EnumFile`
	EnumStringMap     map[string]string // gen from content of `EnumFile`
	UniversalTagMapID uint8             // gen from universal tags
	Omitempty         bool              // tag: 'omitempty', not support yet
	TagDataSourceStr  string            // tag: 'datasource'
	TagDataSourceBits uint32            // gen from 'TagDatasourceStr'

	// the field has tagFilter, if it is not nil, should caculate filter
	TagFilters []TagFilter // gen from 'ExporterCfg.TagFilters'

	IsExportedField bool // gen from 'ExporterCfg.ExportFields'
}

type TagFilter

type TagFilter struct {
	FieldName   string   `yaml:"field-name"`
	Operator    string   `yaml:"operator"`
	FieldValues []string `yaml:"field-values"`

	FieldFloat64s  []float64
	OperatorId     OperatorID
	RegexpComplied *regexp.Regexp
}

func (*TagFilter) MatchFloatValue

func (t *TagFilter) MatchFloatValue(value float64) bool

func (*TagFilter) MatchStringValue

func (t *TagFilter) MatchStringValue(value string) bool

func (*TagFilter) MatchValue

func (t *TagFilter) MatchValue(value interface{}) bool

func (*TagFilter) Validate

func (t *TagFilter) Validate()

type TagFilterCondition

type TagFilterCondition struct {
	ConditionType string `yaml:"type"`
}

TagFilterCondition 过滤条件配置,使用 map 结构便于后续扩展配置项

func (*TagFilterCondition) NewConditionHandler

func (t *TagFilterCondition) NewConditionHandler() ConditionHandler

func (*TagFilterCondition) Validate

func (t *TagFilterCondition) Validate()

Jump to

Keyboard shortcuts

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