logsearch

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TaskMaxPreviewLines      = 500
	TaskGroupMaxPreviewLines = 5000
)

Variables

View Source
var MaxRecvMsgSize = math.MaxInt64

MaxRecvMsgSize set max gRPC receive message size received from server. If any message size is larger than current value, an error will be reported from gRPC.

View Source
var ServerTypeMap = map[ServerType]string{
	ServerTypeTiDB: "tidb",
	ServerTypeTiKV: "tikv",
	ServerTypePD:   "pd",
}

Functions

This section is empty.

Types

type CreateTaskGroupRequest

type CreateTaskGroupRequest struct {
	Request       SearchLogRequest `json:"request" binding:"required"`
	SearchTargets []SearchTarget   `json:"search_targets" binding:"required"`
}

type PreviewModel

type PreviewModel struct {
	ID          uint                   `json:"id" grom:"primary_key"`
	TaskID      uint                   `json:"task_id" gorm:"index:task"`
	TaskGroupID uint                   `json:"task_group_id" gorm:"index:task_group"`
	Time        int64                  `json:"time" gorm:"index:task,task_group"`
	Level       diagnosticspb.LogLevel `json:"level" gorm:"type:integer"`
	Message     string                 `json:"message" gorm:"type:text"`
}

func (PreviewModel) TableName

func (PreviewModel) TableName() string

type Scheduler

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

func NewScheduler

func NewScheduler(service *Service) *Scheduler

func (*Scheduler) AsyncAbort

func (s *Scheduler) AsyncAbort(taskGroupID uint) bool

func (*Scheduler) AsyncStart

func (s *Scheduler) AsyncStart(taskGroupModel *TaskGroupModel, tasksModel []*TaskModel) bool

type SearchLogRequest

type SearchLogRequest diagnosticspb.SearchLogRequest

func (*SearchLogRequest) Scan

func (r *SearchLogRequest) Scan(src interface{}) error

func (*SearchLogRequest) Value

func (r *SearchLogRequest) Value() (driver.Value, error)

type SearchTarget

type SearchTarget struct {
	Kind       ServerType `json:"kind" example:"1"`
	IP         string     `json:"ip" gorm:"size:32" example:"127.0.0.1"`
	Port       int        `json:"port" example:"4000"`
	StatusPort int        `json:"status_port" example:"10080"`
}

func (*SearchTarget) Address

func (s *SearchTarget) Address() string

func (*SearchTarget) FileName

func (s *SearchTarget) FileName() string

func (*SearchTarget) GRPCAddress

func (s *SearchTarget) GRPCAddress() string

func (*SearchTarget) ServerName

func (s *SearchTarget) ServerName() string

func (*SearchTarget) String

func (s *SearchTarget) String() string

type ServerType

type ServerType int
const (
	ServerTypeTiDB ServerType = 1
	ServerTypeTiKV ServerType = 2
	ServerTypePD   ServerType = 3
)

type Service

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

func NewService

func NewService(config *config.Config, db *dbstore.DB) *Service

func (*Service) CancelTask

func (s *Service) CancelTask(c *gin.Context)

@Summary Cancel running tasks @Description cancel all running tasks in a task group @Produce json @Param id path string true "task group id" @Security JwtAuth @Success 200 {object} utils.APIEmptyResponse @Failure 401 {object} utils.APIError "Unauthorized failure" @Failure 400 {object} utils.APIError @Router /logs/taskgroups/{id}/cancel [post]

func (*Service) CreateTaskGroup

func (s *Service) CreateTaskGroup(c *gin.Context)

@Summary Create and run task group @Description Create and run task group @Produce json @Param request body CreateTaskGroupRequest true "Request body" @Security JwtAuth @Success 200 {object} TaskGroupResponse @Failure 400 {object} utils.APIError @Failure 401 {object} utils.APIError "Unauthorized failure" @Failure 500 {object} utils.APIError @Router /logs/taskgroup [put]

func (*Service) DeleteTaskGroup

func (s *Service) DeleteTaskGroup(c *gin.Context)

@Summary Delete task group @Description delete a task group by providing task group ID @Produce json @Param id path string true "task group id" @Security JwtAuth @Success 200 {object} utils.APIEmptyResponse @Failure 401 {object} utils.APIError "Unauthorized failure" @Failure 500 {object} utils.APIError @Router /logs/taskgroups/{id} [delete]

func (*Service) DownloadLogs

func (s *Service) DownloadLogs(c *gin.Context)

@Summary Download @Description download logs by multiple task IDs @Produce application/x-tar,application/zip @Param token query string true "download token" @Failure 400 {object} utils.APIError @Failure 401 {object} utils.APIError "Unauthorized failure" @Failure 500 {object} utils.APIError @Router /logs/download [get]

