surveyor

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Package surveyor is used to garner data from a NATS deployment for Prometheus

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultListenPort         = 7777
	DefaultListenAddress      = "0.0.0.0"
	DefaultURL                = nats.DefaultURL
	DefaultExpectedServers    = 1
	DefaultPollTimeout        = time.Second * 3
	DefaultServerResponseWait = 500 * time.Millisecond
)

Defaults

Functions

This section is empty.

Types

type JSAdvisoriesExternalAccountConfig added in v0.5.1

type JSAdvisoriesExternalAccountConfig struct {
	// subject on which JS metrics from external accounts will be received.
	// if not set, metrics will be gathered from account set in AccountName.
	MetricsSubject string `json:"metrics_subject"`

	// position of account token in ExternalMetricsSubject
	MetricsAccountTokenPosition int `json:"metrics_account_token_position"`

	// subject on which JS advisories from external accounts will be received.
	// if not set, advisories will be gathered from account set in AccountName.
	AdvisorySubject string `json:"advisory_subject"`

	// position of account token in ExternalAdvisorySubject
	AdvisoryAccountTokenPosition int `json:"advisory_account_token_position"`
}

JSAdvisoriesExternalAccountConfig is used to configure external accounts from which JS metrics and advisories will be imported

type JSAdvisoryConfig added in v0.5.0

type JSAdvisoryConfig struct {
	// unique identifier
	ID string `json:"id"`

	// account name
	AccountName string `json:"name"`

	// optional configuration for importing JS metrics and advisories from other accounts
	// it can only be set via JSAdvisoryConfig directly (not from config file)
	ExternalAccountConfig *JSAdvisoriesExternalAccountConfig `json:"-"`

	// connection options
	JWT         string `json:"jwt"`
	Seed        string `json:"seed"`
	Credentials string `json:"credential"`
	Nkey        string `json:"nkey"`
	Token       string `json:"token"`
	Username    string `json:"username"`
	Password    string `json:"password"`
	TLSCA       string `json:"tls_ca"`
	TLSCert     string `json:"tls_cert"`
	TLSKey      string `json:"tls_key"`
}

func NewJetStreamAdvisoryConfigFromFile added in v0.5.0

func NewJetStreamAdvisoryConfigFromFile(f string) (*JSAdvisoryConfig, error)

NewJetStreamAdvisoryConfigFromFile creates a new JSAdvisoryConfig from a file the ID of the JSAdvisoryConfig is set to the filename f

func (*JSAdvisoryConfig) Validate added in v0.5.0

func (o *JSAdvisoryConfig) Validate() error

Validate is used to validate a JSAdvisoryConfig

type JSAdvisoryManager added in v0.5.0

type JSAdvisoryManager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

JSAdvisoryManager exposes methods to operate on JetStream advisories

func (*JSAdvisoryManager) ConfigMap added in v0.5.0

func (am *JSAdvisoryManager) ConfigMap() map[string]*JSAdvisoryConfig

ConfigMap returns a map of id:*JSAdvisoryConfig for all running advisories

func (*JSAdvisoryManager) Delete added in v0.5.0

func (am *JSAdvisoryManager) Delete(id string) error

Delete deletes existing advisory with provided ID

func (*JSAdvisoryManager) IsRunning added in v0.5.0

func (am *JSAdvisoryManager) IsRunning() bool

IsRunning returns true if the advisory manager is running or false if it is stopped

func (*JSAdvisoryManager) Set added in v0.5.0

func (am *JSAdvisoryManager) Set(config *JSAdvisoryConfig) error

Set creates or updates an advisory if an advisory exists with the same ID, it is updated otherwise, a new advisory is created

type JSAdvisoryMetrics added in v0.4.0

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

func NewJetStreamAdvisoryMetrics added in v0.4.0

func NewJetStreamAdvisoryMetrics(registry *prometheus.Registry, constLabels prometheus.Labels) *JSAdvisoryMetrics

type Options

type Options struct {
	Name                 string
	URLs                 string
	Credentials          string
	Nkey                 string
	JWT                  string
	Seed                 string
	NATSUser             string
	NATSPassword         string
	PollTimeout          time.Duration
	ExpectedServers      int
	ServerResponseWait   time.Duration
	ListenAddress        string
	ListenPort           int
	CertFile             string
	KeyFile              string
	CaFile               string
	HTTPCertFile         string
	HTTPKeyFile          string
	HTTPCaFile           string
	HTTPUser             string // User in metrics scrape by Prometheus.
	HTTPPassword         string
	Prefix               string // TODO
	ObservationConfigDir string
	JetStreamConfigDir   string
	Accounts             bool
	Logger               *logrus.Logger    // not exposed by CLI
	NATSOpts             []nats.Option     // not exposed by CLI
	ConstLabels          prometheus.Labels // not exposed by CLI
	DisableHTTPServer    bool              // not exposed by CLI
}

