estools

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateServiceToken

func CreateServiceToken(ctx context.Context, client elastictransport.Interface, service string) (string, error)

func DeleteIndexTemplatesDataStreams

func DeleteIndexTemplatesDataStreams(ctx context.Context, client elastictransport.Interface, name string) error

DeleteIndexTemplatesDataStreams deletes any data streams, then associcated index templates.

func DeletePipelines

func DeletePipelines(ctx context.Context, client elastictransport.Interface, name string) error

DeletePipelines deletes all pipelines that match the given pattern

func GetPipelines

func GetPipelines(ctx context.Context, client elastictransport.Interface, name string) (map[string]Pipeline, error)

GetPipelines returns a list of installed pipelines that match the given name/pattern

Types

type APIKeyRequest

type APIKeyRequest struct {
	Name            string   `json:"name"`
	Expiration      string   `json:"expiration"`
	RoleDescriptors mapstr.M `json:"role_descriptors,omitempty"`
	Metadata        mapstr.M `json:"metadata,omitempty"`
}

APIKeyRequest contains the needed data to create an API key in Elasticsearch

type APIKeyResponse

type APIKeyResponse struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	Expiration int    `json:"expiration"`
	APIKey     string `json:"api_key"`
	Encoded    string `json:"encoded"`
}

APIKeyResponse contains the response data for an API request

func CreateAPIKey

CreateAPIKey creates an API key with the given request data

type CatIntData

type CatIntData int64

CatIntData represents a shard/doc/byte count in Index{}

func (*CatIntData) UnmarshalJSON

func (s *CatIntData) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the custom unmarshal JSON interface kind of dumb, but ES wraps ints in quotes, so we have to manually turn them into ints

type DataStream

type DataStream struct {
	Name      string              `json:"name"`
	Indicies  []map[string]string `json:"indicies"`
	Status    string              `json:"status"`
	Template  string              `json:"template"`
	Lifecycle Lifecycle           `json:"lifecycle"`
	Hidden    bool                `json:"hidden"`
	System    bool                `json:"system"`
}

DataStream represents a data stream template

type DataStreams

type DataStreams struct {
	DataStreams []DataStream `json:"data_streams"`
}

DataStreams represents the response from an ES _data_stream API

func GetDataStreamsForPattern

func GetDataStreamsForPattern(ctx context.Context, client elastictransport.Interface, namePattern string) (DataStreams, error)

type Documents

type Documents struct {
	Took     int  `json:"took"`
	TimedOut bool `json:"timed_out"`
	Hits     Hits `json:"hits"`
}

Documents represents the complete response from an ES query

func CheckForErrorsInLogs

func CheckForErrorsInLogs(ctx context.Context, client elastictransport.Interface, namespace string, excludeStrings []string) (Documents, error)

CheckForErrorsInLogs checks to see if any error-level lines exist excludeStrings can be used to remove any particular error strings from logs

func CheckForErrorsInLogsWithContext

func CheckForErrorsInLogsWithContext(ctx context.Context, client elastictransport.Interface, namespace string, excludeStrings []string) (Documents, error)

CheckForErrorsInLogsWithContext checks to see if any error-level lines exist excludeStrings can be used to remove any particular error strings from logs

func FindMatchingLogLines

func FindMatchingLogLines(ctx context.Context, client elastictransport.Interface, namespace, line string) (Documents, error)

FindMatchingLogLines returns any logs with message fields that match the given line

func FindMatchingLogLinesForAgentWithContext

func FindMatchingLogLinesForAgentWithContext(ctx context.Context, client elastictransport.Interface, agentID, line string) (Documents, error)

FindMatchingLogLinesForAgentWithContext returns the matching `message` line field for an agent with the matching ID

func FindMatchingLogLinesWithContext

func FindMatchingLogLinesWithContext(ctx context.Context, client elastictransport.Interface, namespace, line string) (Documents, error)

FindMatchingLogLinesWithContext returns any logs with message fields that match the given line

func GetAllLogsForIndexWithContext

func GetAllLogsForIndexWithContext(ctx context.Context, client elastictransport.Interface, index string) (Documents, error)

GetAllLogsForIndexWithContext returns all logs for a given index

func GetLatestDocumentMatchingQuery

func GetLatestDocumentMatchingQuery(ctx context.Context, client elastictransport.Interface, query map[string]interface{}, indexPattern string) (Documents, error)

GetLatestDocumentMatchingQuery returns the last document that matches the given query. the query field is inserted into a simple `query` POST request

func GetLogsForAgentID

