Documentation ¶
Index ¶
- Constants
- func GetAutoCompleteData(ctx *fasthttp.RequestCtx, myid uint64)
- func ListIndicesHandler(ctx *fasthttp.RequestCtx, myid uint64)
- func Parse(filename string, b []byte, opts ...Option) (any, error)
- func ParseFile(filename string, opts ...Option) (i any, err error)
- func ParseQuery(searchText string, qid uint64, queryLanguageType string) (*ASTNode, *QueryAggregators, error)
- func ParseReader(filename string, r io.Reader, opts ...Option) (any, error)
- func ParseRequest(searchText string, startEpoch, endEpoch uint64, qid uint64, ...) (*ASTNode, *QueryAggregators, error)
- func ParseSearchBody(jsonSource map[string]interface{}, nowTs uint64) (string, uint64, uint64, uint64, string, int)
- func ProcessAlertsPipeSearchRequest(queryParams alertutils.QueryParams) int
- func ProcessPipeSearchRequest(ctx *fasthttp.RequestCtx, myid uint64)
- func ProcessPipeSearchWebsocket(conn *websocket.Conn, orgid uint64, ctx *fasthttp.RequestCtx)
- func SearchQueryToASTnode(node *ast.Node, boolNode *ASTNode, qid uint64) error
- func SendClusterDetails(ctx *fasthttp.RequestCtx)
- type AggregationResults
- type AllIndicesInfoResponse
- type Cloner
- type ESResponse
- type IndexInfo
- type Option
- func AllowInvalidUTF8(b bool) Option
- func Debug(b bool) Option
- func Entrypoint(ruleName string) Option
- func GlobalStore(key string, value any) Option
- func InitState(key string, value any) Option
- func MaxExpressions(maxExprCnt uint64) Option
- func Memoize(b bool) Option
- func Recover(b bool) Option
- func Statistics(stats *Stats, choiceNoMatch string) Option
- type PipeSearchCompleteResponse
- type PipeSearchResponse
- type PipeSearchResponseOuter
- type PipeSearchWSUpdateResponse
- type Stats
- type Version
Constants ¶
const DAY_IN_MS = 86400_000
const HOUR_IN_MS = 3600_000
const MIN_IN_MS = 60_000
Variables ¶
This section is empty.
Functions ¶
func GetAutoCompleteData ¶
func GetAutoCompleteData(ctx *fasthttp.RequestCtx, myid uint64)
func ListIndicesHandler ¶
func ListIndicesHandler(ctx *fasthttp.RequestCtx, myid uint64)
func ParseQuery ¶
func ParseReader ¶
ParseReader parses the data from r using filename as information in the error messages.
func ParseRequest ¶
func ParseSearchBody ¶
func ParseSearchBody(jsonSource map[string]interface{}, nowTs uint64) (string, uint64, uint64, uint64, string, int)
Example incomingBody
{"searchText":"*","startEpoch":1656716713300,"endEpoch":1656717613300,"indexName":"*", "size": 1000, "from": 0}
Returns searchText,startEpoch,endEpoch,finalSize,indexName,scrollFrom ¶
finalSize = size + from
func ProcessAlertsPipeSearchRequest ¶
func ProcessAlertsPipeSearchRequest(queryParams alertutils.QueryParams) int
func ProcessPipeSearchRequest ¶
func ProcessPipeSearchRequest(ctx *fasthttp.RequestCtx, myid uint64)
func ProcessPipeSearchWebsocket ¶
func ProcessPipeSearchWebsocket(conn *websocket.Conn, orgid uint64, ctx *fasthttp.RequestCtx)
func SearchQueryToASTnode ¶
Types ¶
type AggregationResults ¶
type AggregationResults struct {
Buckets []map[string]interface{} `json:"buckets"`
}
type AllIndicesInfoResponse ¶
type AllIndicesInfoResponse []*IndexInfo
type Cloner ¶
type Cloner interface {
Clone() any
}
Cloner is implemented by any value that has a Clone method, which returns a copy of the value. This is mainly used for types which are not passed by value (e.g map, slice, chan) or structs that contain such types.
This is used in conjunction with the global state feature to create proper copies of the state to allow the parser to properly restore the state in the case of backtracking.
type ESResponse ¶
type Option ¶
type Option func(*parser) Option
Option is a function that can set an option on the parser. It returns the previous setting as an Option.
func AllowInvalidUTF8 ¶
AllowInvalidUTF8 creates an Option to allow invalid UTF-8 bytes. Every invalid UTF-8 byte is treated as a utf8.RuneError (U+FFFD) by character class matchers and is matched by the any matcher. The returned matched value, c.text and c.offset are NOT affected.
The default is false.
func Debug ¶
Debug creates an Option to set the debug flag to b. When set to true, debugging information is printed to stdout while parsing.
The default is false.
func Entrypoint ¶
Entrypoint creates an Option to set the rule name to use as entrypoint. The rule name must have been specified in the -alternate-entrypoints if generating the parser with the -optimize-grammar flag, otherwise it may have been optimized out. Passing an empty string sets the entrypoint to the first rule in the grammar.
The default is to start parsing at the first rule in the grammar.
func GlobalStore ¶
GlobalStore creates an Option to set a key to a certain value in the globalStore.
func InitState ¶
InitState creates an Option to set a key to a certain value in the global "state" store.
func MaxExpressions ¶
MaxExpressions creates an Option to stop parsing after the provided number of expressions have been parsed, if the value is 0 then the parser will parse for as many steps as needed (possibly an infinite number).
The default for maxExprCnt is 0.
func Memoize ¶
Memoize creates an Option to set the memoize flag to b. When set to true, the parser will cache all results so each expression is evaluated only once. This guarantees linear parsing time even for pathological cases, at the expense of more memory and slower times for typical cases.
The default is false.
func Recover ¶
Recover creates an Option to set the recover flag to b. When set to true, this causes the parser to recover from panics and convert it to an error. Setting it to false can be useful while debugging to access the full stack trace.
The default is true.
func Statistics ¶
Statistics adds a user provided Stats struct to the parser to allow the user to process the results after the parsing has finished. Also the key for the "no match" counter is set.
Example usage:
input := "input" stats := Stats{} _, err := Parse("input-file", []byte(input), Statistics(&stats, "no match")) if err != nil { log.Panicln(err) } b, err := json.MarshalIndent(stats.ChoiceAltCnt, "", " ") if err != nil { log.Panicln(err) } fmt.Println(string(b))
type PipeSearchCompleteResponse ¶
type PipeSearchCompleteResponse struct { State string `json:"state,omitempty"` TotalMatched interface{} `json:"totalMatched,omitempty"` TotalEventsSearched interface{} `json:"total_events_searched,omitempty"` CanScrollMore bool `json:"can_scroll_more"` TotalRRCCount interface{} `json:"total_rrc_count,omitempty"` MeasureFunctions []string `json:"measureFunctions,omitempty"` MeasureResults []*structs.BucketHolder `json:"measure,omitempty"` GroupByCols []string `json:"groupByCols,omitempty"` Qtype string `json:"qtype,omitempty"` BucketCount int `json:"bucketCount,omitempty"` IsTimechart bool `json:"isTimechart"` }
type PipeSearchResponse ¶
type PipeSearchResponse struct { TotalMatched interface{} `json:"totalMatched"` Hits []map[string]interface{} `json:"records"` }
type PipeSearchResponseOuter ¶
type PipeSearchResponseOuter struct { Hits PipeSearchResponse `json:"hits"` Aggs map[string]AggregationResults `json:"aggregations"` ElapedTimeMS int64 `json:"elapedTimeMS"` AllPossibleColumns []string `json:"allColumns"` Errors []string `json:"errors,omitempty"` MeasureFunctions []string `json:"measureFunctions,omitempty"` MeasureResults []*structs.BucketHolder `json:"measure,omitempty"` GroupByCols []string `json:"groupByCols,omitempty"` Qtype string `json:"qtype,omitempty"` CanScrollMore bool `json:"can_scroll_more"` TotalRRCCount interface{} `json:"total_rrc_count,omitempty"` BucketCount int `json:"bucketCount,omitempty"` DashboardPanelId string `json:"dashboardPanelId"` }
type PipeSearchWSUpdateResponse ¶
type PipeSearchWSUpdateResponse struct { Hits PipeSearchResponse `json:"hits,omitempty"` AllPossibleColumns []string `json:"allColumns,omitempty"` Completion float64 `json:"percent_complete"` State string `json:"state,omitempty"` TotalEventsSearched interface{} `json:"total_events_searched,omitempty"` MeasureFunctions []string `json:"measureFunctions,omitempty"` MeasureResults []*structs.BucketHolder `json:"measure,omitempty"` GroupByCols []string `json:"groupByCols,omitempty"` Qtype string `json:"qtype,omitempty"` BucketCount int `json:"bucketCount,omitempty"` SortByTimestampAtDefault bool `json:"sortByTimestampAtDefault"` }
type Stats ¶
type Stats struct { // ExprCnt counts the number of expressions processed during parsing // This value is compared to the maximum number of expressions allowed // (set by the MaxExpressions option). ExprCnt uint64 // ChoiceAltCnt is used to count for each ordered choice expression, // which alternative is used how may times. // These numbers allow to optimize the order of the ordered choice expression // to increase the performance of the parser // // The outer key of ChoiceAltCnt is composed of the name of the rule as well // as the line and the column of the ordered choice. // The inner key of ChoiceAltCnt is the number (one-based) of the matching alternative. // For each alternative the number of matches are counted. If an ordered choice does not // match, a special counter is incremented. The name of this counter is set with // the parser option Statistics. // For an alternative to be included in ChoiceAltCnt, it has to match at least once. ChoiceAltCnt map[string]map[string]int }
Stats stores some statistics, gathered during parsing
type Version ¶
type Version struct { Number string `json:"number"` BuildFlavor string `json:"build_flavor"` BuildType string `json:"build_type"` BuildHash string `json:"build_hash"` BuildDate string `json:"build_date"` BuildSnap bool `json:"build_snapshot"` LuceneVersion string `json:"lucene_version"` MWCV string `json:"minimum_wire_compatibility_version"` MICV string `json:"minimum_index_compatibility_version"` }