func (*Service) GetAllTaskGroups

func (s *Service) GetAllTaskGroups(c *gin.Context)

@Summary List all task groups @Description list all log search taskgroups @Produce json @Security JwtAuth @Success 200 {array} TaskGroupResponse @Failure 401 {object} utils.APIError "Unauthorized failure" @Failure 500 {object} utils.APIError @Router /logs/taskgroups [get]

func (*Service) GetDownloadToken

func (s *Service) GetDownloadToken(c *gin.Context)

@Summary Get download token @Description get download token with multiple task IDs @Produce plain @Param id query []string false "task id" @Security JwtAuth @Success 200 {string} string "xxx" @Failure 400 {object} utils.APIError @Failure 401 {object} utils.APIError "Unauthorized failure" @Router /logs/download/acquire_token [get]

func (*Service) GetTaskGroup

func (s *Service) GetTaskGroup(c *gin.Context)

@Summary List tasks in a task group @Description list all log search tasks in a task group by providing task group ID @Produce json @Param id path string true "Task Group ID" @Security JwtAuth @Success 200 {object} TaskGroupResponse @Failure 401 {object} utils.APIError "Unauthorized failure" @Failure 500 {object} utils.APIError @Router /logs/taskgroups/{id} [get]

func (*Service) GetTaskGroupPreview

func (s *Service) GetTaskGroupPreview(c *gin.Context)

@Summary Preview logs in a task group @Description preview fetched logs in a task group by providing task group ID @Produce json @Param id path string true "task group id" @Security JwtAuth @Success 200 {array} PreviewModel @Failure 401 {object} utils.APIError "Unauthorized failure" @Failure 500 {object} utils.APIError @Router /logs/taskgroups/{id}/preview [get]

func (*Service) Register

func (s *Service) Register(r *gin.RouterGroup, auth *user.AuthService)

func (*Service) RetryTask

func (s *Service) RetryTask(c *gin.Context)

@Summary Retry failed tasks @Description retry tasks that has been failed in a task group @Produce json @Param id path string true "task group id" @Security JwtAuth @Success 200 {object} utils.APIEmptyResponse @Failure 400 {object} utils.APIError @Failure 401 {object} utils.APIError "Unauthorized failure" @Failure 500 {object} utils.APIError @Router /logs/taskgroups/{id}/retry [post]

type Task

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

func (*Task) Abort

func (t *Task) Abort()

This function is multi-thread safe.

func (*Task) String

func (t *Task) String() string

func (*Task) SyncRun

func (t *Task) SyncRun()

type TaskGroup

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

func (*TaskGroup) AbortAll

func (tg *TaskGroup) AbortAll()

This function is multi-thread safe.

func (*TaskGroup) InitTasks

func (tg *TaskGroup) InitTasks(taskModels []*TaskModel)

func (*TaskGroup) SyncRun

func (tg *TaskGroup) SyncRun()

type TaskGroupModel

type TaskGroupModel struct {
	ID            uint              `json:"id" gorm:"primary_key"`
	SearchRequest *SearchLogRequest `json:"search_request" gorm:"type:text"`
	State         TaskGroupState    `json:"state" gorm:"index"`
	LogStoreDir   *string           `json:"log_store_dir" gorm:"type:text"`
}

func (*TaskGroupModel) Delete

func (tg *TaskGroupModel) Delete(db *dbstore.DB)

func (TaskGroupModel) TableName

func (TaskGroupModel) TableName() string

type TaskGroupResponse

type TaskGroupResponse struct {
	TaskGroup TaskGroupModel `json:"task_group"`
	Tasks     []*TaskModel   `json:"tasks"`
}

type TaskGroupState

type TaskGroupState int
const (
	TaskGroupStateRunning  TaskGroupState = 1
	TaskGroupStateFinished TaskGroupState = 2
)

type TaskModel

type TaskModel struct {
	ID           uint          `json:"id" gorm:"primary_key"`
	TaskGroupID  uint          `json:"task_group_id" gorm:"index"`
	SearchTarget *SearchTarget `json:"search_target" gorm:"embedded;embedded_prefix:search_target_"`
	State        TaskState     `json:"state" gorm:"index"`
	LogStorePath *string       `json:"log_store_path" gorm:"type:text"`
	Error        *string       `json:"error" gorm:"type:text"`
}

func (*TaskModel) RemoveDataAndPreview

func (task *TaskModel) RemoveDataAndPreview(db *dbstore.DB)

Note: this function does not save model itself.

func (TaskModel) TableName

func (TaskModel) TableName() string

type TaskState

type TaskState int
const (
	TaskStateRunning  TaskState = 1
	TaskStateFinished TaskState = 2
	TaskStateError    TaskState = 3
)

Jump to

Keyboard shortcuts

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