Documentation ¶
Index ¶
- Constants
- Variables
- func AppendToBuilder(builder *QueryBuilder, f *request.SpanTraceFilter) error
- func Equals(key string, value string) *whereSQL
- func EqualsIfNotEmpty(key string, value string) *whereSQL
- func GetAlertType(g string) string
- func In(key string, values clickhouse.ArraySet) *whereSQL
- func InGroup(vgs ValueInGroups) *whereSQL
- func MergeWheres(sep MergeSep, whereSQLs ...*whereSQL) *whereSQL
- func NewQueryCondition(st, et int64, timeField, query string) string
- func RnLimit(p *request.PageParam) string
- func ValidCheckAndAdjust(f *request.SpanTraceFilter) bool
- type AlertEventSample
- type AlertGroup
- type AvailableFilters
- type ByLimitBuilder
- func (builder *ByLimitBuilder) GroupBy(keys ...string) *ByLimitBuilder
- func (builder *ByLimitBuilder) Limit(limit int) *ByLimitBuilder
- func (builder *ByLimitBuilder) Offset(offset int) *ByLimitBuilder
- func (builder *ByLimitBuilder) OrderBy(key string, asc bool) *ByLimitBuilder
- func (builder *ByLimitBuilder) String() string
- type ChildNode
- type ChildRelation
- type EntryNode
- type ErrorInstancePropagation
- type FaultLogQuery
- type FaultLogResult
- type FieldBuilder
- type FlameGraphData
- type K8sEvents
- type K8sEventsCount
- type LogContent
- type Logs
- type MergeSep
- type NetSegments
- type PagedAlertEvent
- type ParentNode
- type ProfilingEvent
- type QueryBuilder
- func (builder *QueryBuilder) And(where *whereSQL) *QueryBuilder
- func (builder *QueryBuilder) Between(key string, from interface{}, to interface{}) *QueryBuilder
- func (builder *QueryBuilder) Contains(key string, value any) *QueryBuilder
- func (builder *QueryBuilder) Equals(key string, value interface{}) *QueryBuilder
- func (builder *QueryBuilder) EqualsNotEmpty(key string, value string) *QueryBuilder
- func (builder *QueryBuilder) Exists(key string) *QueryBuilder
- func (builder *QueryBuilder) GreaterThan(key string, value any) *QueryBuilder
- func (builder *QueryBuilder) In(key string, values any) *QueryBuilder
- func (builder *QueryBuilder) InStrings(key string, values []string) *QueryBuilder
- func (builder *QueryBuilder) LessThan(key string, value any) *QueryBuilder
- func (builder *QueryBuilder) Like(key string, values any) *QueryBuilder
- func (builder *QueryBuilder) NotContains(key string, value any) *QueryBuilder
- func (builder *QueryBuilder) NotEquals(key string, value interface{}) *QueryBuilder
- func (builder *QueryBuilder) NotExists(key string) *QueryBuilder
- func (builder *QueryBuilder) NotIn(key string, values any) *QueryBuilder
- func (builder *QueryBuilder) NotLike(key string, values any) *QueryBuilder
- func (builder *QueryBuilder) Statement(where string) *QueryBuilder
- func (builder *QueryBuilder) String() string
- type QueryCount
- type QueryTraceResult
- type Repo
- type ServiceNode
- type Source
- type SpanTraceOptions
- type ValueInGroups
- type WrappedConn
- func (c *WrappedConn) Exec(ctx context.Context, query string, args ...any) error
- func (c *WrappedConn) Ping(ctx context.Context) error
- func (c *WrappedConn) Query(ctx context.Context, query string, args ...any) (driver.Rows, error)
- func (c *WrappedConn) QueryRow(ctx context.Context, query string, args ...any) driver.Row
- func (c *WrappedConn) Select(ctx context.Context, dest any, query string, args ...any) error
Constants ¶
View Source
const ( // SQL_GET_SAMPLE_ALERT_EVENT 按alarm_event的name分组,每组取发生事件最晚的记录,并在返回结果中记录同name的告警次数数量 SQL_GET_SAMPLE_ALERT_EVENT = `` /* 473-byte string literal not displayed */ SQL_GET_GROUP_COUNTS_ALERT_EVENT = `` /* 216-byte string literal not displayed */ // SQL_GET_PAGED_ALERT_EVENT 分页取出所有满足条件的告警事件 SQL_GET_PAGED_ALERT_EVENT = `` /* 275-byte string literal not displayed */ )
View Source
const ( SQL_GET_APP_LOG_SOURCE = `SELECT LogAttributes['_source_'] as LogSource FROM ilogtail_logs %s %s` SQL_GET_APP_LOG = `SELECT toUnixTimestamp64Micro(Timestamp) as ts,Body FROM ilogtail_logs %s %s` )
View Source
const ( SQL_GET_PARENT_NODES = `` /* 409-byte string literal not displayed */ SQL_GET_CHILD_NODES = `` /* 343-byte string literal not displayed */ SQL_GET_DESCENDANT_TOPOLOGY = `` /* 869-byte string literal not displayed */ SQL_GET_ENTRY_NODES = ` SELECT entry_service, entry_url FROM service_relationship %s GROUP BY entry_service, entry_url ` )
View Source
const ( TEMPLATE_COUNT_SPAN_TRACE = "SELECT count(1) as total FROM span_trace %s" TEMPLATE_QUERY_SPAN_TRACE = "SELECT %s FROM span_trace %s %s" SQL_GET_LABEL_FILTER_KEYS = `` /* 135-byte string literal not displayed */ SQL_GET_FLAGS_FILTER_KEYS = `` /* 131-byte string literal not displayed */ SQL_GET_FILTER_VALUES = `SELECT DISTINCT %s as label_value FROM span_trace st %s %s` )
View Source
const (
SQL_GET_INSTANCE_ERROR_PROPAGATION = `` /* 2325-byte string literal not displayed */
)
View Source
const ( // SQL_GET_K8S_EVENTS 获取K8s事件告警 SQL_GET_K8S_EVENTS = `` /* 339-byte string literal not displayed */ )
Variables ¶
View Source
var ( ALWAYS_TRUE = &whereSQL{ Wheres: "TRUE", } ALWAYS_FALSE = &whereSQL{ Wheres: "FALSE", } )
Functions ¶
func AppendToBuilder ¶
func AppendToBuilder(builder *QueryBuilder, f *request.SpanTraceFilter) error
func EqualsIfNotEmpty ¶
EqualsIfNotEmpty value长度为0时,返回always true
func GetAlertType ¶
func InGroup ¶
func InGroup(vgs ValueInGroups) *whereSQL
func MergeWheres ¶
func MergeWheres(sep MergeSep, whereSQLs ...*whereSQL) *whereSQL
MergeWheres 合并多个条件
func NewQueryCondition ¶
func ValidCheckAndAdjust ¶
func ValidCheckAndAdjust(f *request.SpanTraceFilter) bool
Types ¶
type AlertEventSample ¶
type AlertEventSample struct { model.AlertEvent // 记录行号 Rn uint64 `ch:"rn" json:"-"` AlarmCount uint64 `ch:"alarm_count" json:"alarmCount"` AlertKey string `ch:"alert_key" json:"alertKey"` }
type AlertGroup ¶
type AlertGroup string
const ( APP_GROUP AlertGroup = "app" NETWORK_GROUP AlertGroup = "network" CONTAINER_GROUP AlertGroup = "container" INFRA_GROUP AlertGroup = "infra" )
func (AlertGroup) GetAlertType ¶
func (g AlertGroup) GetAlertType() string
type AvailableFilters ¶
type AvailableFilters struct { Filters []request.SpanTraceFilter FilterUpdateTime time.Time }
type ByLimitBuilder ¶
type ByLimitBuilder struct {
// contains filtered or unexported fields
}
func NewByLimitBuilder ¶
func NewByLimitBuilder() *ByLimitBuilder
func (*ByLimitBuilder) GroupBy ¶
func (builder *ByLimitBuilder) GroupBy(keys ...string) *ByLimitBuilder
func (*ByLimitBuilder) Limit ¶
func (builder *ByLimitBuilder) Limit(limit int) *ByLimitBuilder
func (*ByLimitBuilder) Offset ¶
func (builder *ByLimitBuilder) Offset(offset int) *ByLimitBuilder
func (*ByLimitBuilder) OrderBy ¶
func (builder *ByLimitBuilder) OrderBy(key string, asc bool) *ByLimitBuilder
func (*ByLimitBuilder) String ¶
func (builder *ByLimitBuilder) String() string
返回GroupBy、OrderBy和Limit
type ChildRelation ¶
type ChildRelation struct { ParentService string `ch:"parentService"` ParentUrl string `ch:"parentUrl"` Service string `ch:"service"` Url string `ch:"url"` IsTraced bool `ch:"traced"` ClientGroup string `ch:"clientGroup"` ClientType string `ch:"clientType"` ClientPeer string `ch:"clientPeer"` ClientKey string `ch:"clientKey"` }
type ErrorInstancePropagation ¶
type ErrorInstancePropagation struct { Timestamp time.Time `ch:"timestamp"` Service string `ch:"service"` InstanceId string `ch:"instance_id"` TraceId string `ch:"trace_id"` ErrorTypes []string `ch:"error_types"` ErrorMsgs []string `ch:"error_msgs"` ParentServices []string `ch:"parent_services"` ParentInstances []string `ch:"parent_instances"` ParentTraced []bool `ch:"parent_traced"` ChildServices []string `ch:"child_services"` ChildInstances []string `ch:"child_instances"` ChildTraced []bool `ch:"child_traced"` }
type FaultLogQuery ¶
type FaultLogQuery struct { StartTime int64 EndTime int64 Service string Instance string NodeName string ContainerId string Pid uint32 EndPoint string TraceId string PageNum int PageSize int Type int // 0 - slow & error, 1 - error MultiServices []string // 匹配多个service MultiNamespace []string // 匹配多个namespace }
type FaultLogResult ¶
type FaultLogResult struct { ServiceName string `ch:"service_name" json:"serviceName"` InstanceId string `ch:"instance_id" json:"instanceId"` TraceId string `ch:"trace_id" json:"traceId"` StartTime uint64 `ch:"start_time_us" json:"startTime"` EndTime uint64 `ch:"end_time_us" json:"endTime"` EndPoint string `ch:"endpoint" json:"endpoint"` PodName string `ch:"pod_name" json:"podName"` ContainerId string `ch:"container_id" json:"containerId"` NodeName string `ch:"node_name" json:"nodeName"` Pid uint32 `ch:"pid" json:"pid"` }
type FieldBuilder ¶
type FieldBuilder struct {
// contains filtered or unexported fields
}
func NewFieldBuilder ¶
func NewFieldBuilder() *FieldBuilder
func (*FieldBuilder) Alias ¶
func (builder *FieldBuilder) Alias(key string, alias string) *FieldBuilder
func (*FieldBuilder) Fields ¶
func (builder *FieldBuilder) Fields(keys ...string) *FieldBuilder
type FlameGraphData ¶
type FlameGraphData struct { StartTime int64 `ch:"start_time" json:"startTime"` EndTime int64 `ch:"end_time" json:"endTime"` PID uint32 `ch:"pid" json:"pid"` TID uint32 `ch:"tid" json:"tid"` SampleType string `ch:"sample_type" json:"sampleType"` SampleRate uint32 `ch:"sample_rate" json:"sampleRate"` Labels map[string]string `ch:"labels" json:"labels"` FlameBearer string `ch:"flamebearer" json:"flameBearer"` }
type K8sEvents ¶
type K8sEvents struct { Timestamp time.Time `ch:"Timestamp" json:"timestamp"` SeverityText string `ch:"SeverityText" json:"SeverityText"` Body string `ch:"Body" json:"body"` ResourceAttributes map[string]string `ch:"ResourceAttributes" json:"resourceAttributes"` LogAttributes map[string]string `ch:"LogAttributes" json:"logAttributes"` }
func (*K8sEvents) GetObjKind ¶
func (*K8sEvents) GetObjName ¶
type K8sEventsCount ¶
type LogContent ¶
type Logs ¶
type Logs struct { Source string `json:"source"` Contents []LogContent `json:"contents"` }
type NetSegments ¶
type PagedAlertEvent ¶
type PagedAlertEvent struct { model.AlertEvent // 记录行号 Rn uint64 `ch:"rn" json:"-"` TotalCount uint64 `ch:"total_count" json:"-"` }
type ParentNode ¶
type ProfilingEvent ¶
type ProfilingEvent struct { Timestamp time.Time `json:"timestamp" ch:"timestamp"` StartTime uint64 `json:"startTime" ch:"startTime"` EndTime uint64 `json:"endTime" ch:"endTime"` Offset int64 `json:"offset" ch:"offset"` PID uint32 `json:"pid" ch:"pid"` TID uint32 `json:"tid" ch:"tid"` TransactionIDs string `json:"transactionIds" ch:"transactionIds"` CPUEvents string `json:"cpuEvents" ch:"cpuEvents"` InnerCalls string `json:"innerCalls" ch:"innerCalls"` JavaFutexEvents string `json:"javaFutexEvents" ch:"javaFutexEvents"` Spans string `json:"spans" ch:"spans"` ThreadName string `json:"threadName" ch:"threadName"` // 线程名 表中在labels中 Labels map[string]string `json:"labels" ch:"labels"` }
type QueryBuilder ¶
type QueryBuilder struct {
// contains filtered or unexported fields
}
func NewQueryBuilder ¶
func NewQueryBuilder() *QueryBuilder
func (*QueryBuilder) And ¶
func (builder *QueryBuilder) And(where *whereSQL) *QueryBuilder
And 将一系列条件whereSQL以And方式加入到QueryBuilder
func (*QueryBuilder) Between ¶
func (builder *QueryBuilder) Between(key string, from interface{}, to interface{}) *QueryBuilder
func (*QueryBuilder) Contains ¶
func (builder *QueryBuilder) Contains(key string, value any) *QueryBuilder
func (*QueryBuilder) Equals ¶
func (builder *QueryBuilder) Equals(key string, value interface{}) *QueryBuilder
func (*QueryBuilder) EqualsNotEmpty ¶
func (builder *QueryBuilder) EqualsNotEmpty(key string, value string) *QueryBuilder
func (*QueryBuilder) Exists ¶
func (builder *QueryBuilder) Exists(key string) *QueryBuilder
func (*QueryBuilder) GreaterThan ¶
func (builder *QueryBuilder) GreaterThan(key string, value any) *QueryBuilder
func (*QueryBuilder) In ¶
func (builder *QueryBuilder) In(key string, values any) *QueryBuilder
组合生成SQL中的 key in (values) 语句, values内部为值数组
func (*QueryBuilder) InStrings ¶
func (builder *QueryBuilder) InStrings(key string, values []string) *QueryBuilder
func (*QueryBuilder) LessThan ¶
func (builder *QueryBuilder) LessThan(key string, value any) *QueryBuilder
func (*QueryBuilder) Like ¶
func (builder *QueryBuilder) Like(key string, values any) *QueryBuilder
func (*QueryBuilder) NotContains ¶
func (builder *QueryBuilder) NotContains(key string, value any) *QueryBuilder
func (*QueryBuilder) NotEquals ¶
func (builder *QueryBuilder) NotEquals(key string, value interface{}) *QueryBuilder
func (*QueryBuilder) NotExists ¶
func (builder *QueryBuilder) NotExists(key string) *QueryBuilder
func (*QueryBuilder) NotIn ¶
func (builder *QueryBuilder) NotIn(key string, values any) *QueryBuilder
func (*QueryBuilder) NotLike ¶
func (builder *QueryBuilder) NotLike(key string, values any) *QueryBuilder
func (*QueryBuilder) Statement ¶
func (builder *QueryBuilder) Statement(where string) *QueryBuilder
type QueryCount ¶
type QueryCount struct {
Total uint64 `ch:"total"`
}
type QueryTraceResult ¶
type QueryTraceResult struct { Timestamp int64 `ch:"ts" json:"timestamp"` Duration uint64 `ch:"duration_us" json:"duration"` ServiceName string `ch:"service_name" json:"serviceName"` Pid uint32 `ch:"pid" json:"pid"` Tid uint32 `ch:"tid" json:"tid"` TraceId string `ch:"trace_id" json:"traceId"` EndPoint string `ch:"endpoint" json:"endpoint"` InstanceId string `ch:"instance_id" json:"instanceId"` SpanId string `ch:"span_id" json:"spanId"` ApmType string `ch:"apm_type" json:"apmType"` Reason string `ch:"reason" json:"reason"` IsError bool `ch:"is_error" json:"isError"` IsSlow bool `ch:"is_slow" json:"isSlow"` ThresholdValue float64 `ch:"threshold_value" json:"thresholdValue"` Labels map[string]string `ch:"labels" json:"labels"` Flags map[string]bool `ch:"flags" json:"flags"` Metrics map[string]uint64 `ch:"metrics" json:"metrics"` MutatedValue uint64 `ch:"mutated_value" json:"mutatedValue"` IsMutated uint8 `ch:"is_mutated" json:"isMutated"` // 延时是否突变 }
type Repo ¶
type Repo interface { // ========== service_relationship ========== // 查询上游节点列表 ListParentNodes(req *request.GetServiceEndpointTopologyRequest) (*model.TopologyNodes, error) // 查询下游节点列表 ListChildNodes(req *request.GetServiceEndpointTopologyRequest) (*model.TopologyNodes, error) // 查询所有子孙服务节点列表 ListDescendantNodes(req *request.GetDescendantMetricsRequest) (*model.TopologyNodes, error) // 查询所有子孙节点的调用关系 ListDescendantRelations(req *request.GetServiceEndpointTopologyRequest) ([]*model.ToplogyRelation, error) // 查询入口节点列表 ListEntryEndpoints(req *request.GetServiceEntryEndpointsRequest) ([]EntryNode, error) // ========== error_propagation ========== // 查询实例相关的错误传播链 ListErrorPropagation(req *request.GetErrorInstanceRequest) ([]ErrorInstancePropagation, error) // ========== span_trace ========== GetAvailableFilterKey(startTime, endTime time.Time, needUpdate bool) ([]request.SpanTraceFilter, error) UpdateFilterKey(startTime, endTime time.Time) ([]request.SpanTraceFilter, error) GetFieldValues(searchText string, filter *request.SpanTraceFilter, startTime, endTime time.Time) (*SpanTraceOptions, error) // 分页查询故障现场日志列表 GetFaultLogPageList(query *FaultLogQuery) ([]FaultLogResult, int64, error) // 分页Trace列表 GetTracePageList(req *request.GetTracePageListRequest) ([]QueryTraceResult, int64, error) CountK8sEvents(startTime int64, endTim int64, pods []string) ([]K8sEventsCount, error) // ========== application_logs ========== // 查询故障现场日志内容, sourceFrom 可为空, 将返回可查到的第一个来源中的日志 QueryApplicationLogs(req *request.GetFaultLogContentRequest) (logContents *Logs, availableSource []string, err error) // 查询故障现场日志内容可用的来源 QueryApplicationLogsAvailableSource(faultLog FaultLogResult) ([]string, error) CreateLogTable(req *request.LogTableRequest) ([]string, error) DropLogTable(req *request.LogTableRequest) ([]string, error) UpdateLogTable(req *request.LogTableRequest, old []request.Field) ([]string, error) QueryAllLogs(req *request.LogQueryRequest) ([]map[string]any, string, error) QueryLogContext(req *request.LogQueryContextRequest) ([]map[string]any, []map[string]any, error) GetLogChart(req *request.LogQueryRequest) ([]map[string]any, int64, error) GetLogIndex(req *request.LogIndexRequest) (map[string]uint64, uint64, error) OtherLogTable() ([]map[string]any, error) OtherLogTableInfo(req *request.OtherTableInfoRequest) ([]map[string]any, error) InsertBatchAlertEvents(ctx context.Context, events []*model.AlertEvent) error ReadAlertEvent(ctx context.Context, id uuid.UUID) (*model.AlertEvent, error) GetConn() driver.Conn //config ModifyTableTTL(ctx context.Context, mapResult []model.ModifyTableTTLMap) error GetTables(tables []model.Table) ([]model.TablesQuery, error) // ========== alert events ========== // 查询按group和级别采样的告警事件,sampleCount为每个group和级别采样的数量 GetAlertEventCountGroupByInstance(startTime time.Time, endTime time.Time, filter request.AlertFilter, instances []*model.ServiceInstance) ([]model.AlertEventCount, error) // 查询按labels采样的告警事件,sampleCount为每个labels采样的数量 GetAlertEventsSample(sampleCount int, startTime time.Time, endTime time.Time, filter request.AlertFilter, instances []*model.ServiceInstance) ([]AlertEventSample, error) // 查询按pageParam分页的告警事件 GetAlertEvents(startTime time.Time, endTime time.Time, filter request.AlertFilter, instances []*model.ServiceInstance, pageParam *request.PageParam) ([]PagedAlertEvent, int, error) // ========== k8s events ============ // SeverityNumber > 9 (warning) GetK8sAlertEventsSample(startTime time.Time, endTime time.Time, instances []*model.ServiceInstance) ([]K8sEvents, error) // profiling_event // GetOnOffCPU 获取span执行消耗 GetOnOffCPU(pid uint32, nodeName string, startTime, endTime int64) (*[]ProfilingEvent, error) // ========== network (deepflow) ========== GetNetworkSpanSegments(traceId string, spanId string) ([]NetSegments, error) // ========== flame graph =========== GetFlameGraphData(startTime, endTime int64, nodeName string, pid, tid int64, sampleType, spanId, traceId string) (*[]FlameGraphData, error) // contains filtered or unexported methods }
type ServiceNode ¶
type SpanTraceOptions ¶
type SpanTraceOptions struct { request.SpanTraceFilter Options any `json:"options"` }
type ValueInGroups ¶
type ValueInGroups struct { Keys []string ValueGroups []clickhouse.GroupSet }
ValueInGroups 用于在OrInGroups中传入多组InGroups参数并做OR连接 每个ValueInGroups生成如下SQL,x是EqualIfNotEmpty中的每个值 (keys) IN (ValueGroups)
Source Files ¶
- alert_event.go
- dao.go
- dao_alert.go
- dao_config.go
- dao_error_propagation.go
- dao_flame_graph.go
- dao_k8s_event.go
- dao_log_chart.go
- dao_log_index.go
- dao_log_table.go
- dao_network_span_segments.go
- dao_other_log_table.go
- dao_profilling_event.go
- dao_query_all_log.go
- dao_query_app_logs.go
- dao_query_log_context.go
- dao_query_rows.go
- dao_service_k8s_events.go
- dao_service_relationship.go
- dao_span_trace.go
- sql_builder.go
- wrapped_driver.go
Click to show internal directories.
Click to hide internal directories.