dynatrace

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PaasToken       = "paasToken"
	ApiToken        = "apiToken"
	DataIngestToken = "dataIngestToken"
)
View Source
const (
	InstallerTypeDefault = "default"
	InstallerTypePaaS    = "paas"
)

Relevant installer types.

View Source
const (
	TokenScopeInstallerDownload     = "InstallerDownload"
	TokenScopeDataExport            = "DataExport"
	TokenScopeMetricsIngest         = "metrics.ingest"
	TokenScopeEntitiesRead          = "entities.read"
	TokenScopeSettingsRead          = "settings.read"
	TokenScopeSettingsWrite         = "settings.write"
	TokenScopeActiveGateTokenCreate = "activeGateTokenManagement.create"
)

Relevant token scopes

View Source
const (
	KubernetesSettingsSchemaId = "builtin:cloud.kubernetes"
	AppTransitionSchemaId      = "builtin:app-transition.kubernetes"
)
View Source
const ApiTokenHeader = "Api-Token "
View Source
const (
	MarkedForTerminationEvent = "MARKED_FOR_TERMINATION"
)
View Source
const (
	MetadataEnrichmentSettingsSchemaId = "builtin:kubernetes.generic.metadata.enrichment"
)
View Source
const (
	OsUnix = "unix"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveGateAuthTokenInfo

type ActiveGateAuthTokenInfo struct {
	TokenId string `json:"id"`
	Token   string `json:"token"`
}

type ActiveGateAuthTokenParams

type ActiveGateAuthTokenParams struct {
	Name           string `json:"name"`
	ActiveGateType string `json:"activeGateType"`
	ExpirationDate string `json:"expirationDate"`
	SeedToken      bool   `json:"seedToken"`
}

type ActiveGateConnectionInfo

type ActiveGateConnectionInfo struct {
	ConnectionInfo
}

type Client

type Client interface {
	// GetLatestAgentVersion gets the latest agent version for the given OS and installer type.
	// Returns the version as received from the server on success.
	//
	// Returns an error for the following conditions:
	//  - os or installerType is empty
	//  - IO error or unexpected response
	//  - error response from the server (e.g. authentication failure)
	//  - the agent version is not set or empty
	GetLatestAgentVersion(ctx context.Context, os, installerType string) (string, error)

	// GetLatestAgent returns a reader with the contents of the download. Must be closed by caller.
	GetLatestAgent(ctx context.Context, os, installerType, flavor, arch string, technologies []string, skipMetadata bool, writer io.Writer) error

	// GetAgent downloads a specific agent version and writes it to the given io.Writer
	GetAgent(ctx context.Context, os, installerType, flavor, arch, version string, technologies []string, skipMetadata bool, writer io.Writer) error

	// GetAgentViaInstallerUrl downloads the agent from the user specified URL and writes it to the given io.Writer
	GetAgentViaInstallerUrl(ctx context.Context, url string, writer io.Writer) error

	// GetAgentVersions on success returns an array of versions that can be used with GetAgent to
	// download a specific agent version
	GetAgentVersions(ctx context.Context, os, installerType, flavor, arch string) ([]string, error)

	GetOneAgentConnectionInfo(ctx context.Context) (OneAgentConnectionInfo, error)

	GetProcessModuleConfig(ctx context.Context, prevRevision uint) (*ProcessModuleConfig, error)

	// GetCommunicationHostForClient returns a CommunicationHost for the client's API URL. Or error, if failed to be parsed.
	GetCommunicationHostForClient() (CommunicationHost, error)

	// SendEvent posts events to dynatrace API
	SendEvent(ctx context.Context, eventData *EventData) error

	// GetEntityIDForIP returns the entity id for a given IP address.
	// Returns an error in case the lookup failed.
	GetEntityIDForIP(ctx context.Context, ip string) (string, error)

	// GetTokenScopes returns the list of scopes assigned to a token if successful.
	GetTokenScopes(ctx context.Context, token string) (TokenScopes, error)

	// GetActiveGateConnectionInfo returns AgentTenantInfo for ActiveGate that holds UUID, Tenant Token and Endpoints
	GetActiveGateConnectionInfo(ctx context.Context) (ActiveGateConnectionInfo, error)

	// CreateOrUpdateKubernetesSetting returns the object id of the created k8s settings if successful, or an api error otherwise
	CreateOrUpdateKubernetesSetting(ctx context.Context, name, kubeSystemUUID, scope string) (string, error)

	// CreateOrUpdateKubernetesAppSetting returns the object id of the created k8s app settings if successful, or an api error otherwise
	CreateOrUpdateKubernetesAppSetting(ctx context.Context, scope string) (string, error)

	// GetMonitoredEntitiesForKubeSystemUUID returns a (possibly empty) list of k8s monitored entities for the given uuid,
	// or an api error otherwise
	GetMonitoredEntitiesForKubeSystemUUID(ctx context.Context, kubeSystemUUID string) ([]MonitoredEntity, error)

	// GetSettingsForMonitoredEntities returns the settings response with the number of settings objects,
	// or an api error otherwise
	GetSettingsForMonitoredEntities(ctx context.Context, monitoredEntities []MonitoredEntity, schemaId string) (GetSettingsResponse, error)

	GetRulesSettings(ctx context.Context, kubeSystemUUID string, entityID string) (GetRulesSettingsResponse, error)

	GetActiveGateAuthToken(ctx context.Context, dynakubeName string) (*ActiveGateAuthTokenInfo, error)

	GetLatestOneAgentImage(ctx context.Context) (*LatestImageInfo, error)

	GetLatestCodeModulesImage(ctx context.Context) (*LatestImageInfo, error)

	GetLatestActiveGateImage(ctx context.Context) (*LatestImageInfo, error)

	// GetLatestActiveGateVersion gets the latest gateway version for the given OS and arch.
	// Returns the version as received from the server on success.
	GetLatestActiveGateVersion(ctx context.Context, os string) (string, error)
}

Client is the interface for the Dynatrace REST API client.

func NewClient

func NewClient(url, apiToken, paasToken string, opts ...Option) (Client, error)

NewClient creates a REST client for the given API base URL and authentication tokens. Returns an error if a token or the URL is empty.

The API base URL is different for managed and SaaS environments:

  • SaaS: https://{environment-id}.live.dynatrace.com/api
  • Managed: https://{domain}/e/{environment-id}/api

opts can be used to customize the created client, entries must not be nil.

type CommunicationHost

type CommunicationHost struct {
	Protocol string
	Host     string
	Port     uint32
}

CommunicationHost => struct of connection endpoint

func ParseEndpoint

func ParseEndpoint(s string) (CommunicationHost, error)

type ConfMap

type ConfMap map[string]map[string]string

ConfMap is the representation of a config file with sections that are divided by headers (map[header] == section) each section consists of key value pairs.

type ConnectionInfo

type ConnectionInfo struct {
	TenantUUID  string
	TenantToken string
	Endpoints   string
}

type EventData

type EventData struct {
	EventType     string               `json:"eventType"`
	Description   string               `json:"description"`
	Source        string               `json:"source"`
	AttachRules   EventDataAttachRules `json:"attachRules"`
	StartInMillis uint64               `json:"start"`
	EndInMillis   uint64               `json:"end"`
}

EventData struct which defines what event payload should contain

type EventDataAttachRules

type EventDataAttachRules struct {
	EntityIDs []string `json:"entityIds"`
}

type GetRulesSettingsResponse added in v1.3.0

type GetRulesSettingsResponse struct {
	Items      []RuleItem `json:"items"`
	TotalCount int        `json:"totalCount"`
}

type GetSettingsResponse

type GetSettingsResponse struct {
	TotalCount int `json:"totalCount"`
}

type HostNotFoundErr

type HostNotFoundErr struct {
	IP string
}

func (HostNotFoundErr) Error

func (e HostNotFoundErr) Error() string

type LatestImageInfo

type LatestImageInfo struct {
	Source string `json:"source"`
	Tag    string `json:"tag"`
}

func (LatestImageInfo) String

func (image LatestImageInfo) String() string

type MonitoredEntity

type MonitoredEntity struct {
	EntityId    string `json:"entityId"`
	DisplayName string `json:"displayName"`
	LastSeenTms int64  `json:"lastSeenTms"`
}

type MonitoringSettings

type MonitoringSettings struct {
	CloudApplicationPipelineEnabled bool `json:"cloudApplicationPipelineEnabled"`
	OpenMetricsPipelineEnabled      bool `json:"openMetricsPipelineEnabled"`
	EventProcessingActive           bool `json:"eventProcessingActive"`
	EventProcessingV2Active         bool `json:"eventProcessingV2Active"`
	FilterEvents                    bool `json:"filterEvents"`
}

type OneAgentConnectionInfo

type OneAgentConnectionInfo struct {
	ConnectionInfo
	CommunicationHosts []CommunicationHost
}

type Option

type Option func(*dynatraceClient)

Option can be passed to NewClient and customizes the created client instance.

func Certs

func Certs(certs []byte) Option

func HostGroup added in v1.0.0

func HostGroup(hostGroup string) Option

func NetworkZone

func NetworkZone(networkZone string) Option

func Proxy

func Proxy(proxyURL string, noProxy string) Option

func SkipCertificateValidation

func SkipCertificateValidation(skip bool) Option

SkipCertificateValidation creates an Option that specifies whether validation of the server's TLS certificate should be skipped. The default is false.

type ProcessModuleConfig

type ProcessModuleConfig struct {
	Properties []ProcessModuleProperty `json:"properties"`
	Revision   uint                    `json:"revision"`
}

func (*ProcessModuleConfig) Add

func (*ProcessModuleConfig) AddConnectionInfo

func (pmc *ProcessModuleConfig) AddConnectionInfo(oneAgentConnectionInfo dynakube.OneAgentConnectionInfoStatus, tenantToken string) *ProcessModuleConfig

func (*ProcessModuleConfig) AddHostGroup

func (pmc *ProcessModuleConfig) AddHostGroup(hostGroup string) *ProcessModuleConfig

func (*ProcessModuleConfig) AddNoProxy added in v1.0.0

func (pmc *ProcessModuleConfig) AddNoProxy(noProxy string) *ProcessModuleConfig

func (*ProcessModuleConfig) AddProxy

func (pmc *ProcessModuleConfig) AddProxy(proxy string) *ProcessModuleConfig

func (ProcessModuleConfig) IsEmpty

func (pmc ProcessModuleConfig) IsEmpty() bool

func (ProcessModuleConfig) ToMap

func (pmc ProcessModuleConfig) ToMap() ConfMap

type ProcessModuleProperty

type ProcessModuleProperty struct {
	Section string `json:"section"`
	Key     string `json:"key"`
	Value   string `json:"value"`
}

type RuleItem added in v1.3.0

type RuleItem struct {
	Value RulesResponseValue `json:"value"`
}

type RulesResponseValue added in v1.3.0

type RulesResponseValue struct {
	Rules []dynakube.EnrichmentRule `json:"rules"`
}

type ServerError

type ServerError struct {
	Message string
	Code    int
}

ServerError represents an error returned from the server (e.g. authentication failure).

func (ServerError) Error

func (e ServerError) Error() string

Error formats the server error code and message.

type TokenScopes

type TokenScopes []string

TokenScopes is a list of scopes assigned to a token

func (TokenScopes) Contains

func (s TokenScopes) Contains(scope string) bool

Contains returns true if scope is included on the scopes, or false otherwise.

Jump to

Keyboard shortcuts

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