openobserve

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SearchTypeDefault    = ""
	SearchTypeUI         = "ui"
	SearchTypeDashBoards = "dashboards"
	SearchTypeReports    = "reports"
	SearchTypeAlerts     = "alerts"
)
View Source
const (
	LogsStream   = "logs"
	MetricStream = "metrics"
	TraceStream  = "traces"
)
View Source
const (
	SqlSelectALlColumns        = "sql_select_all_columns"
	SqlSelectSpecifiedcColumns = "sql_select_specified_columns"
)
View Source
const (
	Equals             = "="
	NotEqual           = "!="
	MatchRegex         = "=~"
	NotMatchRegex      = "!~"
	LessThan           = "<"
	GreaterThan        = ">"
	GreaterThanOrEqual = ">="
	LessThanOrEqual    = "<="
)

Variables

View Source
var OperatorMap = map[string]string{
	Equals:             "=",
	NotEqual:           "<>",
	MatchRegex:         "~",
	NotMatchRegex:      "!~",
	LessThan:           "<",
	GreaterThan:        ">",
	GreaterThanOrEqual: ">=",
	LessThanOrEqual:    "<=",
}

OperatorMap key = adhoc operator, value = postgresql operator

Functions

This section is empty.

Types

type Item

type Item struct {
	TimeStamp int64           `json:"timestamp"`
	Body      string          `json:"body"`
	RawLabels json.RawMessage `json:"raw_labels"` // Labels are optional, so we can omit them if not needed
}

type ListStreamRequestParam

type ListStreamRequestParam struct {
	Organization string `json:"organization"`
	StreamType   string `json:"stream_type"` //stream type, e.g., "logs", "metrics", "traces"
	SortBy       string `json:"sort_by"`     // sort result by name or other fields
	Ascending    bool   `json:"ascending"`   // ascending or descending order
}

ListStreamRequestParam defines the request parameters for listing OpenObserve streams information

type ListStreamResponse

type ListStreamResponse struct {
	List []StreamInfo `json:"list"`
}

ListStreamResponse defines the response structure for listing OpenObserve streams

type OpenObserveClient

type OpenObserveClient struct {
	BaseUrl string
	// contains filtered or unexported fields
}

OpenObserveClient is a client for interacting with the OpenObserve API

func NewOpenObserveClient

func NewOpenObserveClient(baseUrl, username, password string) *OpenObserveClient

NewOpenObserveClient creates a new OpenObserve client with the given base URL, username, and password

func (*OpenObserveClient) HandleListStreams

func (c *OpenObserveClient) HandleListStreams(rw http.ResponseWriter, req *http.Request)

HandleListStreams handles the HTTP request to list streams

func (*OpenObserveClient) HealthCheck

func (c *OpenObserveClient) HealthCheck() error

HealthCheck checks the health of the OpenObserve cluster

func (*OpenObserveClient) ListStreams

func (c *OpenObserveClient) ListStreams(listStreamReqParam *ListStreamRequestParam) (*ListStreamResponse, error)

ListStreams lists the streams information in the OpenObserve cluster

func (*OpenObserveClient) Search

func (c *OpenObserveClient) Search(searchReqParam *SearchRequestParam, searchReqBody *SearchRequestBody) (*SearchResponse, error)

Search performs a search request to the OpenObserve API

type ParsedSearchResult

type ParsedSearchResult struct {
	Items []Item `json:"items"`
}

type Query

type Query struct {
	Sql       string `json:"sql"`
	StartTime int64  `json:"start_time"`
	EndTime   int64  `json:"end_time"`
	From      int64  `json:"from"`
	Size      int64  `json:"size"`
}

type SQL

type SQL struct {
	CompletedSql string
	Limit        int64 // Extracted LIMIT value from SQL, 0 means no limit specified
	// contains filtered or unexported fields
}

type Schema

type Schema struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type SearchRequestBody

type SearchRequestBody struct {
	Query      `json:"query"`
	SearchType string `json:"search_type"`
	Timeout    int    `json:"timeout"`
}

SearchRequestBody defines the body of the OpenObserve search request

type SearchRequestParam

type SearchRequestParam struct {
	Organization string `json:"organization"`
	StreamType   string `json:"stream_type"`
	SearchType   string `json:"search_type"`
	UseCache     bool   `json:"use_cache"`
	EnableSSE    bool   `json:"enable_sse"`
}

