|
| 1 | +/* |
| 2 | + * Copyright (c) 2025. Nydus Developers. All rights reserved. |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +package data |
| 8 | + |
| 9 | +import ( |
| 10 | + "github.com/containerd/nydus-snapshotter/pkg/metrics/types/ttl" |
| 11 | + "github.com/prometheus/client_golang/prometheus" |
| 12 | +) |
| 13 | + |
| 14 | +var ( |
| 15 | + CachePartialHits = ttl.NewGaugeVecWithTTL( |
| 16 | + prometheus.GaugeOpts{ |
| 17 | + Name: "nydusd_cache_partial_hits", |
| 18 | + Help: "Number of partial cache hits (IO needs a part of the chunk)", |
| 19 | + }, |
| 20 | + []string{imageRefLabel}, |
| 21 | + ttl.DefaultTTL, |
| 22 | + ) |
| 23 | + |
| 24 | + CacheWholeHits = ttl.NewGaugeVecWithTTL( |
| 25 | + prometheus.GaugeOpts{ |
| 26 | + Name: "nydusd_cache_whole_hits", |
| 27 | + Help: "Number of whole cache hits (IO needs the entire chunk)", |
| 28 | + }, |
| 29 | + []string{imageRefLabel}, |
| 30 | + ttl.DefaultTTL, |
| 31 | + ) |
| 32 | + |
| 33 | + CacheTotalRequests = ttl.NewGaugeVecWithTTL( |
| 34 | + prometheus.GaugeOpts{ |
| 35 | + Name: "nydusd_cache_total_requests", |
| 36 | + Help: "Total number of cache read requests. Cache hit percentage = (partial_hits + whole_hits) / total", |
| 37 | + }, |
| 38 | + []string{imageRefLabel}, |
| 39 | + ttl.DefaultTTL, |
| 40 | + ) |
| 41 | + |
| 42 | + CacheEntriesCount = ttl.NewGaugeVecWithTTL( |
| 43 | + prometheus.GaugeOpts{ |
| 44 | + Name: "nydusd_cache_entries_count", |
| 45 | + Help: "Number of chunks in ready status", |
| 46 | + }, |
| 47 | + []string{imageRefLabel}, |
| 48 | + ttl.DefaultTTL, |
| 49 | + ) |
| 50 | + |
| 51 | + CachePrefetchDataBytes = ttl.NewGaugeVecWithTTL( |
| 52 | + prometheus.GaugeOpts{ |
| 53 | + Name: "nydusd_cache_prefetch_data_bytes", |
| 54 | + Help: "Total amount of data prefetched, in bytes", |
| 55 | + }, |
| 56 | + []string{imageRefLabel}, |
| 57 | + ttl.DefaultTTL, |
| 58 | + ) |
| 59 | + |
| 60 | + CachePrefetchRequestsCount = ttl.NewGaugeVecWithTTL( |
| 61 | + prometheus.GaugeOpts{ |
| 62 | + Name: "nydusd_cache_prefetch_requests_count", |
| 63 | + Help: "Total prefetch requests issued from storage/blobs or rafs filesystem layer for each file that needs prefetch", |
| 64 | + }, |
| 65 | + []string{imageRefLabel}, |
| 66 | + ttl.DefaultTTL, |
| 67 | + ) |
| 68 | + |
| 69 | + CachePrefetchWorkers = ttl.NewGaugeVecWithTTL( |
| 70 | + prometheus.GaugeOpts{ |
| 71 | + Name: "nydusd_cache_prefetch_workers", |
| 72 | + Help: "Number of prefetch workers", |
| 73 | + }, |
| 74 | + []string{imageRefLabel}, |
| 75 | + ttl.DefaultTTL, |
| 76 | + ) |
| 77 | + |
| 78 | + CachePrefetchUnmergedChunks = ttl.NewGaugeVecWithTTL( |
| 79 | + prometheus.GaugeOpts{ |
| 80 | + Name: "nydusd_cache_prefetch_unmerged_chunks", |
| 81 | + Help: "Number of unmerged chunks", |
| 82 | + }, |
| 83 | + []string{imageRefLabel}, |
| 84 | + ttl.DefaultTTL, |
| 85 | + ) |
| 86 | + |
| 87 | + CachePrefetchCumulativeTimeMillis = ttl.NewGaugeVecWithTTL( |
| 88 | + prometheus.GaugeOpts{ |
| 89 | + Name: "nydusd_cache_prefetch_cumulative_time_millis", |
| 90 | + Help: "Cumulative time latencies in milliseconds of each prefetch request which can be handled in parallel. It starts when the request is born including nydusd processing and schedule and end when the chunk is downloaded and stored. The average prefetch latency can be calculated by `prefetch_cumulative_time_millis / prefetch_requests_count`", |
| 91 | + }, |
| 92 | + []string{imageRefLabel}, |
| 93 | + ttl.DefaultTTL, |
| 94 | + ) |
| 95 | + |
| 96 | + CachePrefetchTotalDurationMillis = ttl.NewGaugeVecWithTTL( |
| 97 | + prometheus.GaugeOpts{ |
| 98 | + Name: "nydusd_cache_prefetch_duration_millis", |
| 99 | + Help: "Total wall clock duration of the prefetch, in milliseconds", |
| 100 | + }, |
| 101 | + []string{imageRefLabel}, |
| 102 | + ttl.DefaultTTL, |
| 103 | + ) |
| 104 | + |
| 105 | + CacheBufferedBackendSize = ttl.NewGaugeVecWithTTL( |
| 106 | + prometheus.GaugeOpts{ |
| 107 | + Name: "nydusd_cache_buffered_backend_size", |
| 108 | + Help: "Size of the buffered backend, in bytes", |
| 109 | + }, |
| 110 | + []string{imageRefLabel}, |
| 111 | + ttl.DefaultTTL, |
| 112 | + ) |
| 113 | +) |
0 commit comments