kibana

package module
v0.0.0-...-b2ac062 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: MPL-2.0 Imports: 21 Imported by: 0 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.

README

Build Status GoDoc

go-kibana

go-kibana is a go client library for kibana

Installation

go get github.com/ewilde/go-kibana

Usage

package examples

import (
	"github.com/ewilde/go-kibana"
	"github.com/stretchr/testify/assert"
)

func createSearch() (*kibana.SearchResponse, error) {
	client := kibana.NewClient(kibana.NewDefaultConfig())

	requestSearch, _ := kibana.NewSearchSourceBuilder().
		WithIndexId(client.Config.DefaultIndexId).
		WithFilter(&kibana.SearchFilter{
			Query: &kibana.SearchFilterQuery{
				Match: map[string]*kibana.SearchFilterQueryAttributes{
					"geo.src": {
						Query: "CN",
						Type:  "phrase",
					},
				},
			},
		}).
		Build()

	request, _ := kibana.NewSearchRequestBuilder().
		WithTitle("Geography filter on china with errors").
		WithDisplayColumns([]string{"_source"}).
		WithSortColumns([]string{"@timestamp"}, kibana.Descending).
		WithSearchSource(requestSearch).
		Build()

	return client.Search().Create(request)
}

func createVisualization(search *kibana.Search) (*kibana.Visualization, error) {
	client := kibana.NewClient(kibana.NewDefaultConfig())
	client.Config.KibanaVersion = kibana.DefaultKibanaVersion6

	request, _ := kibana.NewVisualizationRequestBuilder().
		WithTitle("Geography filter on china with errors").
		WithDescription("Gauge visualization based on a saved search").
		WithVisualizationState(`{"title":"Chinese search","type":"gauge","params":{"type":"gauge","addTooltip":true,"addLegend":true,"gauge":{"verticalSplit":false,"extendRange":true,"percentageMode":false,"gaugeType":"Arc","gaugeStyle":"Full","backStyle":"Full","orientation":"vertical","colorSchema":"Green to Red","gaugeColorMode":"Labels","colorsRange":[{"from":0,"to":50},{"from":50,"to":75},{"from":75,"to":100}],"invertColors":false,"labels":{"show":true,"color":"black"},"scale":{"show":true,"labels":false,"color":"#333"},"type":"meter","style":{"bgWidth":0.9,"width":0.9,"mask":false,"bgMask":false,"maskBars":50,"bgFill":"#eee","bgColor":false,"subText":"","fontSize":60,"labelColor":true}}},"aggs":[{"id":"1","enabled":true,"type":"count","schema":"metric","params":{}}]}`).
		WithSavedSearchId(search.Id).
		Build()

	return client.Visualization().Create(request)
}

By default a saved search won't display the filter on the search UI. Use the meta structure to enable this, as shown below:

image

client := DefaultTestKibanaClient()

	requestSearch, err := NewSearchSourceBuilder().
		WithIndexId(client.Config.DefaultIndexId).
		WithFilter(&SearchFilter{
			Query: &SearchFilterQuery{
				Match: map[string]*SearchFilterQueryAttributes{
					"geo.src": {
						Query: "CN",
						Type:  "phrase",
					},
				},
			},
			Meta: &SearchFilterMetaData{
				Index: client.Config.DefaultIndexId,
				Negate: false,
				Disabled: false,
				Alias: "China",
				Type: "phrase",
				Key: "geo.src",
				Value: "CN",
				Params: &SearchFilterQueryAttributes {
					Query: "CN",
					Type: "phrase",
				},
			},
		}).
		Build()

	request, err := NewSearchRequestBuilder().
		WithTitle("Geography filter on china").
		WithDisplayColumns([]string{"_source"}).
		WithSortColumns([]string{"@timestamp"}, Descending).
		WithSearchSource(requestSearch).
		Build()

	searchApi := client.Search()
	response, err := searchApi.Create(request)
All Resources and Actions

Complete examples can be found in the examples folder or in the unit tests

Developing

Running test

Logzio - running tests

example:

