kibana

package
v0.17.4 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 24 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TRUE  *bool = &bt
	FALSE *bool = &bf
)

Constant booleans for convenience for dealing with *bool

Functions

func EncodeURLParams

func EncodeURLParams(url string, params url.Values) string

func MakeURL

func MakeURL(defaultScheme string, defaultPath string, rawURL string, defaultPort int) (string, error)

MakeURL creates the url based on the url configuration. Adds missing parts with defaults (scheme, host, port)

func ParseURL

func ParseURL(raw string, hints ...ParseHint) (*url.URL, error)

ParseURL tries to parse a URL and return the parsed result.

Types

type AgentCommon added in v0.3.9

type AgentCommon struct {
	Active bool   `json:"active"`
	Status string `json:"status"`
	Agent  struct {
		ID      string `json:"id"`
		Version string `json:"version"`
	} `json:"agent"`
	LocalMetadata struct {
		Host struct {
			Hostname string `json:"hostname"`
		} `json:"host"`
	} `json:"local_metadata"`
	PolicyID       string               `json:"policy_id"`
	PolicyRevision int                  `json:"policy_revision"`
	UpgradeDetails *AgentUpgradeDetails `json:"upgrade_details"`
}

AgentCommon represents common agent data used across Agent APIs

type AgentExisting added in v0.3.9

type AgentExisting struct {
	ID          string `json:"id"`
	AgentCommon `json:",inline"`
}

type AgentPolicy added in v0.3.9

type AgentPolicy struct {
	ID string `json:"id,omitempty"`
	// Name of the policy. Required to create a policy.
	Name string `json:"name"`
	// Namespace of the policy. Required to create a policy.
	Namespace          string                    `json:"namespace"`
	Description        string                    `json:"description,omitempty"`
	MonitoringEnabled  []MonitoringEnabledOption `json:"monitoring_enabled,omitempty"`
	DataOutputID       string                    `json:"data_output_id,omitempty"`
	MonitoringOutputID string                    `json:"monitoring_output_id,omitempty"`
	FleetServerHostID  string                    `json:"fleet_server_host_id,omitempty"`
	DownloadSourceID   string                    `json:"download_source_id,omitempty"`
	UnenrollTimeout    int                       `json:"unenroll_timeout,omitempty"`
	InactivityTImeout  int                       `json:"inactivity_timeout,omitempty"`
	AgentFeatures      []map[string]interface{}  `json:"agent_features,omitempty"`
	Overrides          map[string]interface{}    `json:"overrides,omitempty"`
	IsProtected        bool                      `json:"is_protected"`
}

type AgentPolicyUpdateRequest added in v0.3.9

type AgentPolicyUpdateRequest struct {
	// Name of the policy. Required in an update request.
	Name string `json:"name"`
	// Namespace of the policy. Required in an update request.
	Namespace          string                    `json:"namespace"`
	Description        string                    `json:"description,omitempty"`
	MonitoringEnabled  []MonitoringEnabledOption `json:"monitoring_enabled,omitempty"`
	DataOutputID       string                    `json:"data_output_id,omitempty"`
	MonitoringOutputID string                    `json:"monitoring_output_id,omitempty"`
	FleetServerHostID  string                    `json:"fleet_server_host_id,omitempty"`
	DownloadSourceID   string                    `json:"download_source_id,omitempty"`
	UnenrollTimeout    int                       `json:"unenroll_timeout,omitempty"`
	InactivityTImeout  int                       `json:"inactivity_timeout,omitempty"`
	AgentFeatures      []map[string]interface{}  `json:"agent_features,omitempty"`
	Overrides          map[string]interface{}    `json:"overrides,omitempty"`
	IsProtected        *bool                     `json:"is_protected,omitempty"` // Optional bool for compatibility with the older pre 8.9.0 stack
}

AgentPolicyUpdateRequest is the JSON object for requesting an updated policy Unlike the Agent create and response structures, the update request does not contain an ID field.

type AgentUpgradeDetails added in v0.6.3

