From 5cd7ba0a72f8a274e4dbd068328de2a6916fb88e Mon Sep 17 00:00:00 2001 From: vankichi Date: Wed, 13 Mar 2024 16:56:11 +0900 Subject: [PATCH] :recycle: Update dashboard and rename Signed-off-by: vankichi --- .../metrics/tools/benchmark/benchmark.go | 137 +++- .../metrics/tools/benchmark/benchmark_test.go | 299 +++++++++ .../10-vald-benchmark-operator.yaml | 595 ++++++++++++++++-- .../benchmark/operator/service/operator.go | 15 +- 4 files changed, 957 insertions(+), 89 deletions(-) create mode 100644 internal/observability/metrics/tools/benchmark/benchmark_test.go diff --git a/internal/observability/metrics/tools/benchmark/benchmark.go b/internal/observability/metrics/tools/benchmark/benchmark.go index ff64e8ddc5..6c45c71f2c 100644 --- a/internal/observability/metrics/tools/benchmark/benchmark.go +++ b/internal/observability/metrics/tools/benchmark/benchmark.go @@ -41,6 +41,15 @@ const ( completeBenchmarkJobCount = "benchmark_operator_complete_benchmark_job" completeBenchmarkJobCountDescription = "Benchmark Operator complete benchmark job count" + + appliedJobCount = "benchmark_operator_applied_job" + appliedJobCountDescription = "Benchmark Operator applied job count" + + runningJobCount = "benchmark_operator_running_job" + runningJobCountDescription = "Benchmark Operator running job count" + + completeJobCount = "benchmark_operator_complete_job" + completeJobCountDescription = "Benchmark Operator complete job count" ) const ( @@ -89,12 +98,66 @@ func (om *operatorMetrics) View() ([]metrics.View, error) { Aggregation: view.AggregationLastValue{}, }, ), + view.NewView( + view.Instrument{ + Name: appliedBenchmarkJobCount, + Description: appliedBenchmarkJobCountDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: runningBenchmarkJobCount, + Description: runningBenchmarkJobCountDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: completeBenchmarkJobCount, + Description: completeBenchmarkJobCountDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: appliedJobCount, + Description: appliedJobCountDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: runningJobCount, + Description: runningJobCountDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), + view.NewView( + view.Instrument{ + Name: completeJobCount, + Description: completeJobCountDescription, + }, + view.Stream{ + Aggregation: view.AggregationLastValue{}, + }, + ), }, nil } // TODO: implement here func (om *operatorMetrics) Register(m metrics.Meter) error { - appliedScCount, err := m.Int64ObservableCounter( + appliedScenarioCount, err := m.Int64ObservableCounter( appliedScenarioCount, metrics.WithDescription(appliedScenarioCountDescription), metrics.WithUnit(metrics.Dimensionless), @@ -102,7 +165,7 @@ func (om *operatorMetrics) Register(m metrics.Meter) error { if err != nil { return err } - runningScCount, err := m.Int64ObservableCounter( + runningScenarioCount, err := m.Int64ObservableCounter( runningScenarioCount, metrics.WithDescription(runningScenarioCountDescription), metrics.WithUnit(metrics.Dimensionless), @@ -110,7 +173,7 @@ func (om *operatorMetrics) Register(m metrics.Meter) error { if err != nil { return err } - completeScCount, err := m.Int64ObservableCounter( + completeScenarioCount, err := m.Int64ObservableCounter( completeScenarioCount, metrics.WithDescription(completeScenarioCountDescription), metrics.WithUnit(metrics.Dimensionless), @@ -119,7 +182,7 @@ func (om *operatorMetrics) Register(m metrics.Meter) error { return err } - appliedBjCount, err := m.Int64ObservableCounter( + appliedBenchJobCount, err := m.Int64ObservableCounter( appliedBenchmarkJobCount, metrics.WithDescription(appliedScenarioCountDescription), metrics.WithUnit(metrics.Dimensionless), @@ -127,7 +190,7 @@ func (om *operatorMetrics) Register(m metrics.Meter) error { if err != nil { return err } - runningBjCount, err := m.Int64ObservableCounter( + runningBenchJobCount, err := m.Int64ObservableCounter( runningBenchmarkJobCount, metrics.WithDescription(runningScenarioCountDescription), metrics.WithUnit(metrics.Dimensionless), @@ -135,7 +198,31 @@ func (om *operatorMetrics) Register(m metrics.Meter) error { if err != nil { return err } - completeBjCount, err := m.Int64ObservableCounter( + completeBenchJobCount, err := m.Int64ObservableCounter( + completeBenchmarkJobCount, + metrics.WithDescription(completeScenarioCountDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + appliedJobCount, err := m.Int64ObservableCounter( + appliedJobCount, + metrics.WithDescription(appliedJobCountDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + runningJobCount, err := m.Int64ObservableCounter( + runningJobCount, + metrics.WithDescription(runningJobCountDescription), + metrics.WithUnit(metrics.Dimensionless), + ) + if err != nil { + return err + } + completeJobCount, err := m.Int64ObservableCounter( completeBenchmarkJobCount, metrics.WithDescription(completeScenarioCountDescription), metrics.WithUnit(metrics.Dimensionless), @@ -143,7 +230,6 @@ func (om *operatorMetrics) Register(m metrics.Meter) error { if err != nil { return err } - _, err = m.RegisterCallback( func(_ context.Context, o api.Observer) error { // scenario status @@ -152,7 +238,7 @@ func (om *operatorMetrics) Register(m metrics.Meter) error { running: 0, complete: 0, } - for k, v := range om.op.LenBenchSC() { + for k, v := range om.op.GetScenarioStatus() { sst[applied] += v if k == v1.BenchmarkScenarioCompleted { sst[complete] += v @@ -160,9 +246,9 @@ func (om *operatorMetrics) Register(m metrics.Meter) error { sst[running] += v } } - o.ObserveInt64(appliedScCount, sst[applied]) - o.ObserveInt64(runningScCount, sst[running]) - o.ObserveInt64(completeScCount, sst[complete]) + o.ObserveInt64(appliedScenarioCount, sst[applied]) + o.ObserveInt64(runningScenarioCount, sst[running]) + o.ObserveInt64(completeScenarioCount, sst[complete]) // benchmark job status bst := map[string]int64{ @@ -170,25 +256,28 @@ func (om *operatorMetrics) Register(m metrics.Meter) error { running: 0, complete: 0, } - for k, v := range om.op.LenBenchBJ() { - sst[applied] += v + for k, v := range om.op.GetBenchmarkJobStatus() { + bst[applied] += v if k == v1.BenchmarkJobCompleted { - sst[complete] += v + bst[complete] += v } else { - sst[running] += v + bst[running] += v } } - o.ObserveInt64(appliedBjCount, bst[applied]) - o.ObserveInt64(runningBjCount, bst[running]) - o.ObserveInt64(completeBjCount, bst[complete]) + o.ObserveInt64(appliedBenchJobCount, bst[applied]) + o.ObserveInt64(runningBenchJobCount, bst[running]) + o.ObserveInt64(completeBenchJobCount, bst[complete]) return nil }, - appliedScCount, - runningScCount, - completeScCount, - appliedBjCount, - runningBjCount, - completeBjCount, + appliedScenarioCount, + runningScenarioCount, + completeScenarioCount, + appliedBenchJobCount, + runningBenchJobCount, + completeBenchJobCount, + appliedJobCount, + runningJobCount, + completeJobCount, ) return nil } diff --git a/internal/observability/metrics/tools/benchmark/benchmark_test.go b/internal/observability/metrics/tools/benchmark/benchmark_test.go new file mode 100644 index 0000000000..ba64190d5a --- /dev/null +++ b/internal/observability/metrics/tools/benchmark/benchmark_test.go @@ -0,0 +1,299 @@ +// Copyright (C) 2019-2024 vdaas.org vald team +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// You may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package benchmark + +import ( + "reflect" + "testing" + + "github.com/pkg/errors" + "github.com/vdaas/vald/internal/observability/metrics" + "github.com/vdaas/vald/internal/test/goleak" + "github.com/vdaas/vald/pkg/tools/benchmark/operator/service" +) + +func TestNew(t *testing.T) { + type args struct { + om service.Operator + } + type want struct { + want metrics.Metric + } + type test struct { + name string + args args + want want + checkFunc func(want, metrics.Metric) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) + } + defaultCheckFunc := func(w want, got metrics.Metric) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + om:nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + om:nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt, test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(tt, test.args) + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + + got := New(test.args.om) + if err := checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + +func Test_operatorMetrics_View(t *testing.T) { + type fields struct { + op service.Operator + } + type want struct { + want []metrics.View + err error + } + type test struct { + name string + fields fields + want want + checkFunc func(want, []metrics.View, error) error + beforeFunc func(*testing.T) + afterFunc func(*testing.T) + } + defaultCheckFunc := func(w want, got []metrics.View, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + fields: fields { + op:nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + op:nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt) + } + if test.afterFunc != nil { + defer test.afterFunc(tt) + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + om := &operatorMetrics{ + op: test.fields.op, + } + + got, err := om.View() + if err := checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + +func Test_operatorMetrics_Register(t *testing.T) { + type args struct { + m metrics.Meter + } + type fields struct { + op service.Operator + } + type want struct { + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, error) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) + } + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + m:nil, + }, + fields: fields { + op:nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + m:nil, + }, + fields: fields { + op:nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt, test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(tt, test.args) + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + om := &operatorMetrics{ + op: test.fields.op, + } + + err := om.Register(test.args.m) + if err := checkFunc(test.want, err); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} diff --git a/k8s/metrics/grafana/dashboards/10-vald-benchmark-operator.yaml b/k8s/metrics/grafana/dashboards/10-vald-benchmark-operator.yaml index 5747988b61..9ee9d26a62 100644 --- a/k8s/metrics/grafana/dashboards/10-vald-benchmark-operator.yaml +++ b/k8s/metrics/grafana/dashboards/10-vald-benchmark-operator.yaml @@ -79,8 +79,7 @@ data: } ] }, - "unit": "none", - "unitScale": true + "unit": "none" }, "overrides": [] }, @@ -91,7 +90,6 @@ data: "y": 0 }, "id": 14, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "value", @@ -110,7 +108,7 @@ data: "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.3.3", + "pluginVersion": "10.4.0", "targets": [ { "datasource": { @@ -161,8 +159,7 @@ data: } ] }, - "unit": "none", - "unitScale": true + "unit": "none" }, "overrides": [] }, @@ -173,7 +170,6 @@ data: "y": 0 }, "id": 16, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "value", @@ -192,7 +188,7 @@ data: "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.3.3", + "pluginVersion": "10.4.0", "targets": [ { "datasource": { @@ -242,8 +238,7 @@ data: } ] }, - "unit": "none", - "unitScale": true + "unit": "none" }, "overrides": [] }, @@ -254,7 +249,6 @@ data: "y": 0 }, "id": 34, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "value", @@ -273,7 +267,7 @@ data: "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.3.3", + "pluginVersion": "10.4.0", "targets": [ { "datasource": { @@ -327,8 +321,7 @@ data: } ] }, - "unit": "none", - "unitScale": true + "unit": "none" }, "overrides": [] }, @@ -339,7 +332,6 @@ data: "y": 0 }, "id": 19, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "value", @@ -358,7 +350,7 @@ data: "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.3.3", + "pluginVersion": "10.4.0", "targets": [ { "datasource": { @@ -414,8 +406,7 @@ data: } ] }, - "unit": "decbytes", - "unitScale": true + "unit": "decbytes" }, "overrides": [] }, @@ -426,7 +417,6 @@ data: "y": 0 }, "id": 20, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "value", @@ -445,7 +435,7 @@ data: "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.3.3", + "pluginVersion": "10.4.0", "targets": [ { "datasource": { @@ -496,8 +486,7 @@ data: } ] }, - "unit": "none", - "unitScale": true + "unit": "none" }, "overrides": [] }, @@ -508,7 +497,6 @@ data: "y": 3 }, "id": 17, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "value", @@ -527,7 +515,7 @@ data: "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.3.3", + "pluginVersion": "10.4.0", "targets": [ { "datasource": { @@ -577,8 +565,7 @@ data: } ] }, - "unit": "none", - "unitScale": true + "unit": "none" }, "overrides": [] }, @@ -589,7 +576,6 @@ data: "y": 3 }, "id": 18, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "value", @@ -609,7 +595,7 @@ data: "wideLayout": true }, "pluginVersin": "8.0.1", - "pluginVersion": "10.3.3", + "pluginVersion": "10.4.0", "targets": [ { "datasource": { @@ -649,19 +635,305 @@ data: } ] }, - "unit": "string", - "unitScale": true + "unit": "string" }, "overrides": [] }, "gridPos": { "h": 3, - "w": 8, + "w": 4, "x": 0, "y": 6 }, + "id": 42, + "maxDataPoints": 100, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "/^Value$/", + "values": false + }, + "showPercentChange": false, + "text": {}, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.4.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "sum(benchmark_operator_applied_scenario{exported_kubernetes_namespace=\"$Namespace\", kubernetes_name=~\"$ReplicaSet\", target_pod=~\"$PodName\"})", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "__auto", + "refId": "A" + } + ], + "title": "All Scenario Count", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "fieldMinMax": false, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "string" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 4, + "y": 6 + }, + "id": 43, + "maxDataPoints": 100, + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "/^Value$/", + "values": false + }, + "showPercentChange": false, + "text": {}, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.4.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "sum(benchmark_operator_running_scenario{exported_kubernetes_namespace=\"$Namespace\", kubernetes_name=~\"$ReplicaSet\", target_pod=~\"$PodName\"})", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "__auto", + "refId": "A" + } + ], + "title": "Running Scenario Count", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "string" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 8, + "y": 6 + }, + "id": 44, + "maxDataPoints": 100, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "/^Value$/", + "values": false + }, + "showPercentChange": false, + "text": {}, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.4.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "sum(benchmark_operator_complete_scenario{exported_kubernetes_namespace=\"$Namespace\", kubernetes_name=~\"$ReplicaSet\", target_pod=~\"$PodName\"})", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "__auto", + "refId": "A" + } + ], + "title": "Completed Scenario Count", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "string" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 8, + "x": 12, + "y": 6 + }, + "id": 41, + "maxDataPoints": 100, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "/^image$/", + "values": false + }, + "showPercentChange": false, + "text": {}, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.4.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "label_replace(benchmark_operator_info{exported_kubernetes_namespace=\"$Namespace\", kubernetes_name=~\"$ReplicaSet\", target_pod=~\"$PodName\"}, \"image\", \"$1\", \"image\", \"(.*):.*\")", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "__auto", + "refId": "A" + } + ], + "title": "Job Image Name", + "transformations": [ + { + "id": "partitionByValues", + "options": { + "keepFields": true, + "naming": { + "asLabels": true + } + } + } + ], + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "string" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 20, + "y": 6 + }, "id": 40, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "value", @@ -680,7 +952,76 @@ data: "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.3.3", + "pluginVersion": "10.4.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "label_replace(benchmark_operator_info{exported_kubernetes_namespace=\"$Namespace\", kubernetes_name=~\"$ReplicaSet\", target_pod=~\"$PodName\"}, \"image\", \"$1\", \"image\", \".*:(.*)\")", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "__auto", + "refId": "A" + } + ], + "title": "Job Image Version", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "string" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 0, + "y": 9 + }, + "id": 45, + "maxDataPoints": 100, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "/^Value$/", + "values": false + }, + "showPercentChange": false, + "text": {}, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.4.0", "targets": [ { "datasource": { @@ -688,7 +1029,7 @@ data: "uid": "prometheus" }, "editorMode": "code", - "expr": "benchmark_operator_info{exported_kubernetes_namespace=\"$Namespace\", kubernetes_name=~\"$ReplicaSet\", target_pod=~\"$PodName\"}", + "expr": "sum(benchmark_operator_applied_benchmark_job{exported_kubernetes_namespace=\"$Namespace\", kubernetes_name=~\"$ReplicaSet\", target_pod=~\"$PodName\"})", "format": "table", "instant": true, "interval": "", @@ -696,8 +1037,146 @@ data: "refId": "A" } ], - "title": "Job Image", - "transformations": [], + "title": "All Benchmark Job Count", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "fieldMinMax": false, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "string" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 4, + "y": 9 + }, + "id": 46, + "maxDataPoints": 100, + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "/^Value$/", + "values": false + }, + "showPercentChange": false, + "text": {}, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.4.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "sum(benchmark_operator_running_benchmark_job{exported_kubernetes_namespace=\"$Namespace\", kubernetes_name=~\"$ReplicaSet\", target_pod=~\"$PodName\"})", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "__auto", + "refId": "A" + } + ], + "title": "Running Benchmark Job Count", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "string" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 8, + "y": 9 + }, + "id": 47, + "maxDataPoints": 100, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "/^Value$/", + "values": false + }, + "showPercentChange": false, + "text": {}, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.4.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "sum(benchmark_operator_complete_benchmark_job{exported_kubernetes_namespace=\"$Namespace\", kubernetes_name=~\"$ReplicaSet\", target_pod=~\"$PodName\"})", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "__auto", + "refId": "A" + } + ], + "title": "Completed Benchmark Job Count", "type": "stat" }, { @@ -706,7 +1185,7 @@ data: "h": 1, "w": 24, "x": 0, - "y": 9 + "y": 12 }, "id": 39, "panels": [], @@ -724,8 +1203,7 @@ data: }, "fieldConfig": { "defaults": { - "links": [], - "unitScale": true + "links": [] }, "overrides": [] }, @@ -735,7 +1213,7 @@ data: "h": 8, "w": 12, "x": 0, - "y": 10 + "y": 13 }, "hiddenSeries": false, "id": 22, @@ -755,7 +1233,7 @@ data: "alertThreshold": true }, "percentage": false, - "pluginVersion": "10.3.3", + "pluginVersion": "10.4.0", "pointradius": 2, "points": false, "renderer": "flot", @@ -850,8 +1328,7 @@ data: }, "fieldConfig": { "defaults": { - "links": [], - "unitScale": true + "links": [] }, "overrides": [] }, @@ -861,7 +1338,7 @@ data: "h": 8, "w": 12, "x": 12, - "y": 10 + "y": 13 }, "hiddenSeries": false, "id": 27, @@ -881,7 +1358,7 @@ data: "alertThreshold": true }, "percentage": false, - "pluginVersion": "10.3.3", + "pluginVersion": "10.4.0", "pointradius": 2, "points": false, "renderer": "flot", @@ -976,8 +1453,7 @@ data: }, "fieldConfig": { "defaults": { - "links": [], - "unitScale": true + "links": [] }, "overrides": [] }, @@ -987,7 +1463,7 @@ data: "h": 8, "w": 12, "x": 0, - "y": 18 + "y": 21 }, "hiddenSeries": false, "id": 30, @@ -1008,7 +1484,7 @@ data: "alertThreshold": true }, "percentage": false, - "pluginVersion": "10.3.3", + "pluginVersion": "10.4.0", "pointradius": 2, "points": false, "renderer": "flot", @@ -1086,8 +1562,7 @@ data: }, "fieldConfig": { "defaults": { - "links": [], - "unitScale": true + "links": [] }, "overrides": [] }, @@ -1097,7 +1572,7 @@ data: "h": 8, "w": 12, "x": 12, - "y": 18 + "y": 21 }, "hiddenSeries": false, "id": 32, @@ -1118,7 +1593,7 @@ data: "alertThreshold": true }, "percentage": false, - "pluginVersion": "10.3.3", + "pluginVersion": "10.4.0", "pointradius": 2, "points": false, "renderer": "flot", @@ -1209,8 +1684,7 @@ data: }, "fieldConfig": { "defaults": { - "links": [], - "unitScale": true + "links": [] }, "overrides": [] }, @@ -1220,7 +1694,7 @@ data: "h": 8, "w": 12, "x": 0, - "y": 26 + "y": 29 }, "hiddenSeries": false, "id": 36, @@ -1240,7 +1714,7 @@ data: "alertThreshold": true }, "percentage": false, - "pluginVersion": "10.3.3", + "pluginVersion": "10.4.0", "pointradius": 2, "points": false, "renderer": "flot", @@ -1305,8 +1779,7 @@ data: }, "fieldConfig": { "defaults": { - "links": [], - "unitScale": true + "links": [] }, "overrides": [] }, @@ -1316,7 +1789,7 @@ data: "h": 8, "w": 12, "x": 12, - "y": 26 + "y": 29 }, "hiddenSeries": false, "id": 38, @@ -1337,7 +1810,7 @@ data: "alertThreshold": true }, "percentage": false, - "pluginVersion": "10.3.3", + "pluginVersion": "10.4.0", "pointradius": 2, "points": false, "renderer": "flot", diff --git a/pkg/tools/benchmark/operator/service/operator.go b/pkg/tools/benchmark/operator/service/operator.go index 5100ec52f5..89beca20b9 100644 --- a/pkg/tools/benchmark/operator/service/operator.go +++ b/pkg/tools/benchmark/operator/service/operator.go @@ -38,8 +38,9 @@ import ( type Operator interface { PreStart(context.Context) error Start(context.Context) (<-chan error, error) - LenBenchSC() map[v1.ValdBenchmarkScenarioStatus]int64 - LenBenchBJ() map[v1.BenchmarkJobStatus]int64 + GetScenarioStatus() map[v1.ValdBenchmarkScenarioStatus]int64 + GetBenchmarkJobStatus() map[v1.BenchmarkJobStatus]int64 + // GetJobStatus() map[v1.BenchmarkJobStatus]int64 } type scenario struct { @@ -642,7 +643,7 @@ func (o *operator) checkAtomics() error { return nil } -func (o *operator) LenBenchSC() map[v1.ValdBenchmarkScenarioStatus]int64 { +func (o *operator) GetScenarioStatus() map[v1.ValdBenchmarkScenarioStatus]int64 { m := map[v1.ValdBenchmarkScenarioStatus]int64{ v1.BenchmarkScenarioAvailable: 0, v1.BenchmarkScenarioHealthy: 0, @@ -661,7 +662,7 @@ func (o *operator) LenBenchSC() map[v1.ValdBenchmarkScenarioStatus]int64 { return m } -func (o *operator) LenBenchBJ() map[v1.BenchmarkJobStatus]int64 { +func (o *operator) GetBenchmarkJobStatus() map[v1.BenchmarkJobStatus]int64 { m := map[v1.BenchmarkJobStatus]int64{ v1.BenchmarkJobAvailable: 0, v1.BenchmarkJobHealthy: 0, @@ -680,6 +681,12 @@ func (o *operator) LenBenchBJ() map[v1.BenchmarkJobStatus]int64 { return m } +// func (o *operator) GetJobStatus() map[job.JobStatus]int64 { +// m := map[job.JobStatus]int64{} +// // if js := o.getAtomicJob() +// return m +// } + func (*operator) PreStart(context.Context) error { log.Infof("[benchmark scenario operator] start vald benchmark scenario operator") return nil