clickhouse

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: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TAG_FUNCTION_NODE_TYPE                  = "node_type"
	TAG_FUNCTION_ICON_ID                    = "icon_id"
	TAG_FUNCTION_MASK                       = "mask"
	TAG_FUNCTION_TIME                       = "time"
	TAG_FUNCTION_TO_UNIX_TIMESTAMP_64_MICRO = "toUnixTimestamp64Micro"
	TAG_FUNCTION_TO_UNIX_TIMESTAMP          = "toUnixTimestamp"
	TAG_FUNCTION_TO_STRING                  = "toString"
	TAG_FUNCTION_IF                         = "if"
	TAG_FUNCTION_UNIQ                       = "uniq"
	TAG_FUNCTION_ANY                        = "any"
	TAG_FUNCTION_TOPK                       = "topK"
	TAG_FUNCTION_NEW_TAG                    = "newTag"
	TAG_FUNCTION_ENUM                       = "enum"
	TAG_FUNCTION_FAST_FILTER                = "FastFilter"
	TAG_FUNCTION_FAST_TRANS                 = "FastTrans"
	TAG_FUNCTION_COUNT_DISTINCT             = "countDistinct"
)
View Source
const INTERVAL_1D = 86400

Variables

View Source
var DEFAULT_LIMIT = "10000"
View Source
var INVALID_PROMETHEUS_SUBQUERY_CACHE_ENTRY = "-1"
View Source
var TIME_FILL_LIMIT_DEFAULT = 20

Functions

func ColumnNameSwap

func ColumnNameSwap(args []interface{}) func(result *common.Result) error

func ExtractFromWhereAndvisibilityFilter added in v1.6.65

func ExtractFromWhereAndvisibilityFilter(s string) (table string, whereClause string, visibilityFilter string)

extractFromWhere extracts the first string after 'from' and all strings after 'where'.

func FormatInnerTime

func FormatInnerTime(m *view.Model)

func FormatLimit

func FormatLimit(m *view.Model)

func FormatModel

func FormatModel(m *view.Model)

func GetDatabases

func GetDatabases() *common.Result

func GetDefaultAlias

func GetDefaultAlias(name string, args []string) string

func GetMetricIDFilter

func GetMetricIDFilter(e *CHEngine) (view.Node, error)

func GetNotNullFilter

func GetNotNullFilter(name string, e *CHEngine) (view.Node, bool)

func GetPrometheusAllTagTranslator

func GetPrometheusAllTagTranslator(e *CHEngine) (string, string, error)

func GetPrometheusFilter

func GetPrometheusFilter(promTag, table, op, value string, e *CHEngine) (string, error)

func GetPrometheusGroup

func GetPrometheusGroup(name string, e *CHEngine) string

func GetPrometheusNotNullFilter

func GetPrometheusNotNullFilter(name string, e *CHEngine) (view.Node, bool)

func GetPrometheusSingleTagTranslator

func GetPrometheusSingleTagTranslator(tag string, e *CHEngine) (string, string, error)

func GetRemoteReadFilter

func GetRemoteReadFilter(promTag, table, op, value, originFilter string, e *CHEngine) (string, error)

func GetTables

func GetTables(db, where, queryCacheTTL, orgID string, useQueryCache bool, ctx context.Context, DebugInfo *client.DebugInfo) *common.Result

func GetVirtualTableFilter

func GetVirtualTableFilter(db, table string) (view.Node, bool)

func LoadDbDescriptions

func LoadDbDescriptions(dbDescriptions map[string]interface{}) error

func MacTranslate

func MacTranslate(args []interface{}) func(result *common.Result) error

func MatchPattern

func MatchPattern(s string) (int, bool)

func ShowTagTypeMetrics

func ShowTagTypeMetrics(tagDescriptions, result *common.Result, db, table string)

func SimpleExecute

func SimpleExecute(args *common.QuerierParams) (result *common.Result, debug map[string]interface{}, err error)

func TimeFill

func TimeFill(args []interface{}) func(result *common.Result) error

func TransAlertEventNoSuffixFilter

func TransAlertEventNoSuffixFilter(translator, regexpTranslator, op, value string) (filter string)

func TransChostFilter

func TransChostFilter(translator, regexpTranslator, op, value string) (filter string)

service, chost, chost_hostname, chost_ip, router, dhcpgw, redis, rds, lb_listener, natgw, lb, host, host_hostname, host_ip, pod_node, pod_node_hostname, pod_node_ip, pod_group_type

func TransEnvFilter

func TransEnvFilter(translator, regexpTranslator, key, op, value string) (filter string)

k8s.env, os.app

func TransIngressFilter

func TransIngressFilter(translator, regexpTranslator, op, value string) (filter string)

pod_ingress, pod_service, x_request_id, syscall_thread, syscall_coroutine, syscall_cap_seq, syscall_trace_id, tcp_seq

func TransLabelFilter

func TransLabelFilter(translator, regexpTranslator, key, op, value string) (filter string)

k8s.label, k8s.annotation, cloud.tag

func TransTagFilter

