Register imagePullThroughput and count with MiB
Signed-off-by: Shukui Yang <yangshukui@bytedance.com>
This commit is contained in:
parent
988ee8ffef
commit
db223271e3
@ -212,8 +212,9 @@ func (c *CRIImageService) PullImage(ctx context.Context, r *runtime.PullImageReq
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mbToByte = 1024 * 1024
|
||||||
size, _ := image.Size(ctx)
|
size, _ := image.Size(ctx)
|
||||||
imagePullingSpeed := float64(size) / time.Since(startTime).Seconds()
|
imagePullingSpeed := float64(size) / mbToByte / time.Since(startTime).Seconds()
|
||||||
imagePullThroughput.Observe(imagePullingSpeed)
|
imagePullThroughput.Observe(imagePullingSpeed)
|
||||||
|
|
||||||
log.G(ctx).Infof("Pulled image %q with image id %q, repo tag %q, repo digest %q, size %q in %s", imageRef, imageID,
|
log.G(ctx).Infof("Pulled image %q with image id %q, repo tag %q, repo digest %q, size %q in %s", imageRef, imageID,
|
||||||
|
@ -24,23 +24,30 @@ import (
|
|||||||
var (
|
var (
|
||||||
imagePulls metrics.LabeledCounter
|
imagePulls metrics.LabeledCounter
|
||||||
inProgressImagePulls metrics.Gauge
|
inProgressImagePulls metrics.Gauge
|
||||||
// pull duration / (image size / 1MBi)
|
// image size in MB / image pull duration in seconds
|
||||||
imagePullThroughput prom.Histogram
|
imagePullThroughput prom.Histogram
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
const (
|
||||||
|
namespace = "containerd"
|
||||||
|
subsystem = "cri_sandboxed"
|
||||||
|
)
|
||||||
|
|
||||||
// these CRI metrics record latencies for successful operations around a sandbox and container's lifecycle.
|
// these CRI metrics record latencies for successful operations around a sandbox and container's lifecycle.
|
||||||
ns := metrics.NewNamespace("containerd", "cri_sandboxed", nil)
|
ns := metrics.NewNamespace(namespace, subsystem, nil)
|
||||||
|
|
||||||
imagePulls = ns.NewLabeledCounter("image_pulls", "succeeded and failed counters", "status")
|
imagePulls = ns.NewLabeledCounter("image_pulls", "succeeded and failed counters", "status")
|
||||||
inProgressImagePulls = ns.NewGauge("in_progress_image_pulls", "in progress pulls", metrics.Total)
|
inProgressImagePulls = ns.NewGauge("in_progress_image_pulls", "in progress pulls", metrics.Total)
|
||||||
imagePullThroughput = prom.NewHistogram(
|
imagePullThroughput = prom.NewHistogram(
|
||||||
prom.HistogramOpts{
|
prom.HistogramOpts{
|
||||||
Name: "image_pulling_throughput",
|
Namespace: namespace,
|
||||||
Help: "image pull throughput",
|
Subsystem: subsystem,
|
||||||
Buckets: prom.DefBuckets,
|
Name: "image_pulling_throughput",
|
||||||
|
Help: "image pull throughput",
|
||||||
|
Buckets: prom.DefBuckets,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
ns.Add(imagePullThroughput)
|
||||||
metrics.Register(ns)
|
metrics.Register(ns)
|
||||||
}
|
}
|
||||||
|
@ -209,8 +209,9 @@ func (c *criService) PullImage(ctx context.Context, r *runtime.PullImageRequest)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mbToByte = 1024 * 1024
|
||||||
size, _ := image.Size(ctx)
|
size, _ := image.Size(ctx)
|
||||||
imagePullingSpeed := float64(size) / time.Since(startTime).Seconds()
|
imagePullingSpeed := float64(size) / mbToByte / time.Since(startTime).Seconds()
|
||||||
imagePullThroughput.Observe(imagePullingSpeed)
|
imagePullThroughput.Observe(imagePullingSpeed)
|
||||||
|
|
||||||
log.G(ctx).Infof("Pulled image %q with image id %q, repo tag %q, repo digest %q, size %q in %s", imageRef, imageID,
|
log.G(ctx).Infof("Pulled image %q with image id %q, repo tag %q, repo digest %q, size %q in %s", imageRef, imageID,
|
||||||
|
@ -42,13 +42,18 @@ var (
|
|||||||
|
|
||||||
imagePulls metrics.LabeledCounter
|
imagePulls metrics.LabeledCounter
|
||||||
inProgressImagePulls metrics.Gauge
|
inProgressImagePulls metrics.Gauge
|
||||||
// pull duration / (image size / 1MBi)
|
// image size in MB / image pull duration in seconds
|
||||||
imagePullThroughput prom.Histogram
|
imagePullThroughput prom.Histogram
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
const (
|
||||||
|
namespace = "containerd"
|
||||||
|
subsystem = "cri"
|
||||||
|
)
|
||||||
|
|
||||||
// these CRI metrics record latencies for successful operations around a sandbox and container's lifecycle.
|
// these CRI metrics record latencies for successful operations around a sandbox and container's lifecycle.
|
||||||
ns := metrics.NewNamespace("containerd", "cri", nil)
|
ns := metrics.NewNamespace(namespace, subsystem, nil)
|
||||||
|
|
||||||
sandboxListTimer = ns.NewTimer("sandbox_list", "time to list sandboxes")
|
sandboxListTimer = ns.NewTimer("sandbox_list", "time to list sandboxes")
|
||||||
sandboxCreateNetworkTimer = ns.NewTimer("sandbox_create_network", "time to create the network for a sandbox")
|
sandboxCreateNetworkTimer = ns.NewTimer("sandbox_create_network", "time to create the network for a sandbox")
|
||||||
@ -72,12 +77,15 @@ func init() {
|
|||||||
inProgressImagePulls = ns.NewGauge("in_progress_image_pulls", "in progress pulls", metrics.Total)
|
inProgressImagePulls = ns.NewGauge("in_progress_image_pulls", "in progress pulls", metrics.Total)
|
||||||
imagePullThroughput = prom.NewHistogram(
|
imagePullThroughput = prom.NewHistogram(
|
||||||
prom.HistogramOpts{
|
prom.HistogramOpts{
|
||||||
Name: "image_pulling_throughput",
|
Namespace: namespace,
|
||||||
Help: "image pull throughput",
|
Subsystem: subsystem,
|
||||||
Buckets: prom.DefBuckets,
|
Name: "image_pulling_throughput",
|
||||||
|
Help: "image pull throughput",
|
||||||
|
Buckets: prom.DefBuckets,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ns.Add(imagePullThroughput)
|
||||||
metrics.Register(ns)
|
metrics.Register(ns)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user