From 1e7b74818ae259436bbf801d50b824b8f94cf34e Mon Sep 17 00:00:00 2001 From: huanggze Date: Sat, 12 Oct 2019 17:30:18 +0800 Subject: [PATCH] remove log highlighting Signed-off-by: huanggze --- pkg/api/logging/v1alpha2/types.go | 60 +++++---------------- pkg/simple/client/elasticsearch/esclient.go | 9 ---- 2 files changed, 13 insertions(+), 56 deletions(-) diff --git a/pkg/api/logging/v1alpha2/types.go b/pkg/api/logging/v1alpha2/types.go index 59e5cdfd..fb5fc655 100644 --- a/pkg/api/logging/v1alpha2/types.go +++ b/pkg/api/logging/v1alpha2/types.go @@ -48,12 +48,11 @@ type QueryParameters struct { // elasticsearch request body type Request struct { - From int64 `json:"from"` - Size int64 `json:"size"` - Sorts []Sort `json:"sort,omitempty"` - MainQuery BoolQuery `json:"query"` - Aggs interface{} `json:"aggs,omitempty"` - MainHighLight MainHighLight `json:"highlight,omitempty"` + From int64 `json:"from"` + Size int64 `json:"size"` + Sorts []Sort `json:"sort,omitempty"` + MainQuery BoolQuery `json:"query"` + Aggs interface{} `json:"aggs,omitempty"` } type Sort struct { @@ -104,30 +103,6 @@ type RegexpQuery struct { Regexp interface{} `json:"regexp"` } -type MainHighLight struct { - Fields []interface{} `json:"fields,omitempty"` - FragmentSize int `json:"fragment_size"` -} - -type LogHighLightField struct { - FieldContent EmptyField `json:"log"` -} - -type NamespaceHighLightField struct { - FieldContent EmptyField `json:"kubernetes.namespace_name.keyword"` -} - -type PodHighLightField struct { - FieldContent EmptyField `json:"kubernetes.pod_name.keyword"` -} - -type ContainerHighLightField struct { - FieldContent EmptyField `json:"kubernetes.container_name.keyword"` -} - -type EmptyField struct { -} - // StatisticsAggs, the struct for `aggs` of type Request, holds a cardinality aggregation for distinct container counting type StatisticsAggs struct { ContainerAgg ContainerAgg `json:"containers"` @@ -177,9 +152,8 @@ type Hits struct { } type Hit struct { - Source Source `json:"_source"` - HighLight HighLight `json:"highlight"` - Sort []int64 `json:"sort"` + Source Source `json:"_source"` + Sort []int64 `json:"sort"` } type Source struct { @@ -195,21 +169,13 @@ type Kubernetes struct { Host string `json:"host"` } -type HighLight struct { - LogHighLights []string `json:"log,omitempty" description:"log messages to highlight"` - NamespaceHighLights []string `json:"kubernetes.namespace_name.keyword,omitempty" description:"namespaces to highlight"` - PodHighLights []string `json:"kubernetes.pod_name.keyword,omitempty" description:"pods to highlight"` - ContainerHighLights []string `json:"kubernetes.container_name.keyword,omitempty" description:"containers to highlight"` -} - type LogRecord struct { - Time string `json:"time,omitempty" description:"log timestamp"` - Log string `json:"log,omitempty" description:"log message"` - Namespace string `json:"namespace,omitempty" description:"namespace"` - Pod string `json:"pod,omitempty" description:"pod name"` - Container string `json:"container,omitempty" description:"container name"` - Host string `json:"host,omitempty" description:"node id"` - HighLight HighLight `json:"highlight,omitempty" description:"highlighted log fragment"` + Time string `json:"time,omitempty" description:"log timestamp"` + Log string `json:"log,omitempty" description:"log message"` + Namespace string `json:"namespace,omitempty" description:"namespace"` + Pod string `json:"pod,omitempty" description:"pod name"` + Container string `json:"container,omitempty" description:"container name"` + Host string `json:"host,omitempty" description:"node id"` } type ReadResult struct { diff --git a/pkg/simple/client/elasticsearch/esclient.go b/pkg/simple/client/elasticsearch/esclient.go index 9ff1663c..7ed03aae 100644 --- a/pkg/simple/client/elasticsearch/esclient.go +++ b/pkg/simple/client/elasticsearch/esclient.go @@ -209,14 +209,6 @@ func createQueryRequest(param v1alpha2.QueryParameters) ([]byte, error) { order = "desc" } request.Sorts = append(request.Sorts, v1alpha2.Sort{Order: v1alpha2.Order{Order: order}}) - - var mainHighLight v1alpha2.MainHighLight - mainHighLight.Fields = append(mainHighLight.Fields, v1alpha2.LogHighLightField{}) - mainHighLight.Fields = append(mainHighLight.Fields, v1alpha2.NamespaceHighLightField{}) - mainHighLight.Fields = append(mainHighLight.Fields, v1alpha2.PodHighLightField{}) - mainHighLight.Fields = append(mainHighLight.Fields, v1alpha2.ContainerHighLightField{}) - mainHighLight.FragmentSize = 0 - request.MainHighLight = mainHighLight } request.MainQuery = v1alpha2.BoolQuery{Bool: mainBoolQuery} @@ -303,7 +295,6 @@ func (c *ElasticSearchClient) parseQueryResult(operation int, body []byte) (*v1a logRecord.Pod = hit.Source.Kubernetes.Pod logRecord.Container = hit.Source.Kubernetes.Container logRecord.Host = hit.Source.Kubernetes.Host - logRecord.HighLight = hit.HighLight readResult.Records = append(readResult.Records, logRecord) } queryResult.Read = &readResult -- GitLab