Documentation
¶
Overview ¶
Package elasticsearch provides bounded, read-only access to one configured Elasticsearch log source.
Index ¶
- Constants
- Variables
- type Client
- func (client *Client) ClearIngestScroll(ctx context.Context, address, scrollID string) error
- func (client *Client) NextIngestScroll(ctx context.Context, address, scrollID string, output any) error
- func (client *Client) OpenIngestScroll(ctx context.Context, body []byte, output any) (string, error)
- func (client *Client) SearchIngestJSON(ctx context.Context, body []byte, output any) error
- func (client *Client) SearchIngestJSONWithPreference(ctx context.Context, preference string, body []byte, output any) error
- func (client *Client) SearchJSON(ctx context.Context, body []byte, output any) error
- type Index
- type IndexMapping
- type IndexResult
- type MappingField
- type MappingResult
- type SearchHit
- type SearchOptions
- type SearchResult
- type Service
- func (service *Service) Client() *Client
- func (service *Service) Config() config.AgentElasticsearchSourceConfig
- func (service *Service) ListIndices(ctx context.Context, limit int) (IndexResult, error)
- func (service *Service) Mappings(ctx context.Context, limit int) (MappingResult, error)
- func (service *Service) PreviewSearch(options SearchOptions) (json.RawMessage, error)
- func (service *Service) ProjectedFields() []string
- func (service *Service) Search(ctx context.Context, options SearchOptions) (SearchResult, error)
- func (service *Service) SearchWithPrefix(ctx context.Context, options SearchOptions) (SearchResult, error)
- func (service *Service) SetScrubber(scrubber core.Scrubber)
- func (service *Service) Shards(ctx context.Context, limit int) (ShardResult, error)
- type Shard
- type ShardResult
- type ShardStats
Constants ¶
const ( DefaultLimit = 20 MaximumLimit = 50 MaximumFields = 32 MaximumMappingFieldsPerIndex = 50 )
Variables ¶
var ( ErrInvalidConfig = errors.New("elasticsearch: invalid source configuration") ErrInvalidArguments = errors.New("elasticsearch: invalid arguments") ErrForbidden = errors.New("elasticsearch: forbidden") ErrNotFound = errors.New("elasticsearch: not found") ErrResponseTooLarge = errors.New("elasticsearch: response too large") ErrBackend = errors.New("elasticsearch: backend unavailable") ErrShardFailure = errors.New("elasticsearch: search failed on one or more shards") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client owns transport, authentication, failover, and source index scoping.
func NewClient ¶
func NewClient(cfg config.AgentElasticsearchSourceConfig) (*Client, error)
NewClient constructs a client from the same source configuration used by signal tailing. The configured index is the only index this client can read.
func (*Client) ClearIngestScroll ¶
ClearIngestScroll releases a server-side snapshot even after Pull is canceled.
func (*Client) NextIngestScroll ¶
func (client *Client) NextIngestScroll(ctx context.Context, address, scrollID string, output any) error
NextIngestScroll reads the next page from a scroll opened by this client.
func (*Client) OpenIngestScroll ¶
func (client *Client) OpenIngestScroll(ctx context.Context, body []byte, output any) (string, error)
OpenIngestScroll starts an index-scoped snapshot and returns its route.
func (*Client) SearchIngestJSON ¶
SearchIngestJSON executes a tail search with the historical 30-second operation timeout and a bounded response budget sized for structured pages.
func (*Client) SearchIngestJSONWithPreference ¶
func (client *Client) SearchIngestJSONWithPreference(ctx context.Context, preference string, body []byte, output any) error
SearchIngestJSONWithPreference is SearchIngestJSON with an Elasticsearch `preference` routing value, so requests sharing it hit the same shard copies. An empty preference sends none.
type IndexMapping ¶
type IndexMapping struct {
Index string `json:"index"`
Fields []MappingField `json:"fields"`
TotalFields int `json:"total_fields"`
Truncated bool `json:"truncated"`
}
type IndexResult ¶
type MappingField ¶
type MappingResult ¶
type MappingResult struct {
TotalIndices int `json:"total_indices"`
Truncated bool `json:"truncated"`
AllowedFields []string `json:"allowed_fields"`
AllowedFieldsTruncated bool `json:"allowed_fields_truncated"`
Items []IndexMapping `json:"items"`
}
type SearchOptions ¶
type SearchOptions struct {
QueryBody json.RawMessage
Fields []string
Limit int
}
type SearchResult ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides provider-neutral, bounded reads for one configured source.
func NewService ¶
func NewService(cfg config.AgentElasticsearchSourceConfig) (*Service, error)
NewService constructs one source-scoped application service.
func (*Service) Config ¶
func (service *Service) Config() config.AgentElasticsearchSourceConfig
Config returns the normalized source configuration used by this service.
func (*Service) ListIndices ¶
ListIndices discovers indices matching only the configured pattern.
func (*Service) PreviewSearch ¶ added in v1.4.32
func (service *Service) PreviewSearch(options SearchOptions) (json.RawMessage, error)
func (*Service) ProjectedFields ¶
ProjectedFields returns the validated fields this source may retrieve.
func (*Service) Search ¶
func (service *Service) Search(ctx context.Context, options SearchOptions) (SearchResult, error)
func (*Service) SearchWithPrefix ¶ added in v1.4.32
func (service *Service) SearchWithPrefix(ctx context.Context, options SearchOptions) (SearchResult, error)
Search executes sanitized Query DSL and projects only configured source fields.
func (*Service) SetScrubber ¶
SetScrubber applies the shared redaction policy to every backend string before a result can cross the application-service boundary.
type ShardResult ¶
type ShardStats ¶
type ShardStats struct {
Total int `json:"total"`
Failed int `json:"failed"`
Failures []struct {
Reason struct {
Type string `json:"type"`
Reason string `json:"reason"`
} `json:"reason"`
} `json:"failures"`
}
ShardStats is the `_shards` header of a search response. Elasticsearch reports per-shard query failures (for example sorting on an unmapped field) with HTTP 200 and zero hits, so callers must check it before trusting hits.
func (ShardStats) Err ¶
func (stats ShardStats) Err() error
Err returns ErrShardFailure with the failure count and a bounded, printable first reason when any shard failed, and nil otherwise.