func TransTagFilter(whereTag, postAsTag, value, op, db, table, originFilter string, isRemoteRead bool, e *CHEngine) (filter string, err error)

The tag is not in the tagResourceMap

func TransWhereTagFunction

func TransWhereTagFunction(db, table string, name string, args []string) (filter string)

Types

type AggFunction

type AggFunction struct {
	// 指标量内容
	Metrics *metrics.Metrics
	// 解析获得的参数
	Name              string
	Args              []string
	Alias             string
	IsDerivative      bool
	DerivativeArgs    []string
	DerivativeGroupBy []string
}

func (*AggFunction) Format

func (f *AggFunction) Format(m *view.Model)

func (*AggFunction) FormatInnerTag

func (f *AggFunction) FormatInnerTag(m *view.Model) (innerAlias string)

func (*AggFunction) SetAlias

func (f *AggFunction) SetAlias(alias string)

func (*AggFunction) Trans

func (f *AggFunction) Trans(m *view.Model) view.Node

type BinaryFunction

type BinaryFunction struct {
	Name      string
	Functions []Function
	Alias     string
}

func GetBinaryFunc

func GetBinaryFunc(name string, args []Function) (*BinaryFunction, error)

func (*BinaryFunction) Format

func (f *BinaryFunction) Format(m *view.Model)

func (*BinaryFunction) SetAlias

func (f *BinaryFunction) SetAlias(alias string)

func (*BinaryFunction) Trans

func (f *BinaryFunction) Trans(m *view.Model) view.Node

type CHEngine

type CHEngine struct {
	Model              *view.Model
	Statements         []Statement
	DB                 string
	Table              string
	DataSource         string
	AsTagMap           map[string]string
	ColumnSchemas      []*common.ColumnSchema
	View               *view.View
	Context            context.Context
	TargetLabelFilters []TargetLabelFilter
	NoPreWhere         bool
	IsDerivative       bool
	DerivativeGroupBy  []string
	ORGID              string
}

func (*CHEngine) AddGroup

func (e *CHEngine) AddGroup(group string) error

func (*CHEngine) AddTable

func (e *CHEngine) AddTable(table string)

func (*CHEngine) AddTag

func (e *CHEngine) AddTag(tag string, alias string) (string, error)

func (*CHEngine) ExecuteQuery

func (e *CHEngine) ExecuteQuery(args *common.QuerierParams) (*common.Result, map[string]interface{}, error)

func (*CHEngine) Init

func (e *CHEngine) Init()

func (*CHEngine) ParseShowSql

func (e *CHEngine) ParseShowSql(sql string, args *common.QuerierParams, DebugInfo *client.DebugInfo) (*common.Result, []string, bool, error)

func (*CHEngine) ParseSlimitSql

func (e *CHEngine) ParseSlimitSql(sql string, args *common.QuerierParams) (string, map[string]func(*common.Result) error, map[string]*common.ColumnSchema, error)

func (*CHEngine) ParseWithSql

func (e *CHEngine) ParseWithSql(sql string) (string, map[string]func(*common.Result) error, map[string]*common.ColumnSchema, error)

func (*CHEngine) QuerySlimitSql

func (e *CHEngine) QuerySlimitSql(sql string, args *common.QuerierParams) (*common.Result, *client.Debug, error)

func (*CHEngine) QueryWithSql

func (e *CHEngine) QueryWithSql(sql string, args *common.QuerierParams) (*common.Result, *client.Debug, error)

func (*CHEngine) SetLevelFlag

func (e *CHEngine) SetLevelFlag(flag int)

func (*CHEngine) ToSQLString

func (e *CHEngine) ToSQLString() string

原始sql转为clickhouse-sql

func (*CHEngine) TransDerivativeGroupBy

func (e *CHEngine) TransDerivativeGroupBy(groups sqlparser.GroupBy) error

func (*CHEngine) TransFrom

func (e *CHEngine) TransFrom(froms sqlparser.TableExprs) error

func (*CHEngine) TransGroupBy

func (e *CHEngine) TransGroupBy(groups sqlparser.GroupBy) error

func (*CHEngine) TransHaving

func (e *CHEngine) TransHaving(node *sqlparser.Where) error

func (*CHEngine) TransLimit

func (e *CHEngine) TransLimit(limit *sqlparser.Limit) error

func (*CHEngine) TransOrderBy

func (e *CHEngine) TransOrderBy(orders sqlparser.OrderBy) error

func (*CHEngine) TransPrometheusTargetIDFilter

func (e *CHEngine) TransPrometheusTargetIDFilter(expr view.Node) (view.Node, error)

func (*CHEngine) TransSelect

func (e *CHEngine) TransSelect(tags sqlparser.SelectExprs) error

func (*CHEngine) TransWhere

func (e *CHEngine) TransWhere(node *sqlparser.Where) error

type Callback

type Callback struct {
	Args     []interface{}
	Function func([]interface{}) func(*common.Result) error
	Column   string
}

func (*Callback) Format

func (c *Callback) Format(m *view.Model)

type Field

type Field struct {
	Value string
}

