model

package
v0.0.0-...-385b71e Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Copyright 2024 CloudDetail SPDX-License-Identifier: Apache-2.0

Copyright 2024 CloudDetail SPDX-License-Identifier: Apache-2.0

Copyright 2024 CloudDetail SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	AlertManagerSource = "alertManager"
	ZabbixSource       = "zabbix"
)
View Source
const (
	DelaySourceAlert    = "delaySource"
	InfrastructureAlert = "infrastructureStatus"
	NetAlert            = "netStatus"
	K8sEventAlert       = "k8sStatus"
	REDMetricsAlert     = "REDStatus"
	LogMetricsAlert     = "logsStatus"
	AppAlert            = "appStatus"
	ContainerAlert      = "containerStaus"

	UndefinedAlert = "undefinedAlert"
)
View Source
const (
	STATUS_NORMAL   = "normal"
	STATUS_WARNING  = "warning"
	STATUS_CRITICAL = "critical"
)
View Source
const (
	ROLE_ADMIN    = "admin"
	ROLE_MANAGER  = "manager"
	ROLE_VIEWER   = "viewer"
	ROLE_ANONYMOS = "anonymous"
)
View Source
const (
	PERMISSION_SUB_TYP_ROLE = "role"
	PERMISSION_SUB_TYP_USER = "user"
	PERMISSION_SUB_TYP_TEAM = "team"

	PERMISSION_TYP_FEATURE = "feature"
	PERMISSION_TYP_DATA    = "data"
)
View Source
const (
	TRANSLATION_EN          = "en"
	TRANSLATION_ZH          = "zh"
	TRANSLATION_TYP_FEATURE = "feature"
	TRANSLATION_TYP_MENU    = "menu"
)
View Source
const (
	MAPPED_TYP_MENU   = "menu"
	MAPPED_TYP_ROUTER = "router"
	MAPPED_TYP_API    = "api"
)
View Source
const (
	DATA_GROUP_SUB_TYP_USER    = "user"
	DATA_GROUP_SUB_TYP_TEAM    = "team"
	DATA_GROUP_SOURCE_DEFAULT  = "default"
	DATASOURCE_TYP_NAMESPACE   = "namespace"
	DATASOURCE_TYP_SERVICE     = "service"
	DATASOURCE_CATEGORY_APM    = "apm"
	DATASOURCE_CATEGORY_NORMAL = "normal"
)
View Source
const (
	GROUP_SERVICE  = "service"
	GROUP_MQ       = "mq"
	GROUP_DB       = "db"
	GROUP_EXTERNAL = "external"
)

Variables

View Source
var NORMAL_ALERT_STATUS = AlertStatus{
	AlertStatusCH: AlertStatusCH{
		InfrastructureStatus: STATUS_NORMAL,
		NetStatus:            STATUS_NORMAL,
		K8sStatus:            STATUS_NORMAL,
		AppStatus:            STATUS_NORMAL,
		ContainerStatus:      STATUS_NORMAL,
	},
	AlertStatusPROM: AlertStatusPROM{
		LogMetricsStatus: STATUS_NORMAL,
	},
}

Functions

func GenUUID

func GenUUID() uuid.UUID

func IsTableExists

func IsTableExists(tableName string) bool

func Pop

func Pop(h []int64) []int64

func Push

func Push(h []int64, x int64) []int64

func TableToType

func TableToType() map[string]string

Types

type AlertDetail

type AlertDetail struct {
	Timestamp    int64  `json:"timestamp"`
	AlertObject  string `json:"alertObject"`
	AlertReason  string `json:"alertReason"`
	AlertMessage string `json:"alertMessage"`
}

type AlertEvent

