gather

package
v0.0.0-...-d500d3c Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetricsSubject = "metrics"
)

nats subjects

Variables

This section is empty.

Functions

This section is empty.

Types

type MetricType

type MetricType int

MetricType is prometheus metrics type.

const (
	MetricTypeCounter MetricType = iota
	MetricTypeGauge
	MetricTypeSummary
	MetricTypeUntyped
	MetricTypeHistogrm
)

the set of metric types

func (MetricType) String

func (x MetricType) String() string

String returns the string value of MetricType.

func (*MetricType) UnmarshalJSON

func (x *MetricType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the unmarshaler interface.

type Metrics

type Metrics struct {
	Name      string                 `json:"name"`
	Tags      map[string]string      `json:"tags"`
	Fields    map[string]interface{} `json:"fields"`
	Timestamp int64                  `json:"timestamp"`
	Type      MetricType             `json:"type"`
}

Metrics is the default influx based metrics.

type Scheduler

type Scheduler struct {
	Targets platform.ScraperTargetStoreService
	// Interval is between each metrics gathering event.
	Interval time.Duration
	// Timeout is the maxisium time duration allowed by each TCP request
	Timeout time.Duration

	// Publisher will send the gather requests and gathered metrics to the queue.
	Publisher nats.Publisher

	Logger *zap.Logger
	// contains filtered or unexported fields
}

Scheduler is struct to run scrape jobs.

func NewScheduler

func NewScheduler(
	numScrapers int,
	l *zap.Logger,
	targets platform.ScraperTargetStoreService,
	p nats.Publisher,
	s nats.Subscriber,
	interval time.Duration,
	timeout time.Duration,
) (*Scheduler, error)

NewScheduler creates a new Scheduler and subscriptions for scraper jobs.

func (*Scheduler) Run

func (s *Scheduler) Run(ctx context.Context) error

Run will retrieve scraper targets from the target storage, and publish them to nats job queue for gather.

type Scraper

type Scraper interface {
	Gather(ctx context.Context, target platform.ScraperTarget) (ms []Metrics, err error)
}

Scraper gathers metrics from a scraper target.

type Storage

type Storage interface {
	//Subscriber nats.Subscriber
	Record([]Metrics) error
}

Storage stores the metrics of a time based.

type StorageHandler

type StorageHandler struct {
	Storage Storage
	Logger  *zap.Logger
}

StorageHandler implements nats.Handler interface.

func (*StorageHandler) Process

func (h *StorageHandler) Process(s nats.Subscription, m nats.Message)

Process consumes job queue, and use storage to record.

Jump to

Keyboard shortcuts

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