type AgentUpgradeDetails struct {
	TargetVersion string `json:"target_version"`
	State         string `json:"state"`
	ActionID      string `json:"action_id"`
	Metadata      struct {
		ScheduledAt     *time.Time           `json:"scheduled_at"`
		DownloadPercent float64              `json:"download_percent"`
		DownloadRate    details.DownloadRate `json:"download_rate"`
		FailedState     string               `json:"failed_state"`
		ErrorMsg        string               `json:"error_msg"`
	} `json:"metadata"`
}

type Client

type Client struct {
	Connection
	// contains filtered or unexported fields
}

func NewClientWithConfig

func NewClientWithConfig(config *ClientConfig, binaryName, version, commit, buildtime string) (*Client, error)

NewClientWithConfig creates and returns a kibana client using the given config

func NewClientWithConfigDefault

func NewClientWithConfigDefault(config *ClientConfig, defaultPort int, binaryName, version, commit, buildtime string) (*Client, error)

NewClientWithConfigDefault creates and returns a kibana client using the given config

func NewKibanaClient

func NewKibanaClient(cfg *config.C, binaryName, version, commit, buildtime string) (*Client, error)

NewKibanaClient builds and returns a new Kibana client

func (*Client) Close

func (client *Client) Close() error

func (*Client) CreateDownloadSource added in v0.6.3

func (client *Client) CreateDownloadSource(ctx context.Context, source DownloadSource) (DownloadSourceResponse, error)

func (*Client) CreateEnrollmentAPIKey added in v0.3.8

func (client *Client) CreateEnrollmentAPIKey(ctx context.Context, request CreateEnrollmentAPIKeyRequest) (r CreateEnrollmentAPIKeyResponse, err error)

CreateEnrollmentAPIKey creates an enrollment API key

func (*Client) CreateFleetProxy added in v0.17.0

func (client *Client) CreateFleetProxy(ctx context.Context, req ProxiesRequest) (ProxiesResponse, error)

CreateFleetProxy creates a new proxy

func (*Client) CreateFleetServerHosts added in v0.17.0

func (client *Client) CreateFleetServerHosts(ctx context.Context, req ListFleetServerHostsRequest) (FleetServerHostsResponse, error)

CreateFleetServerHosts creates a new Fleet Server host

func (*Client) CreatePolicy added in v0.3.8

func (client *Client) CreatePolicy(ctx context.Context, request AgentPolicy) (r PolicyResponse, err error)

CreatePolicy creates a new agent policy with the given config

func (*Client) DeleteFleetPackage added in v0.3.10

func (client *Client) DeleteFleetPackage(ctx context.Context, packagePolicyID string) (r DeletePackagePolicyResponse, err error)

DeleteFleetPackage deletes integration with packagePolicyID from the policy ID

func (*Client) DeletePolicy added in v0.3.9

func (client *Client) DeletePolicy(ctx context.Context, id string) error

DeletePolicy deletes the policy with the given ID

func (*Client) GetAgent added in v0.3.9

func (client *Client) GetAgent(ctx context.Context, request GetAgentRequest) (r GetAgentResponse, err error)

GetAgent fetches data for an agent

func (*Client) GetFleetServerHost added in v0.3.9

func (client *Client) GetFleetServerHost(ctx context.Context, request GetFleetServerHostRequest) (r GetFleetServerHostResponse, err error)

func (*Client) GetPolicy added in v0.3.9

func (client *Client) GetPolicy(ctx context.Context, id string) (r PolicyResponse, err error)

GetPolicy returns the policy with 'policy_id' id.

func (*Client) GetPolicyUninstallTokens added in v0.3.10

func (client *Client) GetPolicyUninstallTokens(ctx context.Context, policyID string) (r UninstallTokenResponse, err error)

GetPolicyUninstallTokens Retrieves the policy uninstall tokens

func (*Client) GetUninstallToken added in v0.3.10

func (client *Client) GetUninstallToken(ctx context.Context, tokenID string) (r UninstallTokenItem, err error)

GetUninstallToken return uninstall token value for the given token ID

func (*Client) GetVersion