func (*Field) Format

func (f *Field) Format(m *view.Model)

func (*Field) SetAlias

func (f *Field) SetAlias(alias string)

func (*Field) Trans

func (f *Field) Trans(m *view.Model) view.Node

type FieldFunction

type FieldFunction interface {
	Function
}

func GetFieldFunc

func GetFieldFunc(name string) (FieldFunction, error)

type Function

type Function interface {
	Statement
	Trans(m *view.Model) view.Node
	SetAlias(alias string)
}

type GroupTag

type GroupTag struct {
	Value    string
	Alias    string
	Withs    []view.Node
	AsTagMap map[string]string
}

func (*GroupTag) Format

func (g *GroupTag) Format(m *view.Model)

type Having

type Having struct {
	Where
}

func (*Having) Format

func (h *Having) Format(m *view.Model)

type PrometheusSubqueryCache

type PrometheusSubqueryCache struct {
	PrometheusSubqueryCache *lru.Cache[common.EntryKey, common.EntryValue]
	Lock                    sync.Mutex
}

func GetPrometheusSubqueryCache

func GetPrometheusSubqueryCache() *PrometheusSubqueryCache

func (*PrometheusSubqueryCache) Add

func (*PrometheusSubqueryCache) Get

func (c *PrometheusSubqueryCache) Get(key common.EntryKey) (value common.EntryValue, ok bool)

type SelectTag

type SelectTag struct {
	Value string
	Alias string
	Flag  int
	Withs []view.Node
}

func (*SelectTag) Format

func (t *SelectTag) Format(m *view.Model)

type Statement

type Statement interface {
	Format(*view.Model)
}

翻译单元,翻译结果写入view.Model

func GetAggFunc

func GetAggFunc(name string, args []string, alias string, derivativeArgs []string, e *CHEngine) (Statement, int, string, error)

func GetDefaultTag

func GetDefaultTag(name string, alias string) Statement

func GetGroup

func GetGroup(name string, e *CHEngine) ([]Statement, error)

func GetMetricsTag

func GetMetricsTag(name string, alias string, e *CHEngine) (Statement, error)

func GetTagFunction

func GetTagFunction(name string, args []string, alias string, e *CHEngine) (Statement, error)

func GetTagTranslator

func GetTagTranslator(name, alias string, e *CHEngine) ([]Statement, string, error)

func GetTopKTrans

func GetTopKTrans(name string, args []string, alias string, e *CHEngine) (Statement, int, string, error)

type Table

type Table struct {
	Value string
}

func (*Table) Format

func (t *Table) Format(m *view.Model)

type TagFunction

type TagFunction struct {
	Name   string
	Args   []string
	Alias  string
	Withs  []view.Node
	Value  string
	DB     string
	Table  string
	Engine *CHEngine
}

func (*TagFunction) Check

func (f *TagFunction) Check() error

func (*TagFunction) Format

func (f *TagFunction) Format(m *view.Model)

func (*TagFunction) SetAlias

func (f *TagFunction) SetAlias(alias string)

func (*TagFunction) Trans

func (f *TagFunction) Trans(m *view.Model) view.Node

type TargetLabelFilter

type TargetLabelFilter struct {
	OriginFilter string
	TransFilter  string
}

type Time

type Time struct {
	Args       []string
	Alias      string
	Withs      []view.Node
	TimeField  string
	Interval   int
	WindowSize int
	Offset     int
	Fill       string
}

func (*Time) Format

func (t *Time) Format(m *view.Model)

func (*Time) Trans

func (t *Time) Trans(m *view.Model) error

type TimeIntervalField

type TimeIntervalField struct {
	FieldFunction
}

func (*TimeIntervalField) Format

func (f *TimeIntervalField) Format(m *view.Model)

func (*TimeIntervalField) SetAlias

func (f *TimeIntervalField) SetAlias(alias string)

func (*TimeIntervalField) Trans

func (f *TimeIntervalField) Trans(m *view.Model) view.Node

type TimeTag

type TimeTag struct {
	Value string
}

func (*TimeTag) Trans

func (t *TimeTag) Trans(expr sqlparser.Expr, w *Where, e *CHEngine) (view.Node, error)

type Where

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

func (*Where) Format

func (w *Where) Format(m *view.Model)

type WhereFunction

type WhereFunction struct {
	Function view.Node
	Value    string
}

func (*WhereFunction) Trans

func (f *WhereFunction) Trans(expr sqlparser.Expr, w *Where, asTagMap map[string]string, db, table string) (view.Node, error)

type WhereStatement

type WhereStatement interface {
	Trans(sqlparser.Expr, *Where, *CHEngine) (view.Node, error)
}

func GetWhere

func GetWhere(name, value string) WhereStatement

type WhereTag

type WhereTag struct {
	Tag   string
	Value string
}

func (*WhereTag) Trans

func (t *WhereTag) Trans(expr sqlparser.Expr, w *Where, e *CHEngine) (view.Node, error)

Directories

Path Synopsis
packet_batch module

Jump to

Keyboard shortcuts

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