exporter

package
v2.4.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RegisterPeriod = time.Duration(10) * time.Minute
	RegisterPath   = "/v1/agent/service/register"
)
View Source
const (
	PromHandlerPattern      = "/metrics"       // prometheus handler
	AppName                 = "cfs"            //app name
	ConfigKeyExporterEnable = "exporterEnable" //exporter enable
	ConfigKeyExporterPort   = "exporterPort"   //exporter port
	ConfigKeyConsulAddr     = "consulAddr"     //consul addr
	ConfigKeyConsulMeta     = "consulMeta"     // consul meta
	ConfigKeyIpFilter       = "ipFilter"       // add ip filter
	ConfigKeyEnablePid      = "enablePid"      // enable report partition id
	ChSize                  = 1024 * 10        //collect chan size

	// monitor label name
	Vol    = "vol"
	Disk   = "disk"
	PartId = "partid"
	Op     = "op"
	Type   = "type"
)

Variables

View Source
var (
	AlarmPool = &sync.Pool{New: func() interface{} {
		return new(Alarm)
	}}
	//AlarmGroup  sync.Map
	AlarmCh chan *Alarm
)
View Source
var (
	CounterGroup sync.Map
	CounterPool  = &sync.Pool{New: func() interface{} {
		return new(Counter)
	}}
	CounterCh chan *Counter
)
View Source
var (
	GaugeGroup sync.Map
	GaugeCh    chan *Gauge
)
View Source
var (
	HistogramGroup sync.Map
	HistogramCh    chan *Histogram
)
View Source
var (
	EnablePid = false
)

Functions

func DoConsulRegisterProc

func DoConsulRegisterProc(addr, app, role, cluster, meta, host string, port int64)

do consul register process

func GetConsulId

func GetConsulId(app string, role string, host string, port int64) string

get consul id

func GetLocalIpAddr

func GetLocalIpAddr(filter string) (ipaddr string, err error)

GetLocalIpAddr returns the local IP address.

func Init

func Init(role string, cfg *config.Config)

Init initializes the exporter.

func InitWithRouter

func InitWithRouter(role string, cfg *config.Config, router *mux.Router, exPort string)

Init initializes the exporter.

func RegistConsul added in v1.4.0

func RegistConsul(cluster string, role string, cfg *config.Config)

Types

type Alarm

type Alarm struct {
	Counter
}

func Warning added in v1.4.0

func Warning(detail string) (a *Alarm)

type ConsulRegisterInfo

type ConsulRegisterInfo struct {
	Name    string            `json:"Name"`
	ID      string            `json:"ID"`
	Address string            `json:"Address"`
	Port    int64             `json:"Port"`
	Tags    []string          `json:"Tags"`
	Meta    map[string]string `json:",omitempty"`
}

*

  • consul register info for prometheus
  • optional for user when set prometheus exporter

type Counter

type Counter struct {
	Gauge
}

func NewCounter

func NewCounter(name string) (c *Counter)

func (*Counter) Add

func (c *Counter) Add(val int64)

func (*Counter) AddWithLabels

func (c *Counter) AddWithLabels(val int64, labels map[string]string)

func (*Counter) Metric

func (c *Counter) Metric() prometheus.Counter

type Gauge

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

func NewGauge

func NewGauge(name string) (g *Gauge)

func (*Gauge) Key

func (c *Gauge) Key() (key string)

func (*Gauge) Metric

func (c *Gauge) Metric() prometheus.Gauge

func (*Gauge) Name

func (g *Gauge) Name() string

func (*Gauge) Set

func (g *Gauge) Set(val float64)

func (*Gauge) SetWithLabels

func (g *Gauge) SetWithLabels(val float64, labels map[string]string)

func (*Gauge) String

func (g *Gauge) String() string

type GaugeVec

type GaugeVec struct {
	*prometheus.GaugeVec
}

func NewGaugeVec

func NewGaugeVec(name, help string, labels []string) *GaugeVec

func (*GaugeVec) SetWithLabelValues

func (v *GaugeVec) SetWithLabelValues(val float64, lvs ...string)

type Histogram

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

func (*Histogram) Key

func (c *Histogram) Key() (key string)

func (*Histogram) Metric

func (c *Histogram) Metric() prometheus.Histogram

func (*Histogram) Name

func (g *Histogram) Name() string

func (*Histogram) String

func (g *Histogram) String() string

type TimePoint

type TimePoint struct {
	Histogram
	// contains filtered or unexported fields
}

func NewTP

func NewTP(name string) (tp *TimePoint)

func (*TimePoint) Set

func (tp *TimePoint) Set()

func (*TimePoint) SetWithLabels

func (tp *TimePoint) SetWithLabels(labels map[string]string)

type TimePointCount

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

func NewTPCnt

func NewTPCnt(name string) (tpc *TimePointCount)

func (*TimePointCount) Set

func (tpc *TimePointCount) Set(err error)

it should be invoked by defer func{set(err)}

func (*TimePointCount) SetWithLabels

func (tpc *TimePointCount) SetWithLabels(err error, labels map[string]string)

Jump to

Keyboard shortcuts

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