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 ¶
- Constants
- type ArrayAgg
- type BucketAgg
- type CountHistogram
- type ESClient
- type IndexEntry
- type IndexEntrys
- type Log
- type LogDownloadRequest
- type LogField
- type LogFieldBucket
- type LogFieldsAggregationRequest
- type LogFieldsAggregationResponse
- type LogItem
- type LogQueryResponse
- type LogRequest
- type LogSearchRequest
- type LogStatisticRequest
- type LogStatisticResponse
- type LogStatisticResult
- type LogV1
- type LoghubService
- type Tag
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 ESClient ¶
type ESClient struct { *elastic.Client Cluster string URLs string LogVersion string Indices []string Entrys []*IndexEntry }
ESClient .
type IndexEntry ¶
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 ¶
type IndexEntrys []*IndexEntry
IndexEntrys .
func (IndexEntrys) Len ¶
func (entrys IndexEntrys) Len() int
func (IndexEntrys) Less ¶
func (entrys IndexEntrys) Less(i, j int) bool
func (IndexEntrys) Swap ¶
func (entrys IndexEntrys) Swap(i, j int)
type LogDownloadRequest ¶
type LogDownloadRequest struct { LogRequest Sort []string Size int MaxReturn int64 }
type LogField ¶
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 ¶
type LogFieldBucket struct {
Buckets []*BucketAgg `json:"buckets"`
}
type LogFieldsAggregationRequest ¶
type LogFieldsAggregationRequest struct { LogRequest AggFields []string TermsSize int }
type LogFieldsAggregationResponse ¶
type LogFieldsAggregationResponse struct { Total int64 `json:"total"` AggFields map[string]*LogFieldBucket `json:"aggFields"` }
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 .
type LoghubService ¶
type LoghubService interface { SearchLogs(req *LogSearchRequest) (*LogQueryResponse, error) DownloadLogs(req *LogDownloadRequest, callback func(batchLogs []*Log) error) error StatisticLogs(req *LogStatisticRequest) (*LogStatisticResponse, error) AggregateLogFields(req *LogFieldsAggregationRequest) (*LogFieldsAggregationResponse, error) }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.