github.com/matrixorigin/matrixone@v1.2.0/pkg/util/metric/v2/dashboard/grafana_dashboard_fs.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) initFileServiceDashboard() error { 25 folder, err := c.createFolder(moFolderName) 26 if err != nil { 27 return err 28 } 29 30 build, err := dashboard.New( 31 "FileService Metrics", 32 c.withRowOptions( 33 c.initFSOverviewRow(), 34 c.initFSReadWriteDurationRow(), 35 c.initFSReadWriteBytesRow(), 36 c.initFSS3ConnOverviewRow(), 37 c.initFSS3ConnDurationRow(), 38 c.initFSIOMergerDurationRow(), 39 )...) 40 if err != nil { 41 return err 42 } 43 _, err = c.cli.UpsertDashboard(context.Background(), folder, build) 44 return err 45 } 46 47 func (c *DashboardCreator) initFSOverviewRow() dashboard.Option { 48 return dashboard.Row( 49 "FileService Overview", 50 c.withMultiGraph( 51 "S3 Read requests", 52 6, 53 []string{ 54 `sum(rate(` + c.getMetricWithFilter("mo_fs_read_total", `type="s3"`) + `[$interval]))`, 55 `sum(rate(` + c.getMetricWithFilter("mo_fs_read_total", `type="hit-mem"`) + `[$interval]))`, 56 `sum(rate(` + c.getMetricWithFilter("mo_fs_read_total", `type="hit-disk"`) + `[$interval]))`, 57 `sum(rate(` + c.getMetricWithFilter("mo_fs_read_total", `type="hit-remote"`) + `[$interval]))`, 58 }, 59 []string{ 60 "s3", 61 "hit-mem", 62 "hit-dist", 63 "hit-remote", 64 }), 65 66 c.withMultiGraph( 67 "S3 Write requests", 68 6, 69 []string{ 70 `sum(rate(` + c.getMetricWithFilter("mo_fs_write_total", `type="s3"`) + `[$interval]))`, 71 `sum(rate(` + c.getMetricWithFilter("mo_fs_write_total", `type="local"`) + `[$interval]))`, 72 }, 73 []string{ 74 "s3", 75 "local", 76 }), 77 ) 78 } 79 80 func (c *DashboardCreator) initFSReadWriteDurationRow() dashboard.Option { 81 return dashboard.Row( 82 "FileService read write duration", 83 c.getMultiHistogram( 84 []string{ 85 c.getMetricWithFilter(`mo_fs_s3_io_duration_seconds_bucket`, `type="read"`), 86 c.getMetricWithFilter(`mo_fs_s3_io_duration_seconds_bucket`, `type="write"`), 87 c.getMetricWithFilter(`mo_fs_local_io_duration_seconds_bucket`, `type="read"`), 88 c.getMetricWithFilter(`mo_fs_local_io_duration_seconds_bucket`, `type="write"`), 89 c.getMetricWithFilter(`mo_fs_s3_io_duration_seconds_bucket`, `type="list"`), 90 c.getMetricWithFilter(`mo_fs_s3_io_duration_seconds_bucket`, `type="stat"`), 91 }, 92 []string{ 93 "s3-read", 94 "s3-write", 95 "local-read", 96 "local-write", 97 "s3-list", 98 "s3-stat", 99 }, 100 []float64{0.50, 0.8, 0.90, 0.99}, 101 []float32{3, 3, 3, 3}, 102 axis.Unit("s"), 103 axis.Min(0))..., 104 ) 105 } 106 107 func (c *DashboardCreator) initFSReadWriteBytesRow() dashboard.Option { 108 return dashboard.Row( 109 "FileService read write bytes", 110 c.getMultiHistogram( 111 []string{ 112 c.getMetricWithFilter(`mo_fs_s3_io_bytes_bucket`, `type="read"`), 113 c.getMetricWithFilter(`mo_fs_s3_io_bytes_bucket`, `type="write"`), 114 c.getMetricWithFilter(`mo_fs_local_io_bytes_bucket`, `type="read"`), 115 c.getMetricWithFilter(`mo_fs_local_io_bytes_bucket`, `type="write"`), 116 }, 117 []string{ 118 "s3-read", 119 "s3-write", 120 "local-read", 121 "local-write", 122 }, 123 []float64{0.50, 0.8, 0.90, 0.99}, 124 []float32{3, 3, 3, 3}, 125 axis.Unit("bytes"), 126 axis.Min(0))..., 127 ) 128 } 129 130 func (c *DashboardCreator) initFSS3ConnOverviewRow() dashboard.Option { 131 return dashboard.Row( 132 "FileService S3 connection overview", 133 c.withGraph( 134 "Connect", 135 6, 136 `sum(rate(`+c.getMetricWithFilter("mo_fs_s3_conn_duration_seconds_count", `type="connect"`)+`[$interval]))`, 137 ""), 138 c.withGraph( 139 "DNS Resolve", 140 6, 141 `sum(rate(`+c.getMetricWithFilter("mo_fs_s3_conn_duration_seconds_count", `type="dns-resolve"`)+`[$interval]))`, 142 ""), 143 ) 144 } 145 146 func (c *DashboardCreator) initFSS3ConnDurationRow() dashboard.Option { 147 return dashboard.Row( 148 "FileService s3 connection duration", 149 c.getMultiHistogram( 150 []string{ 151 c.getMetricWithFilter(`mo_fs_s3_conn_duration_seconds_bucket`, `type="connect"`), 152 c.getMetricWithFilter(`mo_fs_s3_conn_duration_seconds_bucket`, `type="get-conn"`), 153 c.getMetricWithFilter(`mo_fs_s3_conn_duration_seconds_bucket`, `type="dns-resolve"`), 154 c.getMetricWithFilter(`mo_fs_s3_conn_duration_seconds_bucket`, `type="tls-handshake"`), 155 }, 156 []string{ 157 "connect", 158 "get-conn", 159 "dns-resolve", 160 "tls-handshake", 161 }, 162 []float64{0.50, 0.8, 0.90, 0.99}, 163 []float32{3, 3, 3, 3}, 164 axis.Unit("s"), 165 axis.Min(0))..., 166 ) 167 } 168 169 func (c *DashboardCreator) initFSIOMergerDurationRow() dashboard.Option { 170 return dashboard.Row( 171 "FileService io merger duration", 172 c.getMultiHistogram( 173 []string{ 174 c.getMetricWithFilter(`mo_fs_io_merger_duration`, `type="wait"`), 175 c.getMetricWithFilter(`mo_fs_io_merger_duration`, `type="initiate"`), 176 }, 177 []string{ 178 "wait", 179 "initiate", 180 }, 181 []float64{0.50, 0.8, 0.90, 0.99}, 182 []float32{3, 3, 3, 3}, 183 axis.Unit("seconds"), 184 axis.Min(0))..., 185 ) 186 }