env ELK_VERSION=5.5.3 KIBANA_TYPE=KibanaTypeLogzio \
    KIBANA_URI="https://app-eu.logz.io" \
    ELASTIC_SEARCH_PATH="/kibana/elasticsearch/logzioCustomerKibanaIndex" \
    LOGZ_CLIENT_ID=zzedfwe3424fsdf KIBANA_USERNAME=foo@acme.com \
    LOGZ_IO_ACCOUNT_ID_1=123233 \
    LOGZ_IO_ACCOUNT_ID_2=232333
    KIBANA_PASSWORD=mypwd make fmt test

Kibana vanilla - running tests

example:

env ELK_VERSION=6.2.1 KIBANA_TYPE=KibanaTypeVanilla make
Environment variables Description
ELK_VERSION Version of ELK to run while test against logzio
KIBANA_TYPE Always KibanaTypeLogzio
KIBANA_URI Your logz.io base uri i.e. https://app-eu.logz.io/kibana-7-6
ELASTIC_SEARCH_PATH Always /kibana/elasticsearch/logzioCustomerKibanaIndex for logz.io
LOGZ_CLIENT_ID Obtained for the POST data call to https://logzio.auth0.com/oauth/ro. Use chrome developer tools when you login to logz.io to obtain this.
LOGZ_URL Optional The base URL to Logz.io, i.e https://app-eu.logz.io. Defaults to KIBANA_URI or https://app-eu.logz.io (in that order)
LOGZ_MFA_SECRET Optional One time password secret, if account requires MFA.
KIBANA_USERNAME Your logz.io username
KIBANA_PASSWORD Your logz.io password
LOGZ_IO_ACCOUNT_ID_1 Optional Your primary logz.io account id, you can obtain this from the result or GET https://app-eu.logz.io/session. If not given will not run some tests to do with switching between multiple logz.io accounts
LOGZ_IO_ACCOUNT_ID_2 Optional A secondary primary logz.io account id, you can obtain this from the result or GET https://app-eu.logz.io/session after you switch accounts in the logz.io UI. If not given will not run some tests to do with switching between multiple logz.io accounts
KIBANA_DEBUG Optional If set to any value i.e. 1 will print http request and response debug information
Adding dependencies

This project uses govendor to manage dependencies

Add /Update a package

govendor fetch github.com/owner/repo

Documentation

Index

Constants

View Source
const (
	DashboardReferencesTypeSearch        dashboardReferencesType = "search"
	DashboardReferencesTypeVisualization dashboardReferencesType = "visualization"
)

Enums for DashboardReferencesType

View Source
const (
	VisualizationReferencesTypeSearch       visualizationReferencesType = "search"
	VisualizationReferencesTypeIndexPattern visualizationReferencesType = "index-pattern"
)
View Source
const DefaultElasticSearchPath = "/es_admin/.kibana"
View Source
const DefaultKibanaIndexId = "logstash-*"
View Source
const DefaultKibanaIndexIdLogzio = "[logzioCustomerIndex]YYMMDD"
View Source
const DefaultKibanaUri = "http://localhost:5601"
View Source
const DefaultKibanaVersion = DefaultKibanaVersion6
View Source
const DefaultKibanaVersion553 = "5.5.3"
View Source
const DefaultKibanaVersion6 = "6.0.0"
View Source
const DefaultKibanaVersion7 = "7.3.1"
View Source
const DefaultLogzioClientId = "kydHH8LqsLR6D6d2dlHTpPEdf0Bztz4c"
View Source
const DefaultLogzioVersion = "6.3.2"
View Source
const EnvElasticSearchPath = "ELASTIC_SEARCH_PATH"
View Source
const EnvKibanaDebug = "KIBANA_DEBUG"
View Source
const EnvKibanaIndexId = "KIBANA_INDEX_ID"
View Source
const EnvKibanaPassword = "KIBANA_PASSWORD"
View Source
const EnvKibanaType = "KIBANA_TYPE"
View Source
const EnvKibanaUri = "KIBANA_URI"
View Source
const EnvKibanaUserName = "KIBANA_USERNAME"
View Source
const EnvKibanaVersion = "ELK_VERSION"
View Source
const EnvLogzClientId = "LOGZ_CLIENT_ID"
View Source
const EnvLogzMfaSecret = "LOGZ_MFA_SECRET"
View Source
const EnvLogzURL = "LOGZ_URL"
View Source
const (
	SearchReferencesTypeIndexPattern searchReferencesType = "index-pattern"
)

Enums for searchReferencesType

Variables

This section is empty.