func (client *Client) GetVersion() version.V

GetVersion returns the version read from kibana. The version is not set if IgnoreVersion was set when creating the client.

func (*Client) ImportMultiPartFormFile

func (client *Client) ImportMultiPartFormFile(url string, params url.Values, filename string, contents string) error

func (*Client) InstallFleetPackage added in v0.3.10

func (client *Client) InstallFleetPackage(ctx context.Context, req PackagePolicyRequest) (r PackagePolicyResponse, err error)

InstallFleetPackage uses the Fleet package policies API install an integration package as specified in the request. Note that the package policy ID and Name must be globally unique across all installed packages.

func (*Client) KibanaIsServerless added in v0.4.0

func (client *Client) KibanaIsServerless() (bool, error)

KibanaIsServerless returns true if we're talking to a serverless instance.

func (*Client) ListAgents added in v0.3.8

func (client *Client) ListAgents(ctx context.Context, _ ListAgentsRequest) (r ListAgentsResponse, err error)

ListAgents returns a list of agents known to Kibana

func (*Client) ListFleetServerHosts added in v0.3.9

func (client *Client) ListFleetServerHosts(ctx context.Context, _ ListFleetServerHostsRequest) (r ListFleetServerHostsResponse, err error)

ListFleetServerHosts returns a list of fleet server hosts

func (*Client) UnEnrollAgent added in v0.3.8

func (client *Client) UnEnrollAgent(ctx context.Context, request UnEnrollAgentRequest) (r UnEnrollAgentResponse, err error)

UnEnrollAgent removes the agent from fleet

func (*Client) UpdatePolicy added in v0.3.9

func (client *Client) UpdatePolicy(ctx context.Context, id string, request AgentPolicyUpdateRequest) (r PolicyResponse, err error)

UpdatePolicy updates an existing agent policy.

func (*Client) UpgradeAgent added in v0.3.8

func (client *Client) UpgradeAgent(ctx context.Context, request UpgradeAgentRequest) (r UpgradeAgentResponse, err error)

UpgradeAgent upgrades the requested agent

type ClientConfig

type ClientConfig struct {
	Protocol     string `config:"protocol" yaml:"protocol,omitempty"`
	Host         string `config:"host" yaml:"host,omitempty"`
	Path         string `config:"path" yaml:"path,omitempty"`
	SpaceID      string `config:"space.id" yaml:"space.id,omitempty"`
	Username     string `config:"username" yaml:"username,omitempty"`
	Password     string `config:"password" yaml:"password,omitempty"`
	APIKey       string `config:"api_key" yaml:"api_key,omitempty"`
	ServiceToken string `config:"service_token" yaml:"service_token,omitempty"`

	// Headers holds headers to include in every request sent to Kibana.
	Headers map[string]string `config:"headers" yaml:"headers,omitempty"`

	IgnoreVersion bool

	Transport httpcommon.HTTPTransportSettings `config:",inline" yaml:",inline"`
}

ClientConfig to connect to Kibana

func DefaultClientConfig

func DefaultClientConfig() ClientConfig

DefaultClientConfig connects to a locally running kibana over HTTP

func (*ClientConfig) Validate

func (c *ClientConfig) Validate() error

type Connection

type Connection struct {
	URL          string
	Username     string
	Password     string
	APIKey       string
	ServiceToken string
	Headers      http.Header

	HTTP    *http.Client
	Version version.V
}

func (*Connection) Request

func (conn *Connection) Request(method, extraPath string,
	params url.Values, headers http.Header, body io.Reader) (int, []byte, error)

func (*Connection) RoundTrip

func (conn *Connection) RoundTrip(r *http.Request) (*http.Response, error)

Implements RoundTrip interface

func (*Connection) Send

func (conn *Connection) Send(method, extraPath string,
	params url.Values, headers http.Header, body io.Reader) (*http.Response, error)

Send an application/json request to Kibana with appropriate kbn headers

func (*Connection) SendWithContext

func (conn *Connection) SendWithContext(ctx context.Context, method, extraPath string,
	params url.Values, headers http.Header, body io.Reader) (*http.Response, error)

