query

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Example (MergeLogSearch)
limit := 10
results := []*LogQueryResponse{
	{
		Total: 11,
		Data: []*LogItem{
			{
				Source: &Log{
					Log: &logs.Log{
						Content:   "1",
						Timestamp: 1,
					},
				},
			},
			{
				Source: &Log{
					Log: &logs.Log{
						Content:   "3",
						Timestamp: 3,
						Offset:    1,
					},
				},
			},
			{
				Source: &Log{
					Log: &logs.Log{
						Content:   "3",
						Timestamp: 3,
						Offset:    2,
					},
				},
			},
			{
				Source: &Log{
					Log: &logs.Log{
						Content:   "5",
						Timestamp: 5,
						Offset:    1,
					},
				},
			},
			{
				Source: &Log{
					Log: &logs.Log{
						Content:   "5",
						Timestamp: 5,
						Offset:    2,
					},
				},
			},
			{
				Source: &Log{
					Log: &logs.Log{
						Content:   "6",
						Timestamp: 6,
					},
				},
			},
			{
				Source: &Log{
					Log: &logs.Log{
						Content:   "7",
						Timestamp: 7,
					},
				},
			},
			{
				Source: &Log{
					Log: &logs.Log{
						Content:   "8",
						Timestamp: 8,
					},
				},
			},
			{},
			{
				Source: &Log{
					Log: &logs.Log{
						Content:   "10",
						Timestamp: 10,
					},
				},
			},
			{
				Source: &Log{
					Log: &logs.Log{
						Content:   "11",
						Timestamp: 11,
					},
				},
			},
		},
	},
	{
		Total: 2,
		Data: []*LogItem{
			{
				Source: &Log{
					Log: &logs.Log{
						Content:   "2",
						Timestamp: 2,
					},
				},
			},
			{
				Source: &Log{
					Log: &logs.Log{
						Content:   "3",
						Timestamp: 3,
						Offset:    3,
					},
				},
			},
		},
	},
}
result := mergeLogSearch(limit, results)
fmt.Println(jsonx.MarshalAndIndent(result), len(result.Data))
Output:

Index

Examples

Constants

View Source
const (
	LogVersion1 = "1.0.0"
	LogVersion2 = "2.0.0"
)

log versions

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayAgg

type ArrayAgg struct {
	UnitType  string    `json:"unitType"`
	Unit      string    `json:"unit"`
	ChartType string    `json:"chartType"`
	AxisIndex int64     `json:"axisIndex"`
	Name      string    `json:"name"`
	Tag       string    `json:"tag"`
	Data      []float64 `json:"data"`
}

ArrayAgg .

type BucketAgg added in v1.3.1

type BucketAgg struct {
	Count int64  `json:"count"`
	Key   string `json:"key"`
}

type CountHistogram

type CountHistogram struct {
	Count ArrayAgg `json:"count"`
}

CountHistogram .

type ESClient

type ESClient struct {
	*elastic.Client
	Cluster    string
	URLs       string
	LogVersion string
	Indices    []string
	Entrys     []*IndexEntry
}

ESClient .

type IndexEntry added in v1.3.0

type IndexEntry struct {
	Index       string
	Name        string
	Time        string
	Num         int64
	MinT        time.Time
	MaxT        time.Time
	MinTS       int64
	MaxTS       int64
	DocsCount   int
	DocsDeleted int
	StoreSize   int64
	Active      bool
}

IndexEntry .

type IndexEntrys added in v1.3.0

type IndexEntrys []*IndexEntry

IndexEntrys .

func (IndexEntrys) Len added in v1.3.0

func (entrys IndexEntrys) Len() int

func (IndexEntrys) Less added in v1.3.0

func (entrys IndexEntrys) Less(i, j int) bool

func (IndexEntrys) Swap added in v1.3.0

func (entrys IndexEntrys) Swap(i, j int)

type Log added in v1.3.2

type Log struct {
	*logs.Log
	DocId          string `json:"_id"`
	TimestampNanos string `json:"timestampNanos"`
}

type LogDownloadRequest added in v1.3.1

type LogDownloadRequest struct {
	LogRequest
	Sort      []string
	Size      int
	MaxReturn int64
}

type LogField added in v1.3.1

type LogField struct {
	FieldName          string `json:"fieldName"`
	SupportAggregation bool   `json:"supportAggregation"`
	Display            bool   `json:"display"`
	AllowEdit          bool   `json:"allowEdit"`
	Group              int    `json:"group"`
}

LogField .

type LogFieldBucket added in v1.3.1

type LogFieldBucket struct {
	Buckets []*BucketAgg `json:"buckets"`
}

type LogFieldsAggregationRequest added in v1.3.1

type LogFieldsAggregationRequest struct {
	LogRequest
	AggFields []string
	TermsSize int
}

type LogFieldsAggregationResponse added in v1.3.1

type LogFieldsAggregationResponse struct {
	Total     int64                      `json:"total"`
	AggFields map[string]*LogFieldBucket `json:"aggFields"`
}

type LogItem added in v1.3.1

type LogItem struct {
	Source    *Log                `json:"source"`
	Highlight map[string][]string `json:"highlight"`
}

type LogQueryResponse

type LogQueryResponse struct {
	Expends map[string]interface{} `json:"expends"`
	Total   int64                  `json:"total"`
	Data    []*LogItem             `json:"data"`
}

LogQueryResponse .

type LogRequest

type LogRequest struct {
	OrgID       int64
	ClusterName string
	Addon       string
	Start       int64
	End         int64
	Filters     []*Tag
	Query       string
	Debug       bool
	Lang        i18n.LanguageCodes
	TimeScale   time.Duration
}

LogRequest .

type LogSearchRequest

type LogSearchRequest struct {
	LogRequest
	Page        int64
	Size        int64
	Sort        []string
	Highlight   bool
	SearchAfter []interface{}
}

LogSearchRequest .

type LogStatisticRequest

type LogStatisticRequest struct {
	LogRequest
	Interval int64
	Points   int64
}

LogStatisticRequest .

type LogStatisticResponse

type LogStatisticResponse struct {
	Expends  map[string]interface{} `json:"expends"`
	Title    string                 `json:"title"`
	Total    int64                  `json:"total"`
	Interval int64                  `json:"interval"`
	Time     []int64                `json:"time"`
	Results  []*LogStatisticResult  `json:"results"`
}

LogStatisticResponse .

type LogStatisticResult

type LogStatisticResult struct {
	Name string            `json:"name"`
	Data []*CountHistogram `json:"data"`
}

LogStatisticResult .

type LogV1

type LogV1 struct {
	Message   string            `json:"message"`
	Offset    int64             `json:"offset"`
	Timestamp string            `json:"@timestamp"`
	Tags      map[string]string `json:"tags"`
}

LogV1 .

func (*LogV1) ToLog

func (l *LogV1) ToLog() *Log

ToLog .

type Tag

type Tag struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Tag .

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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