searchactivity

package
v0.1.101 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package searchactivity samples what an OpenSearch cluster is doing for one search walk: the task running the current page, the cluster's health, the pressure on the nodes running it, and how far the walk has read.

Index

Constants

View Source
const (
	// StateRunning says a search or scroll page of the walk is on the cluster.
	StateRunning = "running"
	// StateBetweenPages says no task of the walk is running: the walk is
	// mapping the last page, or waiting for its consumer.
	StateBetweenPages = "between pages"
)
View Source
const EngineOpenSearch = "opensearch"

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterSnapshot

type ClusterSnapshot struct {
	Summary  Sample
	Searches []Sample
}

func ReadCluster

func ReadCluster(ctx context.Context, client *opensearch.Client) (ClusterSnapshot, error)

ReadCluster samples active searches and the pressure across the whole cluster.

type Completion

type Completion struct {
	QueryID  string
	Progress SearchProgress
}

Completion carries the last counters of a search walk, even for a short walk that completed before its first monitoring sample.

type Filter

type Filter struct {
	OpaqueID string
	Progress SearchProgress
}

Filter names the walk to sample, by the X-Opaque-Id every one of its requests carries, and how far it has read so far.

type Sample

type Sample struct {
	SampledAt   time.Time `json:"sampledAt" pretty:"label=Sampled" filter:"time" sort:"sampledAt"`
	Engine      string    `json:"engine" filter:"terms" sort:"engine"`
	State       string    `json:"state" filter:"terms" sort:"state"`
	QueryID     string    `json:"queryId" pretty:"label=Query id" filter:"exact" sort:"queryId"`
	TaskID      string    `json:"taskId,omitempty" pretty:"label=Task" filter:"exact" sort:"taskId"`
	Node        string    `json:"node,omitempty" filter:"terms" sort:"node"`
	Action      string    `json:"action,omitempty" filter:"terms" sort:"action"`
	Description string    `json:"description,omitempty" filter:"text" sort:"description"`
	StartedAt   time.Time `json:"startedAt,omitzero" pretty:"label=Started" filter:"time" sort:"startedAt"`
	ElapsedMs   float64   `json:"elapsedMs" pretty:"label=Elapsed,type=duration,unit=ms" filter:"duration" sort:"elapsedMs"`
	Cancellable bool      `json:"cancellable" filter:"boolean" sort:"cancellable"`
	Cancelled   bool      `json:"cancelled" filter:"boolean" sort:"cancelled"`
	CPUMs       *float64  `json:"cpuMs,omitempty" pretty:"label=CPU,type=duration,unit=ms" filter:"duration" sort:"cpuMs"`
	MemoryBytes *int64    `json:"memoryBytes,omitempty" pretty:"label=Memory,type=bytes" filter:"range" sort:"memoryBytes"`

	Cluster             string  `json:"cluster" filter:"terms" sort:"cluster"`
	Status              string  `json:"status" filter:"terms" sort:"status"`
	ActiveShardsPercent float64 `json:"activeShardsPercent" pretty:"label=Active shards,unit=percent" filter:"range" sort:"activeShardsPercent"`
	UnassignedShards    int64   `json:"unassignedShards" pretty:"label=Unassigned shards" filter:"range" sort:"unassignedShards"`
	RelocatingShards    int64   `json:"relocatingShards" pretty:"label=Relocating shards" filter:"range" sort:"relocatingShards"`
	PendingTasks        int64   `json:"pendingTasks" pretty:"label=Pending tasks" filter:"range" sort:"pendingTasks"`

	HeapPercent    *float64 `json:"heapPercent,omitempty" pretty:"label=Heap,unit=percent" filter:"range" sort:"heapPercent"`
	CPUPercent     *float64 `json:"cpuPercent,omitempty" pretty:"label=Node CPU,unit=percent" filter:"range" sort:"cpuPercent"`
	SearchActive   *int64   `json:"searchActive,omitempty" pretty:"label=Search active" filter:"range" sort:"searchActive"`
	SearchQueue    *int64   `json:"searchQueue,omitempty" pretty:"label=Search queue" filter:"range" sort:"searchQueue"`
	SearchRejected *int64   `json:"searchRejected,omitempty" pretty:"label=Search rejected" filter:"range" sort:"searchRejected"`
	SearchProgress
}

Sample is one read of a walk's search activity. The task fields are empty between pages; nullable measurements distinguish unavailable from zero.

func Read

func Read(ctx context.Context, client *opensearch.Client, filter Filter) (Sample, error)

Read takes one sample of the walk filter names with three reads: its tasks, the cluster's health and the stats of the nodes running them. A failed read fails the sample; a walk with no running task is between pages, not an error.

func (Sample) SampleEngine

func (s Sample) SampleEngine() string

SampleEngine names the engine the sample was read from.

type SearchProgress

type SearchProgress struct {
	Pages           int      `json:"pages" filter:"range" sort:"pages"`
	RowsRead        int64    `json:"rowsRead" pretty:"label=Rows read" filter:"range" sort:"rowsRead"`
	TotalHits       *int64   `json:"totalHits,omitempty" pretty:"label=Total hits" filter:"range" sort:"totalHits"`
	TotalRelation   string   `json:"totalRelation,omitempty" pretty:"label=Total relation" filter:"terms" sort:"totalRelation"`
	PercentComplete *float64 `json:"percentComplete,omitempty" pretty:"label=Progress,unit=percent" filter:"range" sort:"percentComplete"`
}

SearchProgress is how far a walk has read: the pages and rows it received, against the total the index reported for the search.

func (SearchProgress) Derive

func (p SearchProgress) Derive() SearchProgress

Derive states the rows read as a percentage of the total, only when the total is exact and non-zero: a lower bound ("gte") would make the walk look further along than it is.

Jump to

Keyboard shortcuts

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