Options are used to configure the NATS collector

func GetDefaultOptions

func GetDefaultOptions() *Options

GetDefaultOptions returns the default set of options

type ServiceObsConfig added in v0.5.0

type ServiceObsConfig struct {
	// unique identifier
	ID string `json:"id"`

	// service settings
	ServiceName string `json:"name"`
	Topic       string `json:"topic"`

	// optional configuration for importing observations from other accounts
	// it can only be set via ServiceObsConfig directly (not from config file)
	ExternalAccountConfig *ServiceObservationExternalAccountConfig `json:"-"`

	// connection options
	JWT         string `json:"jwt"`
	Seed        string `json:"seed"`
	Credentials string `json:"credential"`
	Nkey        string `json:"nkey"`
	Token       string `json:"token"`
	Username    string `json:"username"`
	Password    string `json:"password"`
	TLSCA       string `json:"tls_ca"`
	TLSCert     string `json:"tls_cert"`
	TLSKey      string `json:"tls_key"`
}

ServiceObsConfig is used to configure service observations

func NewServiceObservationConfigFromFile added in v0.5.0

func NewServiceObservationConfigFromFile(f string) (*ServiceObsConfig, error)

NewServiceObservationConfigFromFile creates a new ServiceObsConfig from a file the ID of the ServiceObsConfig is set to the filename f

func (*ServiceObsConfig) Validate added in v0.5.0

func (o *ServiceObsConfig) Validate() error

Validate is used to validate a ServiceObsConfig

type ServiceObsManager added in v0.5.0

type ServiceObsManager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ServiceObsManager exposes methods to operate on service observations

func (*ServiceObsManager) ConfigMap added in v0.5.0

func (om *ServiceObsManager) ConfigMap() map[string]*ServiceObsConfig

ConfigMap returns a map of id:*ServiceObsConfig for all running observations

func (*ServiceObsManager) Delete added in v0.5.0

func (om *ServiceObsManager) Delete(id string) error

Delete deletes existing observations with provided ID

func (*ServiceObsManager) IsRunning added in v0.5.0

func (om *ServiceObsManager) IsRunning() bool

IsRunning returns true if the observation manager is running or false if it is stopped

func (*ServiceObsManager) Set added in v0.5.0

func (om *ServiceObsManager) Set(config *ServiceObsConfig) error

Set creates or updates an observation if an observation exists with the same ID, it is updated otherwise, a new observation is created

type ServiceObsMetrics added in v0.4.0

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

func NewServiceObservationMetrics added in v0.4.0

func NewServiceObservationMetrics(registry *prometheus.Registry, constLabels prometheus.Labels) *ServiceObsMetrics

type ServiceObservationExternalAccountConfig added in v0.5.1

type ServiceObservationExternalAccountConfig struct {
	// account name position in subject, used when aggregating services across multiple accounts
	AccountTokenPosition int `json:"account_token_position"`
	// optional service name position in subject, useful when aggregating services across multiple accounts
	// if not set, account name from account_token_position is used
	ServiceNamePosition int `json:"service_name_position"`
}

type StatzCollector

type StatzCollector struct {
	sync.Mutex
	// contains filtered or unexported fields
}

StatzCollector collects statz from a server deployment

func NewStatzCollector

func NewStatzCollector(nc *nats.Conn, logger *logrus.Logger, numServers int, serverDiscoveryWait, pollTimeout time.Duration, accounts bool, constLabels prometheus.Labels) *StatzCollector

NewStatzCollector creates a NATS Statz Collector

func (*StatzCollector) Collect

func (sc *StatzCollector) Collect(ch chan<- prometheus.Metric)

Collect gathers the streaming server serverz metrics.

func (*StatzCollector) Describe

func (sc *StatzCollector) Describe(ch chan<- *prometheus.Desc)

Describe is the Prometheus interface to describe metrics for the prometheus system

type Surveyor

type Surveyor struct {
	sync.Mutex
	// contains filtered or unexported fields
}

A Surveyor instance

func NewSurveyor

func NewSurveyor(opts *Options) (*Surveyor, error)

NewSurveyor creates a surveyor

func (*Surveyor) Gather added in v0.4.0

func (s *Surveyor) Gather() ([]*dto.MetricFamily, error)

Gather implements the prometheus.Gatherer interface

func (*Surveyor) JetStreamAdvisoryManager added in v0.5.0

func (s *Surveyor) JetStreamAdvisoryManager() *JSAdvisoryManager

func (*Surveyor) ServiceObservationManager added in v0.5.0

func (s *Surveyor) ServiceObservationManager() *ServiceObsManager

func (*Surveyor) Start

func (s *Surveyor) Start() error

Start starts the surveyor

func (*Surveyor) Stop

func (s *Surveyor) Stop()

Stop stops the surveyor

Jump to

Keyboard shortcuts

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