github.com/munnerz/test-infra@v0.0.0-20190108210205-ce3d181dc989/greenhouse/prometheus.go (about) 1 /* 2 Copyright 2018 The Kubernetes 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 17 package main 18 19 import ( 20 "github.com/prometheus/client_golang/prometheus" 21 ) 22 23 // prometheusMetrics are served by /prometheus on the metrics port 24 type prometheusMetrics struct { 25 DiskFree prometheus.Gauge 26 DiskUsed prometheus.Gauge 27 DiskTotal prometheus.Gauge 28 FilesEvicted prometheus.Counter 29 ActionCacheHits prometheus.Counter 30 CASHits prometheus.Counter 31 ActionCacheMisses prometheus.Counter 32 CASMisses prometheus.Counter 33 LastEvictedAccessAge prometheus.Gauge 34 } 35 36 func initMetrics() *prometheusMetrics { 37 metrics := &prometheusMetrics{ 38 DiskFree: prometheus.NewGauge(prometheus.GaugeOpts{ 39 Name: "bazel_cache_disk_free", 40 Help: "Free gb on bazel cache disk", 41 }), 42 DiskUsed: prometheus.NewGauge(prometheus.GaugeOpts{ 43 Name: "bazel_cache_disk_used", 44 Help: "Used gb on bazel cache disk", 45 }), 46 DiskTotal: prometheus.NewGauge(prometheus.GaugeOpts{ 47 Name: "bazel_cache_disk_total", 48 Help: "Total gb on bazel cache disk", 49 }), 50 FilesEvicted: prometheus.NewCounter(prometheus.CounterOpts{ 51 Name: "bazel_cache_evicted_files", 52 Help: "number of files evicted since last server start", 53 }), 54 ActionCacheHits: prometheus.NewCounter(prometheus.CounterOpts{ 55 Name: "bazel_cache_cas_hits", 56 Help: "Approximate number of Action Cache hits since last server start", 57 }), 58 CASHits: prometheus.NewCounter(prometheus.CounterOpts{ 59 Name: "bazel_cache_action_hits", 60 Help: "Approximate number of Content Addressed Storage cache hits since last server start", 61 }), 62 ActionCacheMisses: prometheus.NewCounter(prometheus.CounterOpts{ 63 Name: "bazel_cache_action_misses", 64 Help: "Approximate number of Content Addressed Storage cache misses since last server start", 65 }), 66 CASMisses: prometheus.NewCounter(prometheus.CounterOpts{ 67 Name: "bazel_cache_cas_misses", 68 Help: "Approximate number of Content Addressed Storage cache misses since last server start", 69 }), 70 LastEvictedAccessAge: prometheus.NewGauge(prometheus.GaugeOpts{ 71 Name: "bazel_cache_last_evicted_access_age", 72 Help: "Hours since last access of most recently evicted file (at eviction time)", 73 }), 74 } 75 prometheus.MustRegister(metrics.DiskFree) 76 prometheus.MustRegister(metrics.DiskUsed) 77 prometheus.MustRegister(metrics.DiskTotal) 78 prometheus.MustRegister(metrics.FilesEvicted) 79 prometheus.MustRegister(metrics.ActionCacheHits) 80 prometheus.MustRegister(metrics.CASHits) 81 prometheus.MustRegister(metrics.ActionCacheMisses) 82 prometheus.MustRegister(metrics.CASMisses) 83 prometheus.MustRegister(metrics.LastEvictedAccessAge) 84 return metrics 85 }