@@ -10,35 +10,35 @@ import (
1010 es6 "gopkg.in/olivere/elastic.v6"
1111)
1212
13- func (es * elasticsearch ) getRawLogsES6 (ctx context.Context , logsConfig logsConfig ) ([]byte , error ) {
13+ func (es * elasticsearch ) getRawLogsES6 (ctx context.Context , logsFilter logsFilter ) ([]byte , error ) {
1414 duration := es6 .NewRangeQuery ("timestamp" ).
15- From (logsConfig .StartDate ).
16- To (logsConfig .EndDate )
15+ From (logsFilter .StartDate ).
16+ To (logsFilter .EndDate )
1717
1818 query := es6 .NewBoolQuery ().Filter (duration )
1919 // apply category filter
20- if logsConfig .Filter == "search" {
20+ if logsFilter .Filter == "search" {
2121 filters := es6 .NewTermQuery ("category.keyword" , "search" )
2222 query .Filter (filters )
23- } else if logsConfig .Filter == "delete" {
23+ } else if logsFilter .Filter == "delete" {
2424 filters := es6 .NewMatchQuery ("request.method.keyword" , "DELETE" )
2525 query .Filter (filters )
26- } else if logsConfig .Filter == "success" {
26+ } else if logsFilter .Filter == "success" {
2727 filters := es6 .NewRangeQuery ("response.code" ).Gte (200 ).Lte (299 )
2828 query .Filter (filters )
29- } else if logsConfig .Filter == "error" {
29+ } else if logsFilter .Filter == "error" {
3030 filters := es6 .NewRangeQuery ("response.code" ).Gte (400 )
3131 query .Filter (filters )
3232 } else {
3333 query .Filter (es6 .NewMatchAllQuery ())
3434 }
3535 // apply index filtering logic
36- util .GetIndexFilterQueryEs6 (query , logsConfig .Filter )
36+ util .GetIndexFilterQueryEs6 (query , logsFilter .Filter )
3737
3838 response , err := util .GetClient6 ().Search (es .indexName ).
3939 Query (query ).
40- From (logsConfig .Offset ).
41- Size (logsConfig .Size ).
40+ From (logsFilter .Offset ).
41+ Size (logsFilter .Size ).
4242 SortWithInfo (es6.SortInfo {Field : "timestamp" , UnmappedType : "date" , Ascending : false }).
4343 Do (ctx )
4444 if err != nil {
@@ -54,17 +54,17 @@ func (es *elasticsearch) getRawLogsES6(ctx context.Context, logsConfig logsConfi
5454 }
5555 rawIndices , ok := source ["indices" ]
5656 if ! ok {
57- log .Println (logTag , ": unable to find " , logsConfig .Indices , " in log record" )
57+ log .Println (logTag , ": unable to find " , logsFilter .Indices , " in log record" )
5858 }
5959 logIndices , err := util .ToStringSlice (rawIndices )
6060 if err != nil {
6161 log .Errorln (logTag , ":" , err )
6262 continue
6363 }
6464
65- if len (logsConfig .Indices ) == 0 {
65+ if len (logsFilter .Indices ) == 0 {
6666 hits = append (hits , hit .Source )
67- } else if util .IsSubset (logsConfig .Indices , logIndices ) {
67+ } else if util .IsSubset (logsFilter .Indices , logIndices ) {
6868 hits = append (hits , hit .Source )
6969 }
7070 }
0 commit comments