Documentation
¶
Index ¶
- Constants
- func DetermineSpanStatus(spanHit map[string]interface{}) string
- func ExtractLogType(logType string) string
- func GetOperatorSymbol(operator string) string
- func GetTraceID(hit Hit) string
- type AggFilteredTopHits
- type AggTopHitsValue
- type BuildQueryParams
- type Client
- func (c *Client) CreateMonitor(ctx context.Context, monitor map[string]interface{}) (string, int64, error)
- func (c *Client) DeleteMonitor(ctx context.Context, monitorID string) error
- func (c *Client) GetIndexMapping(ctx context.Context, index string) (*MappingResponse, error)
- func (c *Client) GetMonitorByID(ctx context.Context, monitorID string) (map[string]interface{}, error)
- func (c *Client) Search(ctx context.Context, indices []string, query map[string]interface{}) (*SearchResponse, error)
- func (c *Client) SearchMonitorByName(ctx context.Context, name string) (string, bool, error)
- func (c *Client) UpdateMonitor(ctx context.Context, monitorID string, monitor map[string]interface{}) (int64, error)
- func (c *Client) WriteAlertEntry(ctx context.Context, entry map[string]interface{}) (string, error)
- type ComponentLogsQueryParamsV1
- type ComponentQueryParams
- type FieldMapping
- type GatewayQueryParams
- type Hit
- type IndexMapping
- type LogEntry
- type MappingResponse
- type MonitorActionExecutionScopePerAlert
- type MonitorBody
- type MonitorInput
- type MonitorInputSearch
- type MonitorMessageTemplate
- type MonitorSchedule
- type MonitorSchedulePeriod
- type MonitorTrigger
- type MonitorTriggerAction
- type MonitorTriggerActionExecutionPolicy
- type MonitorTriggerActionExecutionScope
- type MonitorTriggerActionThrottle
- type MonitorTriggerBucketLevelTrigger
- type MonitorTriggerCondition
- type MonitorTriggerConditionScript
- type MonitorTriggerQueryLevelTrigger
- type QueryBuilder
- func (qb *QueryBuilder) BuildBuildLogsQuery(params BuildQueryParams) map[string]interface{}
- func (qb *QueryBuilder) BuildComponentLogsQuery(params ComponentQueryParams) map[string]interface{}
- func (qb *QueryBuilder) BuildComponentLogsQueryV1(params ComponentLogsQueryParamsV1) (map[string]interface{}, error)
- func (qb *QueryBuilder) BuildGatewayLogsQuery(params GatewayQueryParams) map[string]interface{}
- func (qb *QueryBuilder) BuildLogAlertingRuleMonitorBody(params types.AlertingRuleRequest) (map[string]interface{}, error)
- func (qb *QueryBuilder) BuildLogAlertingRuleQuery(params types.AlertingRuleRequest) (map[string]interface{}, error)
- func (qb *QueryBuilder) BuildNamespaceLogsQuery(params QueryParams, podLabels map[string]string) map[string]interface{}
- func (qb *QueryBuilder) BuildProjectLogsQuery(params QueryParams, componentIDs []string) map[string]interface{}
- func (qb *QueryBuilder) BuildSpanDetailsQuery(traceID string, spanID string) map[string]interface{}
- func (qb *QueryBuilder) BuildTracesAggregationQuery(params TracesRequestParams) map[string]interface{}
- func (qb *QueryBuilder) BuildTracesQuery(params TracesRequestParams) map[string]interface{}
- func (qb *QueryBuilder) BuildWorkflowRunLogsQuery(params WorkflowRunQueryParams) map[string]interface{}
- func (qb *QueryBuilder) BuildWorkflowRunPodLogsQuery(params WorkflowRunLogsQueryParams) map[string]interface{}
- func (qb *QueryBuilder) CheckQueryVersion(mapping *MappingResponse, indexName string) string
- func (qb *QueryBuilder) GenerateIndices(startTime, endTime string) ([]string, error)
- type QueryParams
- type SearchResponse
- type Span
- type Trace
- type TraceBucket
- type TraceResponse
- type TracesAggregationResult
- type TracesRequestParams
- type WorkflowRunLogEntry
- type WorkflowRunLogsQueryParams
- type WorkflowRunQueryParams
Constants ¶
const ( SpanStatusOK = "ok" SpanStatusError = "error" SpanStatusUnset = "unset" )
Variables ¶
This section is empty.
Functions ¶
func DetermineSpanStatus ¶ added in v1.0.1
DetermineSpanStatus derives a span's execution status Returns one of "ok", "error", or "unset".
func ExtractLogType ¶
ExtractLogType determines the log type from query parameters or defaults to RUNTIME
func GetOperatorSymbol ¶ added in v0.9.0
func GetTraceID ¶ added in v0.7.0
GetTraceID extracts the traceId from a span hit
Types ¶
type AggFilteredTopHits ¶ added in v1.0.1
type AggFilteredTopHits struct {
DocCount int `json:"doc_count"`
Hit AggTopHitsValue `json:"hit"`
}
AggFilteredTopHits represents a filter aggregation with a nested top_hits sub-aggregation
type AggTopHitsValue ¶ added in v1.0.1
type AggTopHitsValue struct {
Hits struct {
Hits []Hit `json:"hits"`
} `json:"hits"`
}
AggTopHitsValue represents a top_hits aggregation result
type BuildQueryParams ¶ added in v0.6.0
type BuildQueryParams struct {
QueryParams
BuildID string `json:"buildId"`
Limit int `json:"limit"`
SortOrder string `json:"sortOrder"`
}
BuildQueryParams holds build-specific query parameters
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the OpenSearch client with logging and configuration
func (*Client) CreateMonitor ¶ added in v0.9.0
func (c *Client) CreateMonitor(ctx context.Context, monitor map[string]interface{}) (string, int64, error)
CreateMonitor creates a new alerting monitor using the Alerting plugin API.
func (*Client) DeleteMonitor ¶ added in v0.9.0
DeleteMonitor deletes an alerting monitor using the Alerting plugin API.
func (*Client) GetIndexMapping ¶
GetIndexMapping retrieves the mapping for a specific index
func (*Client) GetMonitorByID ¶ added in v0.9.0
func (c *Client) GetMonitorByID(ctx context.Context, monitorID string) (map[string]interface{}, error)
GetMonitorByID retrieves an alerting monitor by ID using the Alerting plugin API.
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, indices []string, query map[string]interface{}) (*SearchResponse, error)
Search executes a search request against OpenSearch
func (*Client) SearchMonitorByName ¶ added in v0.9.0
SearchMonitorByName searches alerting monitors by name using the Alerting plugin API.
type ComponentLogsQueryParamsV1 ¶ added in v0.17.0
type ComponentLogsQueryParamsV1 struct {
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
NamespaceName string `json:"namespaceName"` // OpenChoreo namespace name (required)
ProjectID string `json:"projectId,omitempty"`
ComponentID string `json:"componentId,omitempty"`
EnvironmentID string `json:"environmentId,omitempty"`
SearchPhrase string `json:"searchPhrase,omitempty"`
LogLevels []string `json:"logLevels,omitempty"`
Limit int `json:"limit"`
SortOrder string `json:"sortOrder"`
}
ComponentLogsQueryParamsV1 holds query parameters for the new API component logs query This properly handles optional filters (only adds term filters when values are non-empty)
type ComponentQueryParams ¶
type ComponentQueryParams struct {
QueryParams
BuildID string `json:"buildId,omitempty"`
BuildUUID string `json:"buildUuid,omitempty"`
}
ComponentQueryParams holds component-specific query parameters
type FieldMapping ¶
type FieldMapping struct {
Type string `json:"type"`
Fields map[string]FieldMapping `json:"fields,omitempty"`
Properties map[string]FieldMapping `json:"properties,omitempty"`
}
FieldMapping represents the mapping for a single field
type GatewayQueryParams ¶
type GatewayQueryParams struct {
QueryParams
NamespaceName string `json:"namespaceName"`
APIIDToVersionMap map[string]string `json:"apiIdToVersionMap"`
GatewayVHosts []string `json:"gatewayVHosts"`
}
GatewayQueryParams holds gateway-specific query parameters
type Hit ¶
type Hit struct {
ID string `json:"_id"`
Source map[string]interface{} `json:"_source"`
Score *float64 `json:"_score"`
}
Hit represents a single search result hit
type IndexMapping ¶
type IndexMapping struct {
Mappings struct {
Properties map[string]FieldMapping `json:"properties"`
} `json:"mappings"`
}
IndexMapping represents the mapping for a single index
type LogEntry ¶
type LogEntry struct {
Timestamp time.Time `json:"timestamp"`
Log string `json:"log"`
LogLevel string `json:"logLevel"`
ComponentID string `json:"componentId"`
EnvironmentID string `json:"environmentId"`
ProjectID string `json:"projectId"`
Version string `json:"version"`
VersionID string `json:"versionId"`
Namespace string `json:"namespace"`
PodID string `json:"podId"`
ContainerName string `json:"containerName"`
Labels map[string]string `json:"labels"`
// Additional fields for logs API v1
ComponentName string `json:"componentName,omitempty"`
EnvironmentName string `json:"environmentName,omitempty"`
ProjectName string `json:"projectName,omitempty"`
NamespaceName string `json:"namespaceName,omitempty"`
PodNamespace string `json:"podNamespace,omitempty"`
PodName string `json:"podName,omitempty"`
}
LogEntry represents a parsed log entry from OpenSearch
func ParseLogEntry ¶
ParseLogEntry converts a search hit to a LogEntry struct
type MappingResponse ¶
type MappingResponse struct {
Mappings map[string]IndexMapping `json:",inline"`
}
MappingResponse represents the response from an index mapping query
type MonitorActionExecutionScopePerAlert ¶ added in v0.9.0
type MonitorActionExecutionScopePerAlert struct {
ActionableAlerts []string `json:"actionable_alerts"`
}
MonitorActionExecutionScopePerAlert defines per-alert action settings
type MonitorBody ¶ added in v0.9.0
type MonitorBody struct {
Type string `json:"type"`
MonitorType string `json:"monitor_type"`
Name string `json:"name"`
Enabled bool `json:"enabled"`
Schedule MonitorSchedule `json:"schedule"`
Inputs []MonitorInput `json:"inputs"`
Triggers []MonitorTrigger `json:"triggers"`
}
MonitorBody represents the structure of an OpenSearch monitor
type MonitorInput ¶ added in v0.9.0
type MonitorInput struct {
Search MonitorInputSearch `json:"search"`
}
MonitorInput defines the search input for the monitor
type MonitorInputSearch ¶ added in v0.9.0
type MonitorInputSearch struct {
Indices []string `json:"indices"`
Query map[string]interface{} `json:"query"`
}
MonitorInputSearch defines the search query and indices
type MonitorMessageTemplate ¶ added in v0.9.0
MonitorMessageTemplate defines the message template
type MonitorSchedule ¶ added in v0.9.0
type MonitorSchedule struct {
Period MonitorSchedulePeriod `json:"period"`
}
MonitorSchedule defines the monitoring schedule
type MonitorSchedulePeriod ¶ added in v0.9.0
MonitorSchedulePeriod defines the time period for schedule
type MonitorTrigger ¶ added in v0.9.0
type MonitorTrigger struct {
QueryLevelTrigger *MonitorTriggerQueryLevelTrigger `json:"query_level_trigger,omitempty"`
BucketLevelTrigger *MonitorTriggerBucketLevelTrigger `json:"bucket_level_trigger,omitempty"`
}
MonitorTrigger defines the conditions and actions for the monitor
type MonitorTriggerAction ¶ added in v0.9.0
type MonitorTriggerAction struct {
Name string `json:"name"`
DestinationID string `json:"destination_id"`
MessageTemplate MonitorMessageTemplate `json:"message_template"`
ThrottleEnabled bool `json:"throttle_enabled"`
Throttle MonitorTriggerActionThrottle `json:"throttle"`
SubjectTemplate MonitorMessageTemplate `json:"subject_template"`
ActionExecutionPolicy MonitorTriggerActionExecutionPolicy `json:"action_execution_policy"`
}
MonitorTriggerAction defines the action to take when triggered
type MonitorTriggerActionExecutionPolicy ¶ added in v0.9.0
type MonitorTriggerActionExecutionPolicy struct {
ActionExecutionScope MonitorTriggerActionExecutionScope `json:"action_execution_scope"`
}
MonitorTriggerActionExecutionPolicy defines when actions should be executed
type MonitorTriggerActionExecutionScope ¶ added in v0.9.0
type MonitorTriggerActionExecutionScope struct {
PerAlert MonitorActionExecutionScopePerAlert `json:"per_alert"`
}
MonitorTriggerActionExecutionScope defines the scope of action execution
type MonitorTriggerActionThrottle ¶ added in v0.9.0
MonitorTriggerActionThrottle defines the throttle settings
type MonitorTriggerBucketLevelTrigger ¶ added in v0.9.0
type MonitorTriggerBucketLevelTrigger struct {
Name string `json:"name"`
Severity string `json:"severity"`
Condition MonitorTriggerCondition `json:"condition"`
Actions []MonitorTriggerAction `json:"actions"`
}
type MonitorTriggerCondition ¶ added in v0.9.0
type MonitorTriggerCondition struct {
Script MonitorTriggerConditionScript `json:"script"`
}
MonitorTriggerCondition defines the trigger condition
type MonitorTriggerConditionScript ¶ added in v0.9.0
type MonitorTriggerConditionScript struct {
Source string `json:"source"`
Lang string `json:"lang"`
}
MonitorTriggerConditionScript defines the script for evaluation
type MonitorTriggerQueryLevelTrigger ¶ added in v0.9.0
type MonitorTriggerQueryLevelTrigger struct {
Name string `json:"name"`
Severity string `json:"severity"`
Condition MonitorTriggerCondition `json:"condition"`
Actions []MonitorTriggerAction `json:"actions"`
}
type QueryBuilder ¶
type QueryBuilder struct {
// contains filtered or unexported fields
}
QueryBuilder provides methods to build OpenSearch queries
func NewQueryBuilder ¶
func NewQueryBuilder(indexPrefix string) *QueryBuilder
NewQueryBuilder creates a new query builder with the given index prefix
func (*QueryBuilder) BuildBuildLogsQuery ¶ added in v0.6.0
func (qb *QueryBuilder) BuildBuildLogsQuery(params BuildQueryParams) map[string]interface{}
BuildBuildLogsQuery builds a query for build logs with wildcard search
func (*QueryBuilder) BuildComponentLogsQuery ¶
func (qb *QueryBuilder) BuildComponentLogsQuery(params ComponentQueryParams) map[string]interface{}
BuildComponentLogsQuery builds a query for component logs with wildcard search
func (*QueryBuilder) BuildComponentLogsQueryV1 ¶ added in v0.17.0
func (qb *QueryBuilder) BuildComponentLogsQueryV1(params ComponentLogsQueryParamsV1) (map[string]interface{}, error)
BuildComponentLogsQueryV1 builds a query for the new API component logs endpoint This properly handles optional filters (only adds term filters when values are non-empty)
func (*QueryBuilder) BuildGatewayLogsQuery ¶
func (qb *QueryBuilder) BuildGatewayLogsQuery(params GatewayQueryParams) map[string]interface{}
BuildGatewayLogsQuery builds a query for gateway logs with wildcard search
func (*QueryBuilder) BuildLogAlertingRuleMonitorBody ¶ added in v0.9.0
func (qb *QueryBuilder) BuildLogAlertingRuleMonitorBody(params types.AlertingRuleRequest) (map[string]interface{}, error)
func (*QueryBuilder) BuildLogAlertingRuleQuery ¶ added in v0.9.0
func (qb *QueryBuilder) BuildLogAlertingRuleQuery(params types.AlertingRuleRequest) (map[string]interface{}, error)
func (*QueryBuilder) BuildNamespaceLogsQuery ¶ added in v0.13.0
func (qb *QueryBuilder) BuildNamespaceLogsQuery(params QueryParams, podLabels map[string]string) map[string]interface{}
BuildNamespaceLogsQuery builds a query for namespace logs with wildcard search
func (*QueryBuilder) BuildProjectLogsQuery ¶
func (qb *QueryBuilder) BuildProjectLogsQuery(params QueryParams, componentIDs []string) map[string]interface{}
BuildProjectLogsQuery builds a query for project logs with wildcard search
func (*QueryBuilder) BuildSpanDetailsQuery ¶ added in v0.17.0
func (qb *QueryBuilder) BuildSpanDetailsQuery(traceID string, spanID string) map[string]interface{}
BuildSpanDetailsQuery builds a query for retrieving a specific span by traceId and spanId
func (*QueryBuilder) BuildTracesAggregationQuery ¶ added in v1.0.1
func (qb *QueryBuilder) BuildTracesAggregationQuery(params TracesRequestParams) map[string]interface{}
BuildTracesAggregationQuery builds an aggregation query that groups spans by traceId, so that the limit parameter controls the number of distinct traces returned.
func (*QueryBuilder) BuildTracesQuery ¶ added in v0.7.0
func (qb *QueryBuilder) BuildTracesQuery(params TracesRequestParams) map[string]interface{}
func (*QueryBuilder) BuildWorkflowRunLogsQuery ¶ added in v0.13.0
func (qb *QueryBuilder) BuildWorkflowRunLogsQuery(params WorkflowRunQueryParams) map[string]interface{}
BuildWorkflowRunLogsQuery builds a query for workflow run logs with wildcard search
func (*QueryBuilder) BuildWorkflowRunPodLogsQuery ¶ added in v0.17.0
func (qb *QueryBuilder) BuildWorkflowRunPodLogsQuery(params WorkflowRunLogsQueryParams) map[string]interface{}
BuildWorkflowRunPodLogsQuery builds a query for workflow run pod logs
func (*QueryBuilder) CheckQueryVersion ¶
func (qb *QueryBuilder) CheckQueryVersion(mapping *MappingResponse, indexName string) string
CheckQueryVersion determines if the index supports V2 wildcard queries
func (*QueryBuilder) GenerateIndices ¶
func (qb *QueryBuilder) GenerateIndices(startTime, endTime string) ([]string, error)
GenerateIndices generates the list of indices to search based on time range
type QueryParams ¶
type QueryParams struct {
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
SearchPhrase string `json:"searchPhrase"`
LogLevels []string `json:"logLevels"`
Limit int `json:"limit"`
SortOrder string `json:"sortOrder"`
ComponentID string `json:"componentId,omitempty"`
EnvironmentID string `json:"environmentId,omitempty"`
ProjectID string `json:"projectId,omitempty"`
NamespaceName string `json:"namespaceName,omitempty"`
Namespace string `json:"namespace,omitempty"`
Versions []string `json:"versions,omitempty"`
VersionIDs []string `json:"versionIds,omitempty"`
LogType string `json:"logType,omitempty"`
}
QueryParams holds common query parameters
type SearchResponse ¶
type SearchResponse struct {
Hits struct {
Total struct {
Value int `json:"value"`
Relation string `json:"relation"`
} `json:"total"`
Hits []Hit `json:"hits"`
} `json:"hits"`
Aggregations json.RawMessage `json:"aggregations,omitempty"`
Took int `json:"took"`
TimedOut bool `json:"timed_out"`
}
SearchResponse represents the response from an OpenSearch search query
type Span ¶ added in v0.4.0
type Span struct {
DurationNanoseconds int64 `json:"durationNanoseconds"`
EndTime time.Time `json:"endTime"`
Name string `json:"name"`
OpenChoreoComponentUID string `json:"openChoreoComponentUid"`
OpenChoreoProjectUID string `json:"openChoreoProjectUid"`
ParentSpanID string `json:"parentSpanId"`
SpanID string `json:"spanId"`
SpanKind string `json:"spanKind"`
StartTime time.Time `json:"startTime"`
Status string `json:"status,omitempty"`
Attributes map[string]interface{} `json:"attributes,omitempty"`
ResourceAttributes map[string]interface{} `json:"resourceAttributes,omitempty"`
}
Span represents a parsed span entry from OpenSearch
func ParseSpanEntry ¶ added in v0.4.0
ParseSpanEntry converts a search hit of a span to a SpanEntry struct
type TraceBucket ¶ added in v1.0.1
type TraceBucket struct {
Key string `json:"key"`
DocCount int `json:"doc_count"`
EarliestSpan AggTopHitsValue `json:"earliest_span"`
RootSpan AggFilteredTopHits `json:"root_span"`
LatestSpan AggTopHitsValue `json:"latest_span"`
ErrorSpanCount AggFilteredTopHits `json:"error_span_count"`
}
TraceBucket represents a single trace bucket from the terms aggregation
type TraceResponse ¶ added in v0.4.0
TraceResponse represents the response structure for trace queries
type TracesAggregationResult ¶ added in v1.0.1
type TracesAggregationResult struct {
TraceCount struct {
Value int `json:"value"`
} `json:"trace_count"`
Traces struct {
Buckets []TraceBucket `json:"buckets"`
} `json:"traces"`
}
TracesAggregationResult represents the parsed aggregation response for traces queries
type TracesRequestParams ¶ added in v0.7.0
type TracesRequestParams struct {
ComponentNames []string `json:"componentNames,omitempty"`
ComponentUIDs []string `json:"componentUids,omitempty"`
EndTime string `json:"endTime"`
EnvironmentName string `json:"environmentName,omitempty"`
EnvironmentUID string `json:"environmentUid,omitempty"`
Limit int `json:"limit,omitempty"`
NamespaceName string `json:"namespaceName,omitempty"`
ProjectName string `json:"projectName,omitempty"`
ProjectUID string `json:"projectUid"`
SortOrder string `json:"sortOrder,omitempty"`
StartTime string `json:"startTime"`
TraceID string `json:"traceId,omitempty"`
}
TracesRequestParams holds request body parameters for traces
type WorkflowRunLogEntry ¶ added in v0.17.0
WorkflowRunLogEntry represents a log entry for workflow run logs Not using LogEntry struct as loglevel, labels, etc. are not relevant for workflow run logs
type WorkflowRunLogsQueryParams ¶ added in v0.17.0
type WorkflowRunLogsQueryParams struct {
RunName string `json:"runName"`
StepName string `json:"stepName"`
Limit int `json:"limit"`
}
WorkflowRunLogsQueryParams holds workflow run logs-specific query parameters
type WorkflowRunQueryParams ¶ added in v0.13.0
type WorkflowRunQueryParams struct {
QueryParams
WorkflowRunID string `json:"workflowRunId"`
StepName string `json:"stepName,omitempty"`
}
WorkflowRunQueryParams holds workflow run-specific query parameters