type AlertEvent struct {
	Source string    `ch:"source" json:"source,omitempty"`
	ID     uuid.UUID `ch:"id" json:"id,omitempty"`
	// fault trigger time
	CreateTime time.Time `ch:"create_time" json:"createTime"`
	// Last time the fault occurred
	UpdateTime time.Time `ch:"update_time" json:"updateTime"`
	// Recovery time (only present at recovery)
	EndTime time.Time `ch:"end_time" json:"endTime"`
	// Failure event reception time (used to record data connection, no business meaning)
	ReceivedTime time.Time     `ch:"received_time" json:"receivedTime"`
	Severity     SeverityLevel `ch:"severity" json:"severity,omitempty"`
	// Fault group information
	Group   string            `ch:"group" json:"group,omitempty"`
	Name    string            `ch:"name" json:"name,omitempty"`
	Detail  string            `ch:"detail" json:"detail,omitempty"`
	Tags    map[string]string `ch:"tags" json:"tags,omitempty"`
	RawTags map[string]string `ch:"raw_tags" json:"raw_tags,omitempty"`
	Status  Status            `ch:"status" json:"status,omitempty"`
}

AlertEvent indicates an event in the alert_event table

func (*AlertEvent) GetContainerTag

func (a *AlertEvent) GetContainerTag() string

func (*AlertEvent) GetDatabaseIP

func (a *AlertEvent) GetDatabaseIP() string

func (*AlertEvent) GetDatabasePort

func (a *AlertEvent) GetDatabasePort() string

func (*AlertEvent) GetDatabaseURL

func (a *AlertEvent) GetDatabaseURL() string

func (*AlertEvent) GetEndpointTag

func (a *AlertEvent) GetEndpointTag() string

func (*AlertEvent) GetInfraNodeTag

func (a *AlertEvent) GetInfraNodeTag() string

func (*AlertEvent) GetK8sNamespaceTag

func (a *AlertEvent) GetK8sNamespaceTag() string

func (*AlertEvent) GetK8sPodTag

func (a *AlertEvent) GetK8sPodTag() string

func (*AlertEvent) GetLevelTag

func (a *AlertEvent) GetLevelTag() string

GetLevelTag 获取级别,当前只有network告警存在

func (*AlertEvent) GetNetDstIPTag

func (a *AlertEvent) GetNetDstIPTag() string

func (*AlertEvent) GetNetSrcIPTag

func (a *AlertEvent) GetNetSrcIPTag() string

func (*AlertEvent) GetNetSrcNodeTag

func (a *AlertEvent) GetNetSrcNodeTag() string

func (*AlertEvent) GetNetSrcPidTag

func (a *AlertEvent) GetNetSrcPidTag() string

func (*AlertEvent) GetNetSrcPodTag

func (a *AlertEvent) GetNetSrcPodTag() string

func (*AlertEvent) GetServiceNameTag

func (a *AlertEvent) GetServiceNameTag() string

func (*AlertEvent) GetTargetObj

func (a *AlertEvent) GetTargetObj() string

type AlertEventCount

type AlertEventCount struct {
	Severity SeverityLevel     `ch:"severity" json:"severity,omitempty"`
	Group    string            `ch:"group" json:"group,omitempty"`
	Tags     map[string]string `ch:"tags" json:"tags,omitempty"`

	Rn         uint64 `ch:"rn" json:"-"`
	AlarmCount uint64 `ch:"alarm_count" json:"alarmCount"`
}

type AlertEventLevelCount

type AlertEventLevelCount map[SeverityLevel]uint64

type AlertEventLevelCountMap

type AlertEventLevelCountMap map[string]AlertEventLevelCount

func (AlertEventLevelCountMap) Add

func (m AlertEventLevelCountMap) Add(key string, level SeverityLevel, eventCount uint64)

type AlertReason

type AlertReason map[string][]AlertDetail

func (AlertReason) Add

func (r AlertReason) Add(key string, detail AlertDetail)

type AlertStatus

type AlertStatus struct {
	AlertStatusCH
	AlertStatusPROM
}

func (*AlertStatus) IsAllNormal

func (s *AlertStatus) IsAllNormal() bool

type AlertStatusCH

