Example #1
0
)

const (
	result  = "result"
	success = "success"
	failure = "failure"
	dropped = "dropped"

	facet     = "facet"
	occupancy = "occupancy"
	capacity  = "capacity"
)

var (
	notificationsCount     = prometheus.NewCounter()
	notificationLatency    = prometheus.NewDefaultHistogram()
	notificationsQueueSize = prometheus.NewGauge()
)

func recordOutcome(duration time.Duration, err error) {
	labels := map[string]string{result: success}
	if err != nil {
		labels[result] = failure
	}

	notificationsCount.Increment(labels)
	ms := float64(duration / time.Millisecond)
	notificationLatency.Add(labels, ms)
}

func init() {
Example #2
0
File: ent.go Project: queer1/ent
	"github.com/prometheus/client_golang/prometheus"
	"github.com/prometheus/client_golang/prometheus/exp"
)

const (
	fileRoute = `/{bucket}/{key:[a-zA-Z0-9\-_\.~\+\/]+}`
)

var (
	Program = "ent"
	Commit  = "0000000"
	Version = "0.0.0"

	requestBytes     = prometheus.NewCounter()
	requestDuration  = prometheus.NewCounter()
	requestDurations = prometheus.NewDefaultHistogram()
	requestTotal     = prometheus.NewCounter()
	responseBytes    = prometheus.NewCounter()
)

func main() {
	var (
		fsRoot      = flag.String("fs.root", "/tmp", "FileSystem root directory")
		httpAddress = flag.String("http.addr", ":5555", "HTTP listen address")
		providerDir = flag.String("provider.dir", "/tmp", "Provider directory with bucket policies")
	)
	flag.Parse()

	prometheus.Register("ent_requests_total", "Total number of requests made", prometheus.NilLabels, requestTotal)
	prometheus.Register("ent_requests_duration_nanoseconds_total", "Total amount of time ent has spent to answer requests in nanoseconds", prometheus.NilLabels, requestDuration)
	prometheus.Register("ent_requests_duration_nanoseconds", "Amounts of time ent has spent answering requests in nanoseconds", prometheus.NilLabels, requestDurations)
Example #3
0
)

const (
	result  = "result"
	success = "success"
	failure = "failure"
	dropped = "dropped"

	facet     = "facet"
	occupancy = "occupancy"
	capacity  = "capacity"
)

var (
	samplesCount = prometheus.NewCounter()
	sendLatency  = prometheus.NewDefaultHistogram()
	queueSize    = prometheus.NewGauge()
)

func recordOutcome(duration time.Duration, sampleCount int, err error) {
	labels := map[string]string{result: success}
	if err != nil {
		labels[result] = failure
	}

	samplesCount.IncrementBy(labels, float64(sampleCount))
	ms := float64(duration / time.Millisecond)
	sendLatency.Add(labels, ms)
}

func init() {
Example #4
0
import (
	"time"

	"github.com/prometheus/client_golang/prometheus"
)

const (
	intervalLabel     = "interval"
	ruleTypeLabel     = "rule_type"
	alertingRuleType  = "alerting"
	recordingRuleType = "recording"
)

var (
	evalDuration      = prometheus.NewDefaultHistogram()
	evalCount         = prometheus.NewCounter()
	iterationDuration = prometheus.NewHistogram(&prometheus.HistogramSpecification{
		Starts:                prometheus.LogarithmicSizedBucketsFor(0, 10000),
		BucketBuilder:         prometheus.AccumulatingBucketBuilder(prometheus.EvictAndReplaceWith(10, prometheus.AverageReducer), 100),
		ReportablePercentiles: []float64{0.01, 0.05, 0.5, 0.90, 0.99}})
)

func recordOutcome(ruleType string, duration time.Duration) {
	millisecondDuration := float64(duration / time.Millisecond)
	evalCount.Increment(map[string]string{ruleTypeLabel: ruleType})
	evalDuration.Add(map[string]string{ruleTypeLabel: ruleType}, millisecondDuration)
}

func init() {
	prometheus.Register("prometheus_evaluator_duration_ms", "The duration for each evaluation pool to execute.", prometheus.NilLabels, iterationDuration)