router

package
v6.7.3 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CounterSampleTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: namespace,
		Subsystem: subsystem,
		Name:      "samples_received_total",
		Help:      "Total number samples received.",
	}, []string{"channel"})

	CounterDropSampleTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: namespace,
		Subsystem: subsystem,
		Name:      "drop_sample_total",
		Help:      "Number of drop sample.",
	}, []string{"client_ip"})

	CounterSampleReceivedByIdent = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: namespace,
		Subsystem: subsystem,
		Name:      "sample_received_by_ident",
		Help:      "Number of sample push by ident.",
	}, []string{"host_ident"})
)
View Source
var IdentStats *cache.Cache

Functions

func DecodeWriteRequest

func DecodeWriteRequest(r io.Reader) (*prompb.WriteRequest, error)

DecodeWriteRequest from an io.Reader into a prompb.WriteRequest, handling snappy decompression.

func IdentStatsInc added in v6.7.0

func IdentStatsInc(name string)

Types

type DatadogMetric

type DatadogMetric struct {
	Metric string         `json:"metric"`
	Points []DatadogPoint `json:"points"`
	Host   string         `json:"host"`
	Tags   []string       `json:"tags,omitempty"`
}

func (*DatadogMetric) Clean

func (m *DatadogMetric) Clean() error

func (DatadogMetric) MarshalEasyJSON

func (v DatadogMetric) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (DatadogMetric) MarshalJSON

func (v DatadogMetric) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*DatadogMetric) ToProm

func (m *DatadogMetric) ToProm() (*prompb.TimeSeries, string, error)

func (*DatadogMetric) UnmarshalEasyJSON

func (v *DatadogMetric) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*DatadogMetric) UnmarshalJSON

func (v *DatadogMetric) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type DatadogPoint

type DatadogPoint [2]float64

func (DatadogPoint) MarshalEasyJSON

func (v DatadogPoint) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (DatadogPoint) MarshalJSON

func (v DatadogPoint) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*DatadogPoint) UnmarshalEasyJSON

func (v *DatadogPoint) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*DatadogPoint) UnmarshalJSON

func (v *DatadogPoint) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type FalconMetric

type FalconMetric struct {
	Metric       string      `json:"metric"`
	Endpoint     string      `json:"endpoint"`
	Timestamp    int64       `json:"timestamp"`
	ValueUnTyped interface{} `json:"value"`
	Value        float64     `json:"-"`
	Tags         string      `json:"tags"`
}

func (*FalconMetric) Clean

func (m *FalconMetric) Clean(ts int64) error

func (FalconMetric) MarshalEasyJSON

func (v FalconMetric) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (FalconMetric) MarshalJSON

func (v FalconMetric) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*FalconMetric) ToProm

func (m *FalconMetric) ToProm() (*prompb.TimeSeries, string, error)

func (*FalconMetric) UnmarshalEasyJSON

func (v *FalconMetric) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*FalconMetric) UnmarshalJSON

func (v *FalconMetric) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type FalconMetricArr

type FalconMetricArr []FalconMetric

func (FalconMetricArr) MarshalEasyJSON

func (v FalconMetricArr) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (FalconMetricArr) MarshalJSON

func (v FalconMetricArr) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*FalconMetricArr) UnmarshalEasyJSON

func (v *FalconMetricArr) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*FalconMetricArr) UnmarshalJSON

func (v *FalconMetricArr) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type HTTPMetric

type HTTPMetric struct {
	Metric       string            `json:"metric"`
	Timestamp    int64             `json:"timestamp"`
	ValueUnTyped interface{}       `json:"value"`
	Value        float64           `json:"-"`
	Tags         map[string]string `json:"tags"`
}

easyjson:json

func (*HTTPMetric) Clean

func (m *HTTPMetric) Clean(ts int64) error

func (HTTPMetric) MarshalEasyJSON

func (v HTTPMetric) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (HTTPMetric) MarshalJSON

func (v HTTPMetric) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*HTTPMetric) ToProm

func (m *HTTPMetric) ToProm() (*prompb.TimeSeries, error)

func (*HTTPMetric) UnmarshalEasyJSON

func (v *HTTPMetric) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*HTTPMetric) UnmarshalJSON

func (v *HTTPMetric) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type HTTPMetricArr

type HTTPMetricArr []HTTPMetric

func (HTTPMetricArr) MarshalEasyJSON

func (v HTTPMetricArr) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (HTTPMetricArr) MarshalJSON

func (v HTTPMetricArr) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*HTTPMetricArr) UnmarshalEasyJSON

func (v *HTTPMetricArr) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*HTTPMetricArr) UnmarshalJSON

func (v *HTTPMetricArr) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type HandleTSFunc added in v6.5.0

type HandleTSFunc func(pt *prompb.TimeSeries)

type Router

type Router struct {
	HTTP           httpx.Config
	Pushgw         pconf.Pushgw
	TargetCache    *memsto.TargetCacheType
	BusiGroupCache *memsto.BusiGroupCacheType
	IdentSet       *idents.Set
	Writers        *writer.WritersType
	Ctx            *ctx.Context
	HandleTS       HandleTSFunc
}

func New

func New(httpConfig httpx.Config, pushgw pconf.Pushgw, tc *memsto.TargetCacheType, bg *memsto.BusiGroupCacheType, idents *idents.Set, writers *writer.WritersType, ctx *ctx.Context) *Router

func (*Router) AppendLabels

func (rt *Router) AppendLabels(pt *prompb.TimeSeries, target *models.Target, bgCache *memsto.BusiGroupCacheType)

func (*Router) BeforePush

func (rt *Router) BeforePush(clientIP string, v *prompb.TimeSeries)

func (*Router) Config

func (rt *Router) Config(r *gin.Engine)

func (*Router) DropSample added in v6.7.0

func (rt *Router) DropSample(remoteAddr string, v *prompb.TimeSeries) bool

func (*Router) ForwardByIdent

func (rt *Router) ForwardByIdent(clientIP string, ident string, v *prompb.TimeSeries)

func (*Router) ForwardByMetric

func (rt *Router) ForwardByMetric(clientIP string, metric string, v *prompb.TimeSeries)

func (*Router) ReportIdentStats added in v6.7.0

func (rt *Router) ReportIdentStats() (interface{}, bool)

type TimeSeries

type TimeSeries struct {
	Series []*DatadogMetric `json:"series"`
}

func (TimeSeries) MarshalEasyJSON

func (v TimeSeries) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (TimeSeries) MarshalJSON

func (v TimeSeries) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*TimeSeries) UnmarshalEasyJSON

func (v *TimeSeries) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*TimeSeries) UnmarshalJSON

func (v *TimeSeries) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

Jump to

Keyboard shortcuts

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