SearchRequestParam defines the parameters for the OpenObserve search request

type SearchResponse

type SearchResponse struct {
	Took             int              `json:"took"`
	TookDetail       SearchTookDetail `json:"took_detail"`
	Hits             []map[string]any `json:"hits"`
	Total            int              `json:"total"`
	From             int              `json:"from"`
	Size             int              `json:"size"`
	CachedRatio      int              `json:"cached_ratio"`
	ScanSize         int              `json:"scan_size"`
	IdxScanSize      int              `json:"idx_scan_size"`
	ScanRecords      int              `json:"scan_records"`
	TraceID          string           `json:"trace_id"`
	IsPartial        bool             `json:"is_partial"`
	ResultCacheRatio int              `json:"result_cache_ratio"`
	WorkGroup        string           `json:"work_group"`
	OrderBy          string           `json:"order_by"`
}

SearchResponse defines the structure of the OpenObserve search response

type SearchTookDetail

type SearchTookDetail struct {
	Total        int `json:"total"`
	CacheTook    int `json:"cache_took"`
	FileListTook int `json:"file_list_took"`
	WaitInQueue  int `json:"wait_in_queue"`
	IdxTook      int `json:"idx_took"`
	SearchTook   int `json:"search_took"`
}

type SqlParser

type SqlParser struct{}

SqlParser is responsible for parsing SQL queries

func NewSqlParser

func NewSqlParser() *SqlParser

NewSqlParser creates a new instance of SqlParser

func (*SqlParser) CompeleteSqlWithAdhocFilters

func (sp *SqlParser) CompeleteSqlWithAdhocFilters(rawSql string, filters []WhereFilter) (string, error)

CompeleteSqlWithAdhocFilters completes the SQL with ad-hoc filters

func (*SqlParser) ParseSql

func (sp *SqlParser) ParseSql(sqlStr string) (*SQL, error)

parseSql parses the SQL string and returns a SQL object with select columns and where variables

type StreamInfo

type StreamInfo struct {
	Name        string   `json:"name"`
	StorageType string   `json:"storage_type"`
	StreamType  string   `json:"stream_type"`
	Schema      []Schema `json:"schema"`
}

StreamInfo defines the structure of each stream in the OpenObserve cluster

type TableResult

type TableResult struct {
	Headers []string         `json:"headers"`
	Table   map[string][]any `json:"table"`
}

type Transformer

type Transformer struct {
}

func NewTransformer

func NewTransformer() *Transformer

func (*Transformer) TransformFallbackDisplayTables

func (t *Transformer) TransformFallbackDisplayTables(listStreamResp *ListStreamResponse) (*data.Frame, error)

TransformFallbackDisplayTables transforms the OpenObserve list streams response into Grafana data frame This is used when the user selects a stream from the dropdown in the query editor

func (*Transformer) TransformFallbackSelectFrom

func (t *Transformer) TransformFallbackSelectFrom(parsedSql *SQL, searchResponse *SearchResponse) (*data.Frame, error)

TransformFallbackSelectFrom transforms the OpenObserve search response into Grafana data frame This is used when the user query a specific stream with select <columns> from SQL syntax

func (*Transformer) TransformStream

func (t *Transformer) TransformStream(parsedSql *SQL, searchResponse *SearchResponse) (*data.Frame, error)

TransformsStream transforms the OpenObserve search stream response into Grafana data frame

type Visitor

type Visitor struct {
	// contains filtered or unexported fields
}

func NewVisitor

func NewVisitor() *Visitor

func (*Visitor) VisitPost

func (v *Visitor) VisitPost(expr tree.Expr) (newNode tree.Expr)

func (*Visitor) VisitPre

func (v *Visitor) VisitPre(expr tree.Expr) (recurse bool, newExpr tree.Expr)

type WhereFilter

type WhereFilter struct {
	Key       string
	Value     string
	Operation string
}

WhereFilter represents a filter condition in the WHERE clause

func (*WhereFilter) IsValueNumber

func (f *WhereFilter) IsValueNumber() (string, bool)

func (*WhereFilter) String

func (f *WhereFilter) String() (string, error)

Jump to

Keyboard shortcuts

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