type AlertStatusCH struct {
	InfrastructureStatus string `json:"infrastructureStatus"` // infrastructure alarm
	NetStatus            string `json:"netStatus"`            // network alarm
	K8sStatus            string `json:"k8sStatus"`            // K8s status alarm

	AppStatus       string `json:"appStatus"`       // application alarm
	ContainerStatus string `json:"containerStatus"` // container alarm
}

func (*AlertStatusCH) IsAllNormal

func (s *AlertStatusCH) IsAllNormal() bool

type AlertStatusPROM

type AlertStatusPROM struct {
	LogMetricsStatus string `json:"logsStatus"` // log metric alarm
}

func (*AlertStatusPROM) IsAllNormal

func (s *AlertStatusPROM) IsAllNormal() bool

type DataGroupFilter

type DataGroupFilter struct {
	Names          []string
	Name           string
	IDs            []int64
	ID             int64
	DatasourceList []Datasource

	CurrentPage *int
	PageSize    *int
}

DataGroupFilter These fields can not use at the same time.

type Datasource

type Datasource struct {
	Datasource string   `json:"datasource"`       // namespaceName or serviceName
	Type       string   `json:"type,omitempty"`   // namespace or service
	Category   string   `json:"category"`         // normal or apm
	Nested     []string `json:"nested,omitempty"` // Nested datasource (namespace service belongs to or service under namespace)
}

type ErrWithMessage

type ErrWithMessage struct {
	Err  error
	Code string
}

func NewErrWithMessage

func NewErrWithMessage(err error, code string) ErrWithMessage

func (ErrWithMessage) Error

func (e ErrWithMessage) Error() string

type FlameBearer

type FlameBearer struct {
	Names    []string  `json:"names"`
	Levels   [][]int64 `json:"levels"`
	NumTicks int64     `json:"numTicks"`
	MaxSelf  int64     `json:"maxSelf"`
}

func NewFlameGraph

func NewFlameGraph(t *Tree, maxNodes int64) *FlameBearer

type I18nLanguage

type I18nLanguage struct {
	Language string `json:"language" form:"language"` // I18n language
}

type MiddlewareInstance

type MiddlewareInstance struct {
	DatabaseURL  string
	DatabaseIP   string
	DatabasePort string
}

type ModifyTableTTLMap

type ModifyTableTTLMap struct {
	Name          string `json:"name"`
	TTLExpression string `json:"TTLExpression"`
	OriginalDays  *int   `json:"originalDays"`
}

type Pagination

type Pagination struct {
	Total       int64 `json:"total"`       // total number of records
	CurrentPage int   `json:"currentPage"` // current page number
	PageSize    int   `json:"pageSize"`    // number of entries per page
}

type RelatedInstances

type RelatedInstances struct {
	SIs []*ServiceInstance
	MIs []MiddlewareInstance
}

type RoleFilter

type RoleFilter struct {
	Names []string
	Name  string
	IDs   []int
	ID    int
}

RoleFilter These fields can not use at the same time.

type ServiceInstance

type ServiceInstance struct {
	ServiceName string `json:"service"`     // service name
	ContainerId string `json:"containerId"` // container ID
	PodName     string `json:"podName"`     // Pod name
	Namespace   string `json:"-"`
	NodeName    string `json:"nodeName"` // hostname
	Pid         int64  `json:"pid"`      // process number
	NodeIP      string `json:"nodeIp"`
}

func (*ServiceInstance) GetInstanceId

func (instance *ServiceInstance) GetInstanceId() string

func (*ServiceInstance) MatchSvcTags

func (i *ServiceInstance) MatchSvcTags(group string, tags map[string]string) bool

type ServiceInstances

type ServiceInstances struct {
	InstanceMap map[string]*ServiceInstance
}

The ServiceInstances contains all the mappings for the Pod, Container, and VM scenarios. The data without the Pod has been removed.

func NewServiceInstances

func NewServiceInstances() *ServiceInstances

func (*ServiceInstances) AddInstances

func (instances *ServiceInstances) AddInstances(list []*ServiceInstance)

func (*ServiceInstances) GetInstanceIdMap

