github.com/matrixorigin/matrixone@v1.2.0/pkg/util/metric/v2/dashboard/grafana_dashboard_trace.go (about) 1 // Copyright 2023 Matrix Origin 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package dashboard 16 17 import ( 18 "context" 19 20 "github.com/K-Phoen/grabana/axis" 21 "github.com/K-Phoen/grabana/dashboard" 22 ) 23 24 func (c *DashboardCreator) initTraceDashboard() error { 25 folder, err := c.createFolder(moFolderName) 26 if err != nil { 27 return err 28 } 29 30 build, err := dashboard.New( 31 "Trace Metrics", 32 c.withRowOptions( 33 c.initTraceDurationRow(), 34 c.initCUStatusRow(), 35 )...) 36 if err != nil { 37 return err 38 } 39 _, err = c.cli.UpsertDashboard(context.Background(), folder, build) 40 return err 41 } 42 43 func (c *DashboardCreator) initTraceDurationRow() dashboard.Option { 44 return dashboard.Row( 45 "Trace Collector duration", 46 c.getMultiHistogram( 47 []string{ 48 c.getMetricWithFilter(`mo_trace_collector_duration_seconds_bucket`, `type="collect"`), 49 c.getMetricWithFilter(`mo_trace_collector_duration_seconds_bucket`, `type="generate_awake"`), 50 c.getMetricWithFilter(`mo_trace_collector_duration_seconds_bucket`, `type="generate_awake_discard"`), 51 c.getMetricWithFilter(`mo_trace_collector_duration_seconds_bucket`, `type="generate_delay"`), 52 c.getMetricWithFilter(`mo_trace_collector_duration_seconds_bucket`, `type="generate"`), 53 c.getMetricWithFilter(`mo_trace_collector_duration_seconds_bucket`, `type="generate_discard"`), 54 c.getMetricWithFilter(`mo_trace_collector_duration_seconds_bucket`, `type="export"`), 55 }, 56 []string{ 57 "collect", 58 "generate_awake", 59 "generate_awake_discard", 60 "generate_delay", 61 "generate", 62 "generate_discard", 63 "export", 64 }, 65 []float64{0.50, 0.8, 0.90, 0.99}, 66 []float32{3, 3, 3, 3, 3}, 67 axis.Unit("s"), 68 axis.Min(0))..., 69 ) 70 } 71 72 func (c *DashboardCreator) initCUStatusRow() dashboard.Option { 73 return dashboard.Row( 74 "CU Status", 75 c.withMultiGraph( 76 "Negative CU status", 77 4, 78 []string{ 79 `sum(delta(` + c.getMetricWithFilter("mo_trace_negative_cu_total", "") + `[$interval])) by (type)`, 80 }, 81 []string{"{{ type }}"}), 82 ) 83 }