SendWithContext sends an application/json request to Kibana with appropriate kbn headers and the given context.

type CreateEnrollmentAPIKeyRequest added in v0.3.8

type CreateEnrollmentAPIKeyRequest struct {
	Name     string `json:"name"`
	PolicyID string `json:"policy_id"`
}

type CreateEnrollmentAPIKeyResponse added in v0.3.8

type CreateEnrollmentAPIKeyResponse struct {
	Active   bool   `json:"active"`
	APIKey   string `json:"api_key"`
	APIKeyID string `json:"api_key_id"`
	ID       string `json:"id"`
	Name     string `json:"name"`
	PolicyID string `json:"policy_id"`
}

type DeletePackagePolicyResponse added in v0.3.10

type DeletePackagePolicyResponse struct {
	ID string `json:"id"`
}

type DownloadSource added in v0.6.3

type DownloadSource struct {
	Name      string      `json:"name"`
	Host      string      `json:"host"`
	IsDefault bool        `json:"is_default"`
	ProxyID   interface{} `json:"proxy_id"`
}

type DownloadSourceResponse added in v0.7.1

type DownloadSourceResponse struct {
	Item struct {
		ID        string `json:"id"`
		Name      string `json:"name"`
		Host      string `json:"host"`
		IsDefault bool   `json:"is_default"`
		ProxyID   string `json:"proxy_id"`
	} `json:"item"`
}

type FleetServerHost added in v0.3.9

type FleetServerHost struct {
	ID              string   `json:"id"`
	Name            string   `json:"name"`
	HostURLs        []string `json:"host_urls"`
	IsDefault       bool     `json:"is_default"`
	IsInternal      bool     `json:"is_internal"`
	IsPreconfigured bool     `json:"is_preconfigured"`
	ProxyID         string   `json:"proxy_id"`
}

type FleetServerHostsResponse added in v0.17.0

type FleetServerHostsResponse struct {
	Item struct {
		ID              string   `json:"id"`
		HostUrls        []string `json:"host_urls"`
		IsDefault       bool     `json:"is_default"`
		IsInternal      bool     `json:"is_internal"`
		IsPreconfigured bool     `json:"is_preconfigured"`
		Name            string   `json:"name"`
		ProxyID         string   `json:"proxy_id"`
	} `json:"item"`
}

type GetAgentRequest added in v0.3.9

type GetAgentRequest struct {
	ID string
}

type GetAgentResponse added in v0.3.9

type GetAgentResponse AgentExisting

type GetFleetServerHostRequest added in v0.3.9

type GetFleetServerHostRequest struct {
	ID string
}

type GetFleetServerHostResponse added in v0.3.9

type GetFleetServerHostResponse FleetServerHost

type ListAgentsRequest added in v0.3.8

type ListAgentsRequest struct {
}

type ListAgentsResponse added in v0.3.8

type ListAgentsResponse struct {
	Items []AgentExisting `json:"items"`
}

type ListFleetServerHostsRequest added in v0.3.9

type ListFleetServerHostsRequest struct {
	HostURLs   []string `json:"host_urls"`
	ID         string   `json:"id"`
	IsDefault  bool     `json:"is_default"`
	IsInternal bool     `json:"is_internal"`
	Name       string   `json:"name"`
	ProxyID    string   `json:"proxy_id"`
}

type ListFleetServerHostsResponse added in v0.3.9

type ListFleetServerHostsResponse struct {
	Items []FleetServerHost `json:"items"`
}

type MonitoringEnabledOption added in v0.3.8

type MonitoringEnabledOption string

MonitoringEnabledOption is a Kibana JSON value that specifies the various monitoring option types

const (
	// MonitoringEnabledLogs specifies log monitoring
	MonitoringEnabledLogs MonitoringEnabledOption = "logs"
	// MonitoringEnabledMetrics specifies metrics monitoring
	MonitoringEnabledMetrics MonitoringEnabledOption = "metrics"
)

type PackagePolicy added in v0.3.10

type PackagePolicy struct {
	ID          string                      `json:"id,omitempty"`
	Revision    int                         `json:"revision"`
	Enabled     bool                        `json:"enabled"`
	Inputs      []map[string]interface{}    `json:"inputs"`
	Package     PackagePolicyRequestPackage `json:"package"`
	Namespace   string                      `json:"namespace"`
	OutputID    string                      `json:"output_id"`
	PolicyID    string                      `json:"policy_id"`
	Name        string                      `json:"name"`
	Description string                      `json:"description"`
}

type PackagePolicyRequest added in v0.3.10

type PackagePolicyRequest struct {
	ID        string                      `json:"id,omitempty"`
	Name      string                      `json:"name"`
	Namespace string                      `json:"namespace"`
	PolicyID  string                      `json:"policy_id"`
	Package   PackagePolicyRequestPackage `json:"package"`
	Vars      map[string]interface{}      `json:"vars"`
	Inputs    []map[string]interface{}    `json:"inputs"`
	Force     bool                        `json:"force"`
}

type PackagePolicyRequestPackage added in v0.3.10

type PackagePolicyRequestPackage struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

type PackagePolicyResponse added in v0.3.10

type PackagePolicyResponse struct {
	Item PackagePolicy `json:"item"`
}

type ParseHint

type ParseHint func(raw string) string

func WithDefaultScheme

func WithDefaultScheme(scheme string) ParseHint

type PolicyResponse added in v0.3.9

type PolicyResponse struct {
	AgentPolicy     `json:",inline"`
	UpdatedOn       time.Time                `json:"updated_on"`
	UpdatedBy       string                   `json:"updated_by"`
	Revision        int                      `json:"revision"`
	IsProtected     bool                     `json:"is_protected"`
	PackagePolicies []map[string]interface{} `json:"package_policies"`
}

type ProxiesRequest added in v0.17.0

type ProxiesRequest struct {
	Certificate            string            `json:"certificate"`
	CertificateAuthorities string            `json:"certificate_authorities"`
	CertificateKey         string            `json:"certificate_key"`
	ID                     string            `json:"id"`
	Name                   string            `json:"name"`
	ProxyHeaders           map[string]string `json:"proxy_headers"`
	URL                    string            `json:"url"`
}

type ProxiesResponse added in v0.17.0

type ProxiesResponse struct {
	Item struct {
		Certificate            string            `json:"certificate"`
		CertificateAuthorities string            `json:"certificate_authorities"`
		CertificateKey         string            `json:"certificate_key"`
		ID                     string            `json:"id"`
		IsPreconfigured        bool              `json:"is_preconfigured"`
		Name                   string            `json:"name"`
		ProxyHeaders           map[string]string `json:"proxy_headers"`
		URL                    string            `json:"url"`
	} `json:"item"`
}

type UnEnrollAgentRequest added in v0.3.8

type UnEnrollAgentRequest struct {
	ID     string `json:"-"` // ID is not part of the request body send to the Fleet API
	Revoke bool   `json:"revoke"`
}

type UnEnrollAgentResponse added in v0.3.8

type UnEnrollAgentResponse struct {
}

type UninstallTokenItem added in v0.3.10

type UninstallTokenItem struct {
	ID        string `json:"id"`
	PolicyID  string `json:"policy_id"`
	Token     string `json:"token"`
	CreatedAt string `json:"created_at"`
}

type UninstallTokenResponse added in v0.3.10

type UninstallTokenResponse struct {
	Items   []UninstallTokenItem `json:"items"`
	Total   int                  `json:"total"`
	Page    int                  `json:"page"`
	PerPage int                  `json:"perPage"`
}

type UpgradeAgentRequest added in v0.3.8

type UpgradeAgentRequest struct {
	ID        string `json:"-"` // ID is not part of the request body send to the Fleet API
	Version   string `json:"version"`
	SourceURI string `json:"source_uri"`
	Force     bool   `json:"force"`
}

type UpgradeAgentResponse added in v0.3.8

type UpgradeAgentResponse struct {
}

Jump to

Keyboard shortcuts

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