Functions

func GetEnvVarOrDefault

func GetEnvVarOrDefault(key string, defaultValue string) string

func RunTestsWithContainers

func RunTestsWithContainers(m *testing.M, client *KibanaClient)

func RunTestsWithoutContainers

func RunTestsWithoutContainers(m *testing.M)

Types

type Auth0Response

type Auth0Response struct {
	IdTokens         string `json:"id_token"`
	AccessToken      string `json:"access_token"`
	TokenType        string `json:"token_type"`
	Error            string `json:"error"`
	ErrorDescription string `json:"description"`
}

type AuthenticationHandler

type AuthenticationHandler interface {
	Initialize(agent *gorequest.SuperAgent) error
	ChangeAccount(accountId string, agent *HttpAgent) error
}

type BasicAuthenticationHandler

type BasicAuthenticationHandler struct {
	// contains filtered or unexported fields
}

func NewBasicAuthentication

func NewBasicAuthentication(userName string, password string) *BasicAuthenticationHandler

func (*BasicAuthenticationHandler) ChangeAccount

func (auth *BasicAuthenticationHandler) ChangeAccount(accountId string, agent *HttpAgent) error

func (*BasicAuthenticationHandler) Initialize

func (auth *BasicAuthenticationHandler) Initialize(agent *gorequest.SuperAgent) error

type Config

type Config struct {
	Debug             bool
	DefaultIndexId    string
	ElasticSearchPath string
	KibanaBaseUri     string
	KibanaVersion     string
	KibanaType        KibanaType
	Insecure          bool
}

func NewDefaultConfig

func NewDefaultConfig() *Config

func (*Config) BuildFullPath

func (config *Config) BuildFullPath(format string, a ...interface{}) string

type CreateDashboardRequest

type CreateDashboardRequest struct {
	Attributes *DashboardAttributes   `json:"attributes"`
	References []*DashboardReferences `json:"references,omitempty"`
}

type CreateSearchRequest

type CreateSearchRequest struct {
	Attributes *SearchAttributes   `json:"attributes"`
	References []*SearchReferences `json:"references,omitempty"`
}

type CreateVisualizationRequest

type CreateVisualizationRequest struct {
	Attributes *VisualizationAttributes   `json:"attributes"`
	References []*VisualizationReferences `json:"references,omitempty"`
}

type Dashboard

type Dashboard struct {
	Id         string                 `json:"id"`
	Type       string                 `json:"type"`
	Version    version                `json:"version"`
	Attributes *DashboardAttributes   `json:"attributes"`
	References []*DashboardReferences `json:"references,omitempty"`
}

type DashboardAttributes

type DashboardAttributes struct {
	Title                 string                       `json:"title"`
	Description           string                       `json:"description"`
	Version               int                          `json:"version"`
	PanelsJson            string                       `json:"panelsJSON"`
	OptionsJson           string                       `json:"optionsJSON"`
	UiStateJSON           string                       `json:"uiStateJSON,omitempty"`
	TimeRestore           bool                         `json:"timeRestore"`
	KibanaSavedObjectMeta *SearchKibanaSavedObjectMeta `json:"kibanaSavedObjectMeta"`
}

type DashboardClient

type DashboardClient interface {
	Create(request *CreateDashboardRequest) (*Dashboard, error)
	GetById(id string) (*Dashboard, error)
	List() ([]*Dashboard, error)
	Update(id string, request *UpdateDashboardRequest) (*Dashboard, error)
	Delete(id string) error
}

type DashboardReferences

type DashboardReferences struct {
	Name string                  `json:"name"`
	Type dashboardReferencesType `json:"type"`
	Id   string                  `json:"id"`
}

type DashboardRequestBuilder

type DashboardRequestBuilder struct {
	// contains filtered or unexported fields
}

func NewDashboardRequestBuilder

func NewDashboardRequestBuilder() *DashboardRequestBuilder

func (*DashboardRequestBuilder) Build

func (*DashboardRequestBuilder) WithDescription

func (builder *DashboardRequestBuilder) WithDescription(description string) *DashboardRequestBuilder

func (*DashboardRequestBuilder) WithKibanaSavedObjectMeta

func (builder *DashboardRequestBuilder) WithKibanaSavedObjectMeta(meta *SearchKibanaSavedObjectMeta) *DashboardRequestBuilder