func (instances *ServiceInstances) GetInstanceIdMap() map[string]*ServiceInstance

find out the non-duplicate instance list from the collected instance information

HACK when two process with the same information except one of them has pid = 1, we always return the instance with pid > 1

func (*ServiceInstances) GetInstanceIds

func (instances *ServiceInstances) GetInstanceIds() []string

func (*ServiceInstances) GetInstances

func (instances *ServiceInstances) GetInstances() []*ServiceInstance

func (*ServiceInstances) GetPodInstances

func (instances *ServiceInstances) GetPodInstances() []string

type SeverityLevel

type SeverityLevel uint8
const (
	SeverityLevelUnknown SeverityLevel = iota
	SeverityLevelInfo
	SeverityLevelWarning
	SeverityLevelError
	SeverityLevelCritical
)

func Str2SeverityLevel

func Str2SeverityLevel(levelText string) SeverityLevel

func (*SeverityLevel) Scan

func (s *SeverityLevel) Scan(src interface{}) error

Scan implements sql.Scanner so SeverityLevel can be read from databases transparently. Currently, database types that map to uint8 and []byte are supported.

type Stack

type Stack[T any] struct {
	// contains filtered or unexported fields
}

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() (res T, ok bool)

func (*Stack[T]) Push

func (s *Stack[T]) Push(v T)

func (*Stack[T]) Slice

func (s *Stack[T]) Slice() []T

type Status

type Status int8

Status defines the status of the event

const (
	StatusResolved Status = iota
	StatusFiring
)

func (*Status) Scan

func (s *Status) Scan(src interface{}) error

type Table

type Table struct {
	Name string
}

func GetAllTables

func GetAllTables() []Table

func GetTables

func GetTables(typ string) []Table

func (Table) TableName

func (t Table) TableName() string

type TableType

type TableType struct {
	Typ    string
	Tables []Table
}

type TablesQuery

type TablesQuery struct {
	Name             string `ch:"name" json:"name"`
	CreateTableQuery string `ch:"create_table_query" json:"createTableQuery"`
}

type TeamFilter

type TeamFilter struct {
	ID   int64
	IDs  []int64
	Name string
}

type ToplogyRelation

type ToplogyRelation struct {
	ParentService  string `json:"parentService"`
	ParentEndpoint string `json:"parentEndpoint"`
	Service        string `json:"service"`
	Endpoint       string `json:"endpoint"`
	IsTraced       bool   `json:"isTraced"`
	Group          string `json:"group"`
	System         string `json:"system"`
}

func NewServerRelation

func NewServerRelation(parentService, parentEndPoint, service, endpoint string, isTraced bool) *ToplogyRelation

type TopologyNode

type TopologyNode struct {
	Service  string `json:"service"`
	Endpoint string `json:"endpoint"`
	IsTraced bool   `json:"isTraced"`
	Group    string `json:"group"`
	System   string `json:"system"`
}

func NewServerNode

func NewServerNode(service string, url string, isTraced bool) *TopologyNode

type TopologyNodes

type TopologyNodes struct {
	Nodes map[string]*TopologyNode
}

func NewTopologyNodes

func NewTopologyNodes() *TopologyNodes

func (*TopologyNodes) AddServerNode

func (nodes *TopologyNodes) AddServerNode(key string, service string, url string, isTraced bool)

func (*TopologyNodes) AddTopologyNode

func (nodes *TopologyNodes) AddTopologyNode(key string, service string, url string, isTraced bool, group string, system string)

func (*TopologyNodes) GetLabels

func (nodes *TopologyNodes) GetLabels(group string) ([]string, []string, []string)

func (*TopologyNodes) GetNodes

func (nodes *TopologyNodes) GetNodes() []*TopologyNode

type Tree

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

func (*Tree) InsertStack

func (t *Tree) InsertStack(v int64, stack ...string)

func (*Tree) MergeFlameGraph

func (t *Tree) MergeFlameGraph(src *FlameBearer)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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