func GetLogsForAgentID(ctx context.Context, client elastictransport.Interface, id string) (Documents, error)

GetLogsForAgentID returns any logs associated with the agent ID

func GetLogsForDataset

func GetLogsForDataset(ctx context.Context, client elastictransport.Interface, index string) (Documents, error)

GetLogsForDataset returns any logs associated with the datastream

func GetLogsForDatasetWithContext

func GetLogsForDatasetWithContext(ctx context.Context, client elastictransport.Interface, index string) (Documents, error)

GetLogsForDatasetWithContext returns any logs associated with the datastream

func GetLogsForDatastream

func GetLogsForDatastream(
	ctx context.Context,
	client elastictransport.Interface,
	dsType, dataset, namespace string) (Documents, error)

GetLogsForDatastream returns any logs associated with the datastream

func GetLogsForIndexWithContext

func GetLogsForIndexWithContext(ctx context.Context, client elastictransport.Interface, index string, match map[string]interface{}) (Documents, error)

GetLogsForIndexWithContext returns any logs that match the given condition

func GetResultsForAgentAndDatastream

func GetResultsForAgentAndDatastream(ctx context.Context, client elastictransport.Interface, dataset string, agentID string) (Documents, error)

GetResultsForAgentAndDatastream returns any documents match both the given agent ID and data stream

func PerformQueryForRawQuery

func PerformQueryForRawQuery(ctx context.Context, queryRaw map[string]interface{}, index string, client elastictransport.Interface) (Documents, error)

PerformQueryForRawQuery executes the ES query specified by queryRaw

type ESDoc

type ESDoc struct {
	Index  string                 `json:"_index"`
	Score  float64                `json:"_score"`
	Source map[string]interface{} `json:"_source"`
}

ESDoc contains the documents returned by an ES query

type Hits

type Hits struct {
	Hits  []ESDoc       `json:"hits"`
	Total TotalDocCount `json:"total"`
}

Hits returns the matching documents from an ES query

type Index

type Index struct {
	Health                string     `json:"health"`
	Status                string     `json:"status"`
	Index                 string     `json:"index"`
	UUID                  string     `json:"uuid"`
	Primary               CatIntData `json:"pri"`
	Replicated            CatIntData `json:"rep"`
	DocsCount             CatIntData `json:"docs.count"`
	DocsDeleted           CatIntData `json:"docs.deleted"`
	StoreSizeBytes        CatIntData `json:"store.size"`
	PrimaryStoreSizeBytes CatIntData `json:"pri.store.size"`
}

Index is the data associated with a single index from _cat/indicies

func GetAllindicies

func GetAllindicies(ctx context.Context, client elastictransport.Interface) ([]Index, error)

GetAllindicies returns a list of indicies on the target ES instance

func GetIndicesWithContext

func GetIndicesWithContext(ctx context.Context, client elastictransport.Interface, indicies []string) ([]Index, error)

GetIndicesWithContext returns a list of indicies on the target ES instance with the provided context

type Lifecycle

type Lifecycle struct {
	Enabled       bool   `json:"enabled"`
	DataRetention string `json:"data_retention"`
}

type Ping

type Ping struct {
	Name        string  `json:"name"`
	ClusterName string  `json:"cluster_name"`
	ClusterUUID string  `json:"cluster_uuid"`
	Version     Version `json:"version"`
}

Ping returns basic ES info

func GetPing

func GetPing(ctx context.Context, client elastictransport.Interface) (Ping, error)

GetPing performs a basic ping and returns ES config info

type Pipeline

type Pipeline struct {
	Description string                   `json:"description"`
	Processors  []map[string]interface{} `json:"processors"`
}

Pipeline is an individual pipeline

type Template

type Template struct {
	Name          string                 `json:"name"`
	IndexTemplate map[string]interface{} `json:"index_template"`
}

Template is an individual template

type TemplateResponse

type TemplateResponse struct {
	IndexTemplates []Template `json:"index_templates"`
}

TemplateResponse is the body of a template data request

func GetIndexTemplatesForPattern

func GetIndexTemplatesForPattern(ctx context.Context, client elastictransport.Interface, name string) (TemplateResponse, error)

GetIndexTemplatesForPattern lists all index templates on the system

type TotalDocCount

type TotalDocCount struct {
	Value    int    `json:"value"`
	Relation string `json:"relation"`
}

TotalDocCount contains metadata for the ES response

type Version

type Version struct {
	Number      string `json:"number"`
	BuildFlavor string `json:"build_flavor"`
}

Version contains version and build info from an ES ping

Jump to

Keyboard shortcuts

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