Documentation ¶
Index ¶
Constants ¶
View Source
const ( // RAMSuccessCode is the code used for metrics when an RAM request succeeds. RAMSuccessCode = "Success" // RAMUnknownFailCode is the code used for metrics when an RAM request fails with an error not reported by Alibaba Cloud. RAMUnknownFailCode = "UnknownError" )
Variables ¶
View Source
var ( // RAMRequestSec tracks timing of RAM requests. RAMRequestSec = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Namespace: namespace, Subsystem: "ram", Name: "request_duration_seconds", Help: "Time taken to complete RAM request in seconds.", Buckets: prometheus.ExponentialBuckets(0.001, 2, 14), }, []string{ "code", "role_arn", }, ) // RAMCacheHitCount tracks total number of RAM cache hits. Cache misses can be // calculated by looking at the total number of RAM requests for the same role_arn. RAMCacheHitCount = prometheus.NewCounterVec( prometheus.CounterOpts{ Namespace: namespace, Subsystem: "ram", Name: "cache_hits_total", Help: "Total number of RAM cache hits.", }, []string{ "role_arn", }, ) // HTTPRequestSec tracks timing of served HTTP requests. HTTPRequestSec = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Namespace: namespace, Subsystem: "http", Name: "request_duration_seconds", Help: "Time taken for kube2ram to serve HTTP request.", Buckets: prometheus.ExponentialBuckets(0.001, 2, 14), }, []string{ "code", "method", "handler", }, ) // HealthcheckStatus reports the current healthcheck status of kube2ram. HealthcheckStatus = prometheus.NewGauge( prometheus.GaugeOpts{ Namespace: namespace, Subsystem: "healthcheck", Name: "status", Help: "The healthcheck status at scrape time. A value of 1 means it is passing, 0 means it is failing.", }, ) // Info reports various static information about the running kube2ram binary. Info = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Namespace: namespace, Name: "info", Help: "Informational labels about the kube2ram process.", }, []string{ "version", "build_date", "commit_hash", }, ) )
Functions ¶
func GetHandler ¶
GetHandler creates a prometheus HTTP handler that will serve metrics.
func NewFunctionTimer ¶
func NewFunctionTimer(histVec *prometheus.HistogramVec, lvsFn func() []string, storeValue *float64) *prometheus.Timer
NewFunctionTimer creates a new timer for a generic function that can be observed to time the duration of the handler. The metric is labeled with the values produced by the lvsProducer to allow for late binding of label values. If provided, the timer value is stored in storeValue to allow callers access to the reported value.
func StartMetricsServer ¶
func StartMetricsServer(metricsPort string)
StartMetricsServer registers a prometheus /metrics handler and starts a HTTP server listening on the provided port to service it.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.