...

Source file src/github.com/sigstore/rekor/pkg/api/metrics.go

Documentation: github.com/sigstore/rekor/pkg/api

     1  //
     2  // Copyright 2021 The Sigstore Authors.
     3  //
     4  // Licensed under the Apache License, Version 2.0 (the "License");
     5  // you may not use this file except in compliance with the License.
     6  // You may obtain a copy of the License at
     7  //
     8  //     http://www.apache.org/licenses/LICENSE-2.0
     9  //
    10  // Unless required by applicable law or agreed to in writing, software
    11  // distributed under the License is distributed on an "AS IS" BASIS,
    12  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  // See the License for the specific language governing permissions and
    14  // limitations under the License.
    15  
    16  package api
    17  
    18  import (
    19  	"time"
    20  
    21  	"github.com/prometheus/client_golang/prometheus"
    22  	"github.com/prometheus/client_golang/prometheus/promauto"
    23  	"sigs.k8s.io/release-utils/version"
    24  )
    25  
    26  var (
    27  	metricNewEntries = promauto.NewCounter(prometheus.CounterOpts{
    28  		Name: "rekor_new_entries",
    29  		Help: "The total number of new log entries",
    30  	})
    31  
    32  	metricPublishEvents = promauto.NewCounterVec(prometheus.CounterOpts{
    33  		Name: "rekor_publish_events",
    34  		Help: "The status of publishing events to Pub/Sub",
    35  	}, []string{"event", "content_type", "status"})
    36  
    37  	metricIndexStorageLatency = promauto.NewSummaryVec(prometheus.SummaryOpts{
    38  		Name: "rekor_index_storage_latency_summary",
    39  		Help: "Latency of backend index insertion by success/failure",
    40  	}, []string{"success"})
    41  
    42  	MetricLatency = promauto.NewHistogramVec(prometheus.HistogramOpts{
    43  		Name: "rekor_api_latency",
    44  		Help: "Api Latency on calls",
    45  	}, []string{"path", "code"})
    46  
    47  	MetricLatencySummary = promauto.NewSummaryVec(prometheus.SummaryOpts{
    48  		Name: "rekor_api_latency_summary",
    49  		Help: "Api Latency on calls",
    50  	}, []string{"path", "code"})
    51  
    52  	MetricRequestLatency = promauto.NewHistogramVec(prometheus.HistogramOpts{
    53  		Name: "rekor_latency_by_api",
    54  		Help: "Api Latency (in ns) by path and method",
    55  		Buckets: prometheus.ExponentialBucketsRange(
    56  			float64(time.Millisecond),
    57  			float64(4*time.Second),
    58  			10),
    59  	}, []string{"path", "method"})
    60  
    61  	MetricRequestCount = promauto.NewCounterVec(prometheus.CounterOpts{
    62  		Name: "rekor_qps_by_api",
    63  		Help: "Api QPS by path, method, and response code",
    64  	}, []string{"path", "method", "code"})
    65  
    66  	CheckpointPublishCount = promauto.NewCounterVec(prometheus.CounterOpts{
    67  		Name: "rekor_checkpoint_publish",
    68  		Help: "Checkpoint publishing by shard and code",
    69  	}, []string{"shard", "code"})
    70  
    71  	_ = promauto.NewGaugeFunc(
    72  		prometheus.GaugeOpts{
    73  			Namespace: "rekor",
    74  			Name:      "build_info",
    75  			Help:      "A metric with a constant '1' value labeled by version, revision, branch, and goversion from which rekor was built.",
    76  			ConstLabels: prometheus.Labels{
    77  				"version":    version.GetVersionInfo().GitVersion,
    78  				"revision":   version.GetVersionInfo().GitCommit,
    79  				"build_date": version.GetVersionInfo().BuildDate,
    80  				"goversion":  version.GetVersionInfo().GoVersion,
    81  			},
    82  		},
    83  		func() float64 { return 1 },
    84  	)
    85  )
    86  

View as plain text