apmclient

package
v0.0.0-...-07f4370 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package apmclient provides an API for querying APM data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	Encoded string
}

type Client

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

func New

func New(cfg Config) (*Client, error)

New returns a new Client for querying APM data.

func (*Client) CreateAgentAPIKey

func (c *Client) CreateAgentAPIKey(ctx context.Context, expiration time.Duration) (string, error)

CreateAgentAPIKey creates an agent API Key, and returns it in the base64-encoded form that agents should provide.

If expiration is less than or equal to zero, then the API Key never expires.

func (*Client) GetElasticCloudAPMInput

func (c *Client) GetElasticCloudAPMInput(ctx context.Context) (gjson.Result, error)

GetElasticCloudAPMInput returns the APM configuration as defined in the "elastic-cloud-apm" integration policy,

func (*Client) ServiceSummary

func (c *Client) ServiceSummary(ctx context.Context, options ...Option) ([]ServiceSummary, error)

ServiceSummary returns ServiceSummary objects by aggregating `service_summary` metric sets.

type Config

type Config struct {
	// ElasticsearchURL holds the Elasticsearch URL.
	ElasticsearchURL string

	// Username holds the Elasticsearch username for basic auth.
	Username string

	// Password holds the Elasticsearch password for basic auth.
	Password string

	// APIKey holds an Elasticsearch API Key.
	//
	// This will be set from $ELASTICSEARCH_API_KEY if specified.
	APIKey string

	// APMServerURL holds the APM Server URL.
	//
	// If this is unspecified, it will be derived from
	// ElasticsearchURL if that is an Elastic Cloud URL.
	APMServerURL string

	// KibanaURL holds the Kibana URL.
	//
	// If this is unspecified, it will be derived from
	// ElasticsearchURL if that is an Elastic Cloud URL.
	KibanaURL string

	// TLSSkipVerify determines if TLS certificate
	// verification is skipped or not. Default to false.
	//
	// If not specified the value will be take from
	// TLS_SKIP_VERIFY env var.
	// Any value different from "" is considered true.
	TLSSkipVerify bool
}

func NewConfig

func NewConfig() (Config, error)

NewConfig returns a Config intialised from environment variables.

func (*Config) Finalize

func (cfg *Config) Finalize() error

Finalize finalizes cfg by setting unset fields from environment variables:

  • ElasticsearchURL is set from $ELASTICSEARCH_URL
  • Username is set from $ELASTICSEARCH_USERNAME
  • Password is set from $ELASTICSEARCH_PASSWORD
  • API Key is set from $ELASTICSEARCH_API_KEY
  • APMServerURL is set from $ELASTIC_APM_SERVER_URL
  • KibanaURL is set from $KIBANA_URL

If $ELASTIC_APM_SERVER_URL is unspecified, and ElasticsearchURL holds an Elastic Cloud-based URL, then the APM Server URL is derived from that. Likewise, the Kibana URL will be set in this way if $KIBANA_URL is unspecified.

func (*Config) InferElasticCloudURLs

func (cfg *Config) InferElasticCloudURLs() error

InferElasticCloudURLs attempts to infer a value for APMServerURL and KibanaURL (if they are empty), by checking if ElasticsearchURL matches an Elastic Cloud URL pattern, and deriving the other URLs from that.

type Option

type Option func(*options)

type ServiceSummary

type ServiceSummary struct {
	Name        string
	Environment string
	Agent       string
	Language    string
}

Jump to

Keyboard shortcuts

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