github.com/matrixorigin/matrixone@v1.2.0/pkg/util/metric/v2/dashboard/grafana_dashboard_runtime.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) initRuntimeDashboard() error { 25 folder, err := c.createFolder(moFolderName) 26 if err != nil { 27 return err 28 } 29 30 build, err := dashboard.New( 31 "Go Runtime Metrics", 32 c.withRowOptions( 33 c.initMemoryRow(), 34 c.initGCRow(), 35 c.initGoroutineRow(), 36 )...) 37 if err != nil { 38 return err 39 } 40 _, err = c.cli.UpsertDashboard(context.Background(), folder, build) 41 return err 42 } 43 44 func (c *DashboardCreator) initGCRow() dashboard.Option { 45 return dashboard.Row( 46 "Go GC Status", 47 c.getHistogramWithExtraBy( 48 "STW duration", 49 c.getMetricWithFilter(`go_gc_pauses_seconds_bucket`, ``), 50 []float64{0.8, 0.90, 0.95, 0.99}, 51 12, 52 c.by, 53 axis.Unit("s"), 54 axis.Min(0)), 55 ) 56 } 57 58 func (c *DashboardCreator) initGoroutineRow() dashboard.Option { 59 return dashboard.Row( 60 "Goroutine Status", 61 c.withGraph( 62 "Goroutine count", 63 6, 64 `sum(`+c.getMetricWithFilter("go_goroutines", "")+`) by (`+c.by+`)`, 65 "{{ "+c.by+" }}"), 66 67 c.getHistogramWithExtraBy( 68 "Schedule latency duration", 69 c.getMetricWithFilter(`go_sched_latencies_seconds_bucket`, ``), 70 []float64{0.8, 0.90, 0.95, 0.99}, 71 6, 72 c.by, 73 axis.Unit("s"), 74 axis.Min(0)), 75 ) 76 } 77 78 func (c *DashboardCreator) initMemoryRow() dashboard.Option { 79 return dashboard.Row( 80 "Memory Status", 81 c.withGraph( 82 "Live Objects", 83 3, 84 `sum(`+c.getMetricWithFilter("go_gc_heap_objects_objects", "")+`) by (`+c.by+`)`, 85 "{{ "+c.by+" }}"), 86 87 c.withGraph( 88 "Free and ready to return system", 89 3, 90 `sum(`+c.getMetricWithFilter("go_memory_classes_heap_free_bytes", "")+`) by (`+c.by+`)`, 91 "{{ "+c.by+" }}", 92 axis.Unit("bytes"), 93 axis.Min(0)), 94 95 c.withGraph( 96 "Dead objects and not marked free live objects", 97 3, 98 `sum(`+c.getMetricWithFilter("go_memory_classes_heap_objects_bytes", "")+`) by (`+c.by+`)`, 99 "{{ "+c.by+" }}", 100 axis.Unit("bytes"), 101 axis.Min(0)), 102 103 c.withGraph( 104 "Released to system", 105 3, 106 `sum(`+c.getMetricWithFilter("go_memory_classes_heap_released_bytes", "")+`) by (`+c.by+`)`, 107 "{{ "+c.by+" }}", 108 axis.Unit("bytes"), 109 axis.Min(0)), 110 111 c.withGraph( 112 "Heap Allocation Bytes/s", 113 3, 114 `sum(rate(`+c.getMetricWithFilter("go_gc_heap_allocs_bytes_total", "")+`[$interval])) by (`+c.by+`)`, 115 "{{ "+c.by+" }}", 116 axis.Unit("bytes"), 117 axis.Min(0)), 118 119 c.withGraph( 120 "Heap Free Bytes/s", 121 3, 122 `sum(rate(`+c.getMetricWithFilter("go_gc_heap_frees_bytes_total", "")+`[$interval])) by (`+c.by+`)`, 123 "{{ "+c.by+" }}", 124 axis.Unit("bytes"), 125 axis.Min(0)), 126 127 c.withGraph( 128 "Heap Allocation Object/s", 129 3, 130 `sum(rate(`+c.getMetricWithFilter("go_gc_heap_allocs_objects_total", "")+`[$interval])) by (`+c.by+`)`, 131 "{{ "+c.by+" }}"), 132 133 c.withGraph( 134 "Heap Free Object/s", 135 3, 136 `sum(rate(`+c.getMetricWithFilter("go_gc_heap_frees_objects_total", "")+`[$interval])) by (`+c.by+`)`, 137 "{{ "+c.by+" }}"), 138 139 c.getHistogram( 140 "Allocation bytes size", 141 c.getMetricWithFilter(`go_gc_heap_allocs_by_size_bytes_bucket`, ``), 142 []float64{0.8, 0.90, 0.95, 0.99}, 143 12, 144 axis.Unit("bytes"), 145 axis.Min(0)), 146 ) 147 }