func (*DashboardRequestBuilder) WithOptionsJson

func (builder *DashboardRequestBuilder) WithOptionsJson(optionsJson string) *DashboardRequestBuilder

func (*DashboardRequestBuilder) WithPanelsJson

func (builder *DashboardRequestBuilder) WithPanelsJson(panelsJson string) *DashboardRequestBuilder

func (*DashboardRequestBuilder) WithReferences

func (builder *DashboardRequestBuilder) WithReferences(refs []*DashboardReferences) *DashboardRequestBuilder

func (*DashboardRequestBuilder) WithTimeRestore

func (builder *DashboardRequestBuilder) WithTimeRestore(timeRestore bool) *DashboardRequestBuilder

func (*DashboardRequestBuilder) WithTitle

func (builder *DashboardRequestBuilder) WithTitle(title string) *DashboardRequestBuilder

func (*DashboardRequestBuilder) WithUiStateJson

func (builder *DashboardRequestBuilder) WithUiStateJson(uiStateJson string) *DashboardRequestBuilder

type DefaultRoleClient

type DefaultRoleClient struct {
	// contains filtered or unexported fields
}

DefaultRoleClient structure to enable operations on Roles implements RoleClient

func (*DefaultRoleClient) CreateOrUpdate

func (api *DefaultRoleClient) CreateOrUpdate(request *Role) error

CreateOrUpdate creates or updates a role based on https://www.elastic.co/guide/en/kibana/current/role-management-api-put.html

func (*DefaultRoleClient) Delete

func (api *DefaultRoleClient) Delete(id string) error

Delete an existing Role based on https://www.elastic.co/guide/en/kibana/current/role-management-api-delete.html

func (*DefaultRoleClient) GetByID

func (api *DefaultRoleClient) GetByID(id string) (*Role, error)

GetByID fetch an existing role https://www.elastic.co/guide/en/kibana/current/role-management-api-get.html

type DefaultSpaceClient

type DefaultSpaceClient struct {
	// contains filtered or unexported fields
}

DefaultSpaceClient structure to enable operations on Spaces implements SpaceClient

func (*DefaultSpaceClient) Create

func (api *DefaultSpaceClient) Create(request *Space) error

Create creates a space based on https://www.elastic.co/guide/en/kibana/current/spaces-api-post.html

func (*DefaultSpaceClient) Delete

func (api *DefaultSpaceClient) Delete(id string) error

Delete an existing space based on https://www.elastic.co/guide/en/kibana/master/spaces-api-delete.html

func (*DefaultSpaceClient) GetByID

func (api *DefaultSpaceClient) GetByID(id string) (*Space, error)

GetByID fetch an existing space https://www.elastic.co/guide/en/kibana/master/spaces-api-get.html

func (*DefaultSpaceClient) Update

func (api *DefaultSpaceClient) Update(request *Space) error

Update updates a space based on https://www.elastic.co/guide/en/kibana/master/spaces-api-put.html

type HttpAgent

type HttpAgent struct {
	// contains filtered or unexported fields
}

func NewHttpAgent

func NewHttpAgent(config *Config, authHandler AuthenticationHandler) *HttpAgent

func (*HttpAgent) Auth

func (authClient *HttpAgent) Auth(handler AuthenticationHandler) *HttpAgent

func (*HttpAgent) Delete

func (authClient *HttpAgent) Delete(targetUrl string) *HttpAgent

func (*HttpAgent) End

func (authClient *HttpAgent) End(callback ...func(response gorequest.Response, body string, errs []error)) (gorequest.Response, string, []error)

func (*HttpAgent) Get

func (authClient *HttpAgent) Get(targetUrl string) *HttpAgent

func (*HttpAgent) Post

func (authClient *HttpAgent) Post(targetUrl string) *HttpAgent

func (*HttpAgent) Put

func (authClient *HttpAgent) Put(targetUrl string) *HttpAgent

func (*HttpAgent) Query

func (authClient *HttpAgent) Query(content interface{}) *HttpAgent

func (*HttpAgent) Send

func (authClient *HttpAgent) Send(content interface{}) *HttpAgent

func (*HttpAgent) Set

func (authClient *HttpAgent) Set(param string, value string) *HttpAgent

func (*HttpAgent) SetLogger

func (authClient *HttpAgent) SetLogger(logger *log.Logger) *HttpAgent

type HttpError

type HttpError struct {
	ErrorResponse gorequest.Response
	Code          int
	Message       string
	Body          string
}

Error represents an error response from the PagerDuty API.

func NewError

func NewError(response gorequest.Response, body string, message string) *HttpError

func (*HttpError) Error

func (e *HttpError) Error() string

type IndexPattern

type IndexPattern struct {
	Attributes *IndexPatternAttributes `json:"attributes"`
}

type IndexPatternAttributes

type IndexPatternAttributes struct {
	Title         string `json:"title"`
	TimeFieldName string `json:"timeFieldName"`
	Fields        string `json:"fields"`
}

type IndexPatternClient

type IndexPatternClient interface {
	SetDefault(indexPatternId string) error
	Create(name string) (*IndexPatternCreateResult, error)
	RefreshFields(indexPatternId string) error
}

type IndexPatternClient553

type IndexPatternClient553 struct {
	// contains filtered or unexported fields
}

func (*IndexPatternClient553) Create

func (*IndexPatternClient553) RefreshFields

func (api *IndexPatternClient553) RefreshFields(indexPatternId string) error

func (*IndexPatternClient553) SetDefault

func (api *IndexPatternClient553) SetDefault(indexPatternId string) error

type IndexPatternClient600

type IndexPatternClient600 struct {
	// contains filtered or unexported fields
}

func (*IndexPatternClient600) Create

func (*IndexPatternClient600) RefreshFields

func (api *IndexPatternClient600) RefreshFields(indexPatternId string) error

func (*IndexPatternClient600) SetDefault

func (api *IndexPatternClient600) SetDefault(indexPatternId string) error

type IndexPatternCreateResult

type IndexPatternCreateResult struct {
	Id         string                  `json:"id"`
	Type       string                  `json:"type"`
	Version    version                 `json:"version"`
	Attributes *IndexPatternAttributes `json:"attributes"`
}

type IndexPatternCreateResult553

type IndexPatternCreateResult553 struct {
	Id      string  `json:"_id"`
	Type    string  `json:"_type"`
	Version version `json:"_version"`
}

type KibanaClient

type KibanaClient struct {
	Config *Config
	// contains filtered or unexported fields
}

func DefaultTestKibanaClient

func DefaultTestKibanaClient() *KibanaClient

func NewClient

func NewClient(config *Config) *KibanaClient

func (*KibanaClient) ChangeAccount

func (kibanaClient *KibanaClient) ChangeAccount(accountId string) error

func (*KibanaClient) Dashboard

func (kibanaClient *KibanaClient) Dashboard() DashboardClient

func (*KibanaClient) IndexPattern

func (kibanaClient *KibanaClient) IndexPattern() IndexPatternClient

func (*KibanaClient) Role

func (kibanaClient *KibanaClient) Role() RoleClient

func (*KibanaClient) SavedObjects

func (kibanaClient *KibanaClient) SavedObjects() SavedObjectsClient

func (*KibanaClient) Search

func (kibanaClient *KibanaClient) Search() SearchClient

func (*KibanaClient) SetAuth

func (kibanaClient *KibanaClient) SetAuth(handler AuthenticationHandler) *KibanaClient

func (*KibanaClient) SetLogger

func (kibanaClient *KibanaClient) SetLogger(logger *log.Logger) *KibanaClient

func (*KibanaClient) Space

func (kibanaClient *KibanaClient) Space() SpaceClient

func (*KibanaClient) Visualization

func (kibanaClient *KibanaClient) Visualization() VisualizationClient

type KibanaType

type KibanaType int
const (
	KibanaTypeUnknown KibanaType = iota
	KibanaTypeVanilla
	KibanaTypeLogzio
)

func ParseKibanaType

func ParseKibanaType(value string) KibanaType

func (KibanaType) String

func (i KibanaType) String() string

type LogzAuthenticationHandler

type LogzAuthenticationHandler struct {
	Auth0Uri string
	LogzUri  string
	UserName string
	Password string
	ClientId string

	MfaSecret string
	// contains filtered or unexported fields
}

func NewLogzAuthenticationHandler

func NewLogzAuthenticationHandler(agent *gorequest.SuperAgent) *LogzAuthenticationHandler

func (*LogzAuthenticationHandler) ChangeAccount

func (auth *LogzAuthenticationHandler) ChangeAccount(accountId string, agent *HttpAgent) error

func (*LogzAuthenticationHandler) Initialize

func (auth *LogzAuthenticationHandler) Initialize(agent *gorequest.SuperAgent) error

type NoAuthenticationHandler

type NoAuthenticationHandler struct {
}

func (*NoAuthenticationHandler) ChangeAccount

func (auth *NoAuthenticationHandler) ChangeAccount(accountId string, agent *HttpAgent) error

func (*NoAuthenticationHandler) Initialize

func (auth *NoAuthenticationHandler) Initialize(agent *gorequest.SuperAgent) error

type Role

type Role struct {
	Name              string                 `json:"name,omitempty"`
	Metadata          map[string]interface{} `json:"metadata"`
	TransientMetadata map[string]interface{} `json:"transient_metadata,omitempty"`
	ElasticSearch     *RoleElasticSearch     `json:"elasticsearch"`
	Kibana            []*RoleKibana          `json:"kibana"`
}

Role is the api definition of a role in kibana can be used to create and get a role

type RoleClient

type RoleClient interface {
	CreateOrUpdate(request *Role) error
	GetByID(id string) (*Role, error)
	Delete(id string) error
}

RoleClient declares the required methods to implement to be a client and manage roles

type RoleElasticSearch

type RoleElasticSearch struct {
	Cluster []string      `json:"cluster"`
	Indices []interface{} `json:"indices"`
	RunAs   []string      `json:"run_as"`
}

type RoleKibana

type RoleKibana struct {
	Base    []string            `json:"base"`
	Feature map[string][]string `json:"feature"`
	Spaces  []string            `json:"spaces"`
}

type SavedObject

type SavedObject struct {
	Id         string                 `json:"id"`
	Type       string                 `json:"type"`
	Version    version                `json:"version"`
	Attributes map[string]interface{} `json:"attributes"`
}

type SavedObjectRequest

type SavedObjectRequest struct {
	Type    string   `json:"type" url:"type"`
	Fields  []string `json:"fields" url:"fields"`
	PerPage int      `json:"per_page" url:"per_page"`
}

type SavedObjectRequestBuilder

type SavedObjectRequestBuilder struct {
	// contains filtered or unexported fields
}

func NewSavedObjectRequestBuilder

func NewSavedObjectRequestBuilder() *SavedObjectRequestBuilder

func (*SavedObjectRequestBuilder) Build

func (*SavedObjectRequestBuilder) WithFields

func (builder *SavedObjectRequestBuilder) WithFields(fields []string) *SavedObjectRequestBuilder

func (*SavedObjectRequestBuilder) WithPerPage

func (builder *SavedObjectRequestBuilder) WithPerPage(perPage int) *SavedObjectRequestBuilder

func (*SavedObjectRequestBuilder) WithType

func (builder *SavedObjectRequestBuilder) WithType(objectType string) *SavedObjectRequestBuilder

type SavedObjectResponse

type SavedObjectResponse struct {
	Page         int            `json:"page"`
	PerPage      int            `json:"per_page"`
	Total        int            `json:"total"`
	SavedObjects []*SavedObject `json:"saved_objects"`
}

type SavedObjectsClient

type SavedObjectsClient interface {
	GetByType(request *SavedObjectRequest) (*SavedObjectResponse, error)
}
type Search struct {
	Id         string              `json:"id"`
	Type       string              `json:"type"`
	Version    version             `json:"version"`
	Attributes *SearchAttributes   `json:"attributes"`
	References []*SearchReferences `json:"references,omitempty"`
}

type SearchAttributes

type SearchAttributes struct {
	Title                 string                       `json:"title"`
	Description           string                       `json:"description"`
	Hits                  int                          `json:"hits"`
	Columns               []string                     `json:"columns"`
	Sort                  Sort                         `json:"sort"`
	Version               int                          `json:"version"`
	KibanaSavedObjectMeta *SearchKibanaSavedObjectMeta `json:"kibanaSavedObjectMeta"`
}

type SearchClient

type SearchClient interface {
	Create(request *CreateSearchRequest) (*Search, error)
	Update(id string, request *UpdateSearchRequest) (*Search, error)
	GetById(id string) (*Search, error)
	List() ([]*Search, error)
	Delete(id string) error
	NewSearchSource() SearchSourceBuilder
	Version() string
}

type SearchFilter

type SearchFilter struct {
	Query  *SearchFilterQuery    `json:"query"`
	Exists *SearchFilterExists   `json:"exists"`
	Meta   *SearchFilterMetaData `json:"meta,omitempty"`
}

type SearchFilterExists

type SearchFilterExists struct {
	Field string `json:"field"`
}

type SearchFilterMetaData

type SearchFilterMetaData struct {
	Index        string                       `json:"index"`
	IndexRefName string                       `json:"indexRefName"`
	Negate       bool                         `json:"negate"`
	Disabled     bool                         `json:"disabled"`
	Alias        string                       `json:"alias"`
	Type         string                       `json:"type"`
	Key          string                       `json:"key"`
	Value        string                       `json:"value"`
	Params       *SearchFilterQueryAttributes `json:"params"`
}

type SearchFilterQuery

type SearchFilterQuery struct {
	Match map[string]*SearchFilterQueryAttributes `json:"match"`
}

type SearchFilterQueryAttributes

type SearchFilterQueryAttributes struct {
	Query string `json:"query"`
	Type  string `json:"type"`
}

type SearchKibanaSavedObjectMeta

type SearchKibanaSavedObjectMeta struct {
	SearchSourceJSON string `json:"searchSourceJSON"`
}

type SearchQuery553

type SearchQuery553 struct {
	QueryString *searchQueryString `json:"query_string"`
}

type SearchQuery600

type SearchQuery600 struct {
	Query    string `json:"query"`
	Language string `json:"language"`
}

type SearchReferences

type SearchReferences struct {
	Name string               `json:"name"`
	Type searchReferencesType `json:"type"`
	Id   string               `json:"id"`
}

type SearchRequestBuilder

type SearchRequestBuilder struct {
	// contains filtered or unexported fields
}

func NewSearchRequestBuilder

func NewSearchRequestBuilder() *SearchRequestBuilder

func (*SearchRequestBuilder) Build

func (builder *SearchRequestBuilder) Build() (*CreateSearchRequest, error)

func (*SearchRequestBuilder) WithDescription

func (builder *SearchRequestBuilder) WithDescription(description string) *SearchRequestBuilder

func (*SearchRequestBuilder) WithDisplayColumns

func (builder *SearchRequestBuilder) WithDisplayColumns(columns []string) *SearchRequestBuilder

func (*SearchRequestBuilder) WithReferences

func (builder *SearchRequestBuilder) WithReferences(refs []*SearchReferences) *SearchRequestBuilder

func (*SearchRequestBuilder) WithSearchSource

func (builder *SearchRequestBuilder) WithSearchSource(searchSource *SearchSource) *SearchRequestBuilder

func (*SearchRequestBuilder) WithSortColumns

func (builder *SearchRequestBuilder) WithSortColumns(columns []string, order SortOrder) *SearchRequestBuilder

func (*SearchRequestBuilder) WithTitle

func (builder *SearchRequestBuilder) WithTitle(title string) *SearchRequestBuilder

type SearchSource

type SearchSource struct {
	IndexId      string          `json:"index"`
	IndexRefName string          `json:"indexRefName"`
	HighlightAll bool            `json:"highlightAll"`
	Version      bool            `json:"version"`
	Query        interface{}     `json:"query,omitempty"`
	Filter       []*SearchFilter `json:"filter"`
}

type SearchSourceBuilder

type SearchSourceBuilder interface {
	WithIndexId(indexId string) SearchSourceBuilder
	WithIndexRefName(indexRefName string) SearchSourceBuilder
	WithQuery(query string) SearchSourceBuilder
	WithFilter(filter *SearchFilter) SearchSourceBuilder
	Build() (*SearchSource, error)
}

type SearchSourceBuilderFactory

type SearchSourceBuilderFactory interface {
	NewSearchSource() SearchSourceBuilder
}

type Sort

type Sort []string

Sort allows unmarshalling different json structure for the sort field. In newer version of Kibana this can be a nested JSON array (https://github.com/elastic/kibana/pull/41918/), while in the older versions it is a flat JSON array.

func (*Sort) UnmarshalJSON

func (s *Sort) UnmarshalJSON(data []byte) error

UnmarshalJSON tries to unmarshal the json data first into a nested array and if that fails it will try to unmarshal into a slice of string

type SortOrder

type SortOrder int
const (
	Ascending SortOrder = iota
	Descending
)

type Space

type Space struct {
	Id               string   `json:"id"`
	Name             string   `json:"name"`
	Description      string   `json:"description,omitempty"`
	Color            string   `json:"color,omitempty"`
	Initials         string   `json:"initials,omitempty"`
	ImageUrl         string   `json:"imageUrl,omitempty"`
	DisabledFeatures []string `json:"disabledFeatures,omitempty"`
}

Space is the api definition of a space in kibana can be used to create, update and get a space

type SpaceClient

type SpaceClient interface {
	Create(request *Space) error
	Update(request *Space) error
	GetByID(id string) (*Space, error)
	Delete(id string) error
}

SpaceClient declares the required methods to implement to be a client and manage spaces

type UpdateDashboardRequest

type UpdateDashboardRequest struct {
	Attributes *DashboardAttributes   `json:"attributes"`
	References []*DashboardReferences `json:"references,omitempty"`
}

type UpdateSearchRequest

type UpdateSearchRequest struct {
	Attributes *SearchAttributes   `json:"attributes"`
	References []*SearchReferences `json:"references,omitempty"`
}

type UpdateVisualizationRequest

type UpdateVisualizationRequest struct {
	Attributes *VisualizationAttributes   `json:"attributes"`
	References []*VisualizationReferences `json:"references,omitempty"`
}

type Visualization

type Visualization struct {
	Id         string                     `json:"id"`
	Type       string                     `json:"type"`
	Version    version                    `json:"version"`
	Attributes *VisualizationAttributes   `json:"attributes"`
	References []*VisualizationReferences `json:"references,omitempty"`
}

type VisualizationAttributes

type VisualizationAttributes struct {
	Title                 string                       `json:"title"`
	Description           string                       `json:"description"`
	Version               int                          `json:"version"`
	VisualizationState    string                       `json:"visState"`
	SavedSearchId         string                       `json:"savedSearchId,omitempty"`
	SavedSearchRefName    string                       `json:"savedSearchRefName,omitempty"`
	KibanaSavedObjectMeta *SearchKibanaSavedObjectMeta `json:"kibanaSavedObjectMeta"`
}

type VisualizationClient

type VisualizationClient interface {
	Create(request *CreateVisualizationRequest) (*Visualization, error)
	GetById(id string) (*Visualization, error)
	List() ([]*Visualization, error)
	Update(id string, request *UpdateVisualizationRequest) (*Visualization, error)
	Delete(id string) error
}

type VisualizationReferences

type VisualizationReferences struct {
	Name string                      `json:"name"`
	Type visualizationReferencesType `json:"type"`
	Id   string                      `json:"id"`
}

type VisualizationRequestBuilder

type VisualizationRequestBuilder struct {
	// contains filtered or unexported fields
}

func NewVisualizationRequestBuilder

func NewVisualizationRequestBuilder() *VisualizationRequestBuilder

func (*VisualizationRequestBuilder) Build

func (*VisualizationRequestBuilder) WithDescription

func (builder *VisualizationRequestBuilder) WithDescription(description string) *VisualizationRequestBuilder

func (*VisualizationRequestBuilder) WithKibanaSavedObjectMeta

func (builder *VisualizationRequestBuilder) WithKibanaSavedObjectMeta(meta *SearchKibanaSavedObjectMeta) *VisualizationRequestBuilder

func (*VisualizationRequestBuilder) WithReferences

func (*VisualizationRequestBuilder) WithSavedSearchId

func (builder *VisualizationRequestBuilder) WithSavedSearchId(savedSearchId string) *VisualizationRequestBuilder

func (*VisualizationRequestBuilder) WithSavedSearchRefName

func (builder *VisualizationRequestBuilder) WithSavedSearchRefName(savedSearchRefName string) *VisualizationRequestBuilder

func (*VisualizationRequestBuilder) WithTitle

func (*VisualizationRequestBuilder) WithVisualizationState

func (builder *VisualizationRequestBuilder) WithVisualizationState(visualizationState string) *VisualizationRequestBuilder

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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