Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport: Add metricts collection from MTV. #946

Merged
merged 1 commit into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions pkg/controller/migration/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go_library(
srcs = [
"controller.go",
"doc.go",
"metrics.go",
"predicate.go",
"validation.go",
],
Expand All @@ -20,9 +19,8 @@ go_library(
"//pkg/lib/error",
"//pkg/lib/logging",
"//pkg/lib/ref",
"//pkg/monitoring/metrics/forklift-controller",
"//pkg/settings",
"//vendor/github.com/prometheus/client_golang/prometheus",
"//vendor/github.com/prometheus/client_golang/prometheus/promauto",
"//vendor/k8s.io/apimachinery/pkg/api/errors",
"//vendor/k8s.io/apiserver/pkg/storage/names",
"//vendor/sigs.k8s.io/controller-runtime/pkg/client",
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/migration/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
libcnd "github.com/konveyor/forklift-controller/pkg/lib/condition"
"github.com/konveyor/forklift-controller/pkg/lib/logging"
libref "github.com/konveyor/forklift-controller/pkg/lib/ref"
metrics "github.com/konveyor/forklift-controller/pkg/monitoring/metrics/forklift-controller"
"github.com/konveyor/forklift-controller/pkg/settings"
k8serr "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apiserver/pkg/storage/names"
Expand Down Expand Up @@ -84,7 +85,7 @@ func Add(mgr manager.Manager) error {
}

// Gather migration metrics
recordMetrics(mgr.GetClient())
metrics.RecordMigrationMetrics(mgr.GetClient())

return nil
}
Expand Down
72 changes: 0 additions & 72 deletions pkg/controller/migration/metrics.go

This file was deleted.

4 changes: 1 addition & 3 deletions pkg/controller/plan/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ go_library(
"doc.go",
"hook.go",
"kubevirt.go",
"metrics.go",
"migration.go",
"predicate.go",
"util.go",
Expand Down Expand Up @@ -36,13 +35,12 @@ go_library(
"//pkg/lib/itinerary",
"//pkg/lib/logging",
"//pkg/lib/ref",
"//pkg/monitoring/metrics/forklift-controller",
"//pkg/settings",
"//vendor/github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1:k8s_cni_cncf_io",
"//vendor/github.com/openshift/api/template/v1:template",
"//vendor/github.com/openshift/library-go/pkg/template/generator",
"//vendor/github.com/openshift/library-go/pkg/template/templateprocessing",
"//vendor/github.com/prometheus/client_golang/prometheus",
"//vendor/github.com/prometheus/client_golang/prometheus/promauto",
"//vendor/gopkg.in/yaml.v2:yaml_v2",
"//vendor/k8s.io/api/batch/v1:batch",
"//vendor/k8s.io/api/core/v1:core",
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/plan/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
liberr "github.com/konveyor/forklift-controller/pkg/lib/error"
"github.com/konveyor/forklift-controller/pkg/lib/logging"
libref "github.com/konveyor/forklift-controller/pkg/lib/ref"
metrics "github.com/konveyor/forklift-controller/pkg/monitoring/metrics/forklift-controller"
"github.com/konveyor/forklift-controller/pkg/settings"
k8serr "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apiserver/pkg/storage/names"
Expand Down Expand Up @@ -145,7 +146,7 @@ func Add(mgr manager.Manager) error {
}

// Gather migration Plan metrics
recordMetrics(mgr.GetClient())
metrics.RecordMigrationMetrics(mgr.GetClient())

return nil
}
Expand Down
106 changes: 0 additions & 106 deletions pkg/controller/plan/metrics.go

This file was deleted.

18 changes: 18 additions & 0 deletions pkg/monitoring/metrics/forklift-controller/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "forklift-controller",
srcs = [
"metrics.go",
"migration_metrics.go",
"plan_metrics.go",
],
importpath = "github.com/konveyor/forklift-controller/pkg/monitoring/metrics/forklift-controller",
visibility = ["//visibility:public"],
deps = [
"//pkg/apis/forklift/v1beta1",
"//vendor/github.com/prometheus/client_golang/prometheus",
"//vendor/github.com/prometheus/client_golang/prometheus/promauto",
"//vendor/sigs.k8s.io/controller-runtime/pkg/client",
],
)
117 changes: 117 additions & 0 deletions pkg/monitoring/metrics/forklift-controller/metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package forklift_controller

import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)

const (
Succeeded = "Succeeded"
Failed = "Failed"
Executing = "Executing"
Running = "Running"
Pending = "Pending"
Canceled = "Canceled"
Blocked = "Blocked"
Ready = "Ready"
Deleted = "Deleted"
Warm = "Warm"
Cold = "Cold"
Local = "Local"
Remote = "Remote"
)

var (
// 'status' - [ Succeeded, Failed, Executing, Canceled]
// 'provider' - [oVirt, VSphere, Openstack, OVA, Openshift]
// 'mode' - [Cold, Warm]
// 'target' - [Local, Remote]
migrationStatusGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "mtv_migrations_status",
Help: "VM Migrations sorted by status, provider, mode and destination",
},
[]string{
"status",
"provider",
"mode",
"target",
},
)

// 'status' - [ Succeeded, Failed, Executing, Running, Pending, Canceled, Blocked, Deleted]
// 'provider' - [oVirt, VSphere, Openstack, OVA, Openshift]
// 'mode' - [Cold, Warm]
// 'target' - [Local, Remote]
planStatusGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "mtv_plans_status",
Help: "VM migration Plans sorted by status, provider, mode and destination",
},
[]string{
"status",
"provider",
"mode",
"target",
},
)

// 'status' - [ Succeeded, Failed, Executing, Canceled]
// 'provider' - [oVirt, VSphere, Openstack, OVA, Openshift]
// 'mode' - [Cold, Warm]
// 'target' - [Local, Remote]
// 'plan' - [Id]
migrationDurationGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "mtv_migration_duration_seconds",
Help: "Duration of VM migrations in seconds",
},
[]string{"provider", "mode", "target", "plan"},
)

// 'provider' - [oVirt, VSphere, Openstack, OVA, Openshift]
// 'mode' - [Cold, Warm]
// 'target' - [Local, Remote]
// 'plan' - [Id]
dataTransferredGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "mtv_migration_data_transferred_bytes",
Help: "Total data transferred during VM migrations in bytes",
},
[]string{
"provider",
"mode",
"target",
"plan",
},
)

// 'status' - [ Succeeded, Failed, Executing, Canceled]
// 'provider' - [oVirt, VSphere, Openstack, OVA, Openshift]
// 'mode' - [Cold, Warm]
// 'target' - [Local, Remote]
// 'plan' - [Id]
migrationPlanCorrelationStatusGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "mtv_workload_migrations_status",
Help: "VM Migrations status by provider, mode, destination and plan",
},
[]string{
"status",
"provider",
"mode",
"target",
"plan",
},
)

// 'provider' - [oVirt, VSphere, Openstack, OVA, Openshift]
// 'mode' - [Cold, Warm]
// 'target' - [Local, Remote]
migrationDurationHistogram = promauto.NewHistogramVec(prometheus.HistogramOpts{
Name: "mtv_migrations_duration_seconds",
Help: "Histogram of VM migrations duration in seconds",
Buckets: []float64{1 * 3600, 2 * 3600, 5 * 3600, 10 * 3600, 24 * 3600, 48 * 3600}, // 1, 2, 5, 10, 24, 48 hours in seconds
},
[]string{
"provider",
"mode",
"target",
},
)
)
Loading
Loading