github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/pkg/storage/chunk/client/aws/dynamodb_metrics.go (about) 1 package aws 2 3 import ( 4 "github.com/prometheus/client_golang/prometheus" 5 "github.com/prometheus/client_golang/prometheus/promauto" 6 "github.com/weaveworks/common/instrument" 7 ) 8 9 type dynamoDBMetrics struct { 10 dynamoRequestDuration *instrument.HistogramCollector 11 dynamoConsumedCapacity *prometheus.CounterVec 12 dynamoThrottled *prometheus.CounterVec 13 dynamoFailures *prometheus.CounterVec 14 dynamoDroppedRequests *prometheus.CounterVec 15 dynamoQueryPagesCount prometheus.Histogram 16 } 17 18 func newMetrics(r prometheus.Registerer) *dynamoDBMetrics { 19 m := dynamoDBMetrics{} 20 21 m.dynamoRequestDuration = instrument.NewHistogramCollector(promauto.With(r).NewHistogramVec(prometheus.HistogramOpts{ 22 Namespace: "loki", 23 Name: "dynamo_request_duration_seconds", 24 Help: "Time spent doing DynamoDB requests.", 25 26 // DynamoDB latency seems to range from a few ms to a several seconds and is 27 // important. So use 9 buckets from 1ms to just over 1 minute (65s). 28 Buckets: prometheus.ExponentialBuckets(0.001, 4, 9), 29 }, []string{"operation", "status_code"})) 30 m.dynamoConsumedCapacity = promauto.With(r).NewCounterVec(prometheus.CounterOpts{ 31 Namespace: "loki", 32 Name: "dynamo_consumed_capacity_total", 33 Help: "The capacity units consumed by operation.", 34 }, []string{"operation", tableNameLabel}) 35 m.dynamoThrottled = promauto.With(r).NewCounterVec(prometheus.CounterOpts{ 36 Namespace: "loki", 37 Name: "dynamo_throttled_total", 38 Help: "The total number of throttled events.", 39 }, []string{"operation", tableNameLabel}) 40 m.dynamoFailures = promauto.With(r).NewCounterVec(prometheus.CounterOpts{ 41 Namespace: "loki", 42 Name: "dynamo_failures_total", 43 Help: "The total number of errors while storing chunks to the chunk store.", 44 }, []string{tableNameLabel, errorReasonLabel, "operation"}) 45 m.dynamoDroppedRequests = promauto.With(r).NewCounterVec(prometheus.CounterOpts{ 46 Namespace: "loki", 47 Name: "dynamo_dropped_requests_total", 48 Help: "The total number of requests which were dropped due to errors encountered from dynamo.", 49 }, []string{tableNameLabel, errorReasonLabel, "operation"}) 50 m.dynamoQueryPagesCount = promauto.With(r).NewHistogram(prometheus.HistogramOpts{ 51 Namespace: "loki", 52 Name: "dynamo_query_pages_count", 53 Help: "Number of pages per query.", 54 // Most queries will have one page, however this may increase with fuzzy 55 // metric names. 56 Buckets: prometheus.ExponentialBuckets(1, 4, 6), 57 }) 58 59 return &m 60 }