kibana

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: Apache-2.0 Imports: 24 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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"`
}

AgentCommon represents common agent data used across APIs

type AgentExisting added in v0.3.9

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

AgentExisting is the data structure for an existing agent

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"`
}

AgentPolicy is the JSON that represents a agent policy. These fields are used by both the create policy request, and the GET request for an agent policy. see: https://github.com/elastic/kibana/blob/v8.8.0/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy_create_request.yaml and https://github.com/elastic/kibana/blob/v8.8.0/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml

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"`
}

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. See https://github.com/elastic/kibana/blob/v8.8.0/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy_update_request.yaml

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) CreateEnrollmentAPIKey added in v0.3.8

func (client *Client) CreateEnrollmentAPIKey(request CreateEnrollmentAPIKeyRequest) (*CreateEnrollmentAPIKeyResponse, error)

CreateEnrollmentAPIKey creates an enrollment API key

func (*Client) CreatePolicy added in v0.3.8

func (client *Client) CreatePolicy(request AgentPolicy) (*PolicyResponse, error)

CreatePolicy creates a new agent policy with the given config

func (*Client) DeletePolicy added in v0.3.9

func (client *Client) DeletePolicy(id string) error

DeletePolicy deletes the policy with the given ID

func (*Client) GetAgent added in v0.3.9

func (client *Client) GetAgent(request GetAgentRequest) (*GetAgentResponse, error)

GetAgent fetches data for an agent

func (*Client) GetFleetServerHost added in v0.3.9

func (client *Client) GetFleetServerHost(request GetFleetServerHostRequest) (*GetFleetServerHostResponse, error)

GetFleetServerHost returns data on a fleet server

func (*Client) GetPolicy added in v0.3.9

func (client *Client) GetPolicy(id string) (*PolicyResponse, error)

GetPolicy returns the requested 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) ListAgents added in v0.3.8

func (client *Client) ListAgents(_ ListAgentsRequest) (*ListAgentsResponse, error)

ListAgents returns a list of agents known to Kibana

func (*Client) ListFleetServerHosts added in v0.3.9

func (client *Client) ListFleetServerHosts(_ ListFleetServerHostsRequest) (*ListFleetServerHostsResponse, error)

ListFleetServerHosts returns a list of fleet server hosts

func (*Client) UnEnrollAgent added in v0.3.8

func (client *Client) UnEnrollAgent(request UnEnrollAgentRequest) (*UnEnrollAgentResponse, error)

UnEnrollAgent removes the agent from fleet

func (*Client) UpdatePolicy added in v0.3.9

func (client *Client) UpdatePolicy(ID string, request AgentPolicyUpdateRequest) (*PolicyResponse, error)

UpdatePolicy updates an existing agent policy.

func (*Client) UpgradeAgent added in v0.3.8

func (client *Client) UpgradeAgent(request UpgradeAgentRequest) (*UpgradeAgentResponse, 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"`
}

CreateEnrollmentAPIKeyRequest is the JSON object for requesting an enrollment API key

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"`
}

CreateEnrollmentAPIKeyResponse is the JSON response the an enrollment key request

type FleetServerHost added in v0.3.9

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

FleetServerHost handles JSON data for fleet server info

type GetAgentRequest added in v0.3.9

type GetAgentRequest struct {
	ID string
}

GetAgentRequest contains the ID used for fetching agent data

type GetAgentResponse added in v0.3.9

type GetAgentResponse AgentExisting

GetAgentResponse is the JSON response for GetAgent

type GetFleetServerHostRequest added in v0.3.9

type GetFleetServerHostRequest struct {
	ID string
}

GetFleetServerHostRequest is the ID for a request via GetFleetServerHost

type GetFleetServerHostResponse added in v0.3.9

type GetFleetServerHostResponse FleetServerHost

GetFleetServerHostResponse is the JSON respose from GetFleetServerHost

type ListAgentsRequest added in v0.3.8

type ListAgentsRequest struct {
}

ListAgentsRequest is currently unused

type ListAgentsResponse added in v0.3.8

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

ListAgentsResponse is a list of agents returned by the API

type ListFleetServerHostsRequest added in v0.3.9

type ListFleetServerHostsRequest struct {
}

ListFleetServerHostsRequest is currently unused

type ListFleetServerHostsResponse added in v0.3.9

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

ListFleetServerHostsResponse is the JSON response for ListFleetServerHosts

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 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"`
}

PolicyResponse is the response JSON from a policy request This is returned on a GET request for a policy, and on a policy create request See https://github.com/elastic/kibana/blob/v8.8.0/x-pack/plugins/fleet/common/openapi/paths/agent_policies.yaml

type UnEnrollAgentRequest added in v0.3.8

type UnEnrollAgentRequest struct {
	ID     string `json:"id"`
	Revoke bool   `json:"revoke"`
}

UnEnrollAgentRequest is the JSON request for unenrolling an agent

type UnEnrollAgentResponse added in v0.3.8

type UnEnrollAgentResponse struct {
}

UnEnrollAgentResponse is currently unused

type UpgradeAgentRequest added in v0.3.8

type UpgradeAgentRequest struct {
	ID      string `json:"id"`
	Version string `json:"version"`
}

UpgradeAgentRequest is the JSON request for an agent upgrade

type UpgradeAgentResponse added in v0.3.8

type UpgradeAgentResponse struct {
}

UpgradeAgentResponse is currently unused

Jump to

Keyboard shortcuts

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