k8s.io/test-infra@v0.0.0-20240520184403-27c6b4c223d8/config/prow/cluster/monitoring/mixins/grafana_dashboards/ghproxy.jsonnet (about) 1 local config = (import 'config.libsonnet')._config; 2 local grafana = import 'grafonnet/grafana.libsonnet'; 3 local dashboard = grafana.dashboard; 4 local graphPanel = grafana.graphPanel; 5 local prometheus = grafana.prometheus; 6 local template = grafana.template; 7 local singlestat = grafana.singlestat; 8 9 local botName = config.instance.botName; 10 11 local legendConfig = { 12 legend+: { 13 sideWidth: 250, 14 }, 15 }; 16 17 local dashboardConfig = { 18 uid: config.grafanaDashboardIDs['ghproxy.json'], 19 }; 20 21 local histogramQuantileTarget(phi) = prometheus.target( 22 std.format('histogram_quantile(%s, sum(rate(github_request_duration_bucket{path="${path}", status="${status}"}[5m]) * on(token_hash) group_left(login) max(github_user_info{login=~"${login}"}) by (token_hash, login)) by (le))', phi), 23 legendFormat=std.format('phi=%s', phi), 24 ); 25 26 local histogramQuantileTargetOverview(phi) = prometheus.target( 27 std.format('histogram_quantile(%s, sum(rate(github_request_duration_bucket[5m])) by (le))', phi), 28 legendFormat=std.format('phi=%s', phi), 29 ); 30 31 local requestLabels(name, labelInQuery) = template.new( 32 name, 33 'prometheus', 34 std.format('label_values(github_request_duration_count, %s)', labelInQuery), 35 label=name, 36 refresh='time', 37 ); 38 39 dashboard.new( 40 'GitHub Cache', 41 time_from='now-1d', 42 schemaVersion=18, 43 refresh='1m', 44 ) 45 .addTemplate(template.new( 46 'login', 47 'prometheus', 48 'label_values(github_user_info{login="%s"}, login)' % botName, 49 label='login', 50 refresh='time', 51 )) 52 .addTemplate(requestLabels('path', 'path')) 53 .addTemplate(requestLabels('status', 'status')) 54 .addTemplate(requestLabels('user_agent', 'user_agent')) 55 .addTemplate( 56 { 57 "allValue": null, 58 "current": { 59 "text": "30m", 60 "value": "30m" 61 }, 62 "hide": 0, 63 "includeAll": false, 64 "label": "range", 65 "multi": false, 66 "name": "range", 67 "options": 68 [ 69 { 70 "selected": false, 71 "text": '%s' % r, 72 "value": '%s'% r, 73 }, 74 for r in ['24h', '12h', '6h', '3h', '1h'] 75 ] + 76 [ 77 { 78 "selected": true, 79 "text": '30m', 80 "value": '30m', 81 } 82 ] + 83 [ 84 { 85 "selected": false, 86 "text": '%s' % r, 87 "value": '%s'% r, 88 }, 89 for r in ['30m', '15m', '10m', '5m'] 90 ], 91 "query": "3h,1h,30m,15m,10m,5m", 92 "skipUrlSync": false, 93 "type": "custom" 94 } 95 ) 96 .addPanel( 97 (graphPanel.new( 98 'Cache Requests (per hour)', 99 description='Count of cache requests of each cache mode over the last hour.', 100 datasource='prometheus', 101 legend_alignAsTable=true, 102 legend_rightSide=true, 103 legend_values=true, 104 legend_avg=true, 105 legend_sort='avg', 106 legend_sortDesc=true, 107 ) + legendConfig) 108 .addTarget(prometheus.target( 109 'sum(increase(ghcache_responses[1h]) * on(token_hash) group_left(login) max(github_user_info{login="%s"}) by (token_hash, login)) by (mode)' % botName, 110 legendFormat='{{mode}}', 111 )) 112 .addTarget(prometheus.target( 113 'sum(increase(ghcache_responses{mode=~"COALESCED|REVALIDATED"}[1h]) * on(token_hash) group_left(login) max(github_user_info{login="%s"}) by (token_hash, login))' % botName, 114 legendFormat='(No Cost)', 115 )), gridPos={ 116 h: 6, 117 w: 24, 118 x: 0, 119 y: 0, 120 }) 121 .addPanel( 122 (graphPanel.new( 123 'Cache Efficiency', 124 description='Percentage of cacheable requests that are fulfilled for free.\nNo cost modes are "COALESCED" and "REVALIDATED".\nCacheable modes include the no cost modes, "CHANGED" and "MISS".', 125 datasource='prometheus', 126 legend_alignAsTable=true, 127 legend_rightSide=true, 128 legend_values=true, 129 legend_current=true, 130 legend_avg=true, 131 min='0', 132 max='1', 133 formatY1='percentunit', 134 labelY1='% Cacheable Request Fulfilled for Free', 135 ) + legendConfig) 136 .addTarget(prometheus.target( 137 'sum(increase(ghcache_responses{mode=~"COALESCED|REVALIDATED"}[1h]) * on(token_hash) group_left(login) max(github_user_info{login="%s"}) by (token_hash, login)) \n/ sum(increase(ghcache_responses{mode=~"COALESCED|REVALIDATED|MISS|CHANGED"}[1h]) * on(token_hash) group_left(login) max(github_user_info{login="%s"}) by (token_hash, login))' % [botName, botName], 138 legendFormat='Efficiency', 139 )), gridPos={ 140 h: 6, 141 w: 24, 142 x: 0, 143 y: 0, 144 }) 145 .addPanel( 146 (graphPanel.new( 147 'Disk Usage', 148 description='', 149 datasource='prometheus', 150 legend_alignAsTable=true, 151 legend_rightSide=true, 152 legend_values=true, 153 legend_current=true, 154 stack=true, 155 ) + legendConfig) 156 .addTarget(prometheus.target( 157 'avg(ghcache_disk_used) without (instance,pod)', 158 legendFormat='GB Used', 159 )) 160 .addTarget(prometheus.target( 161 'avg(ghcache_disk_free) without (instance,pod)', 162 legendFormat='GB Free', 163 )), gridPos={ 164 h: 6, 165 w: 16, 166 x: 0, 167 y: 0, 168 }) 169 .addPanel( 170 singlestat.new( 171 'API Tokens Saved: Last hour', 172 description='The number of no cost requests in the last hour.\nThis includes both "COALESCED" and "REVALIDATED" modes.', 173 datasource='prometheus', 174 valueName='current', 175 ) 176 .addTarget(prometheus.target( 177 'sum(increase(ghcache_responses{mode=~"COALESCED|REVALIDATED"}[1h]) * on(token_hash) group_left(login) max(github_user_info{login="%s"}) by (token_hash, login))' % botName, 178 instant=true, 179 )), gridPos={ 180 h: 6, 181 w: 4, 182 x: 16, 183 y: 0, 184 }) 185 .addPanel( 186 singlestat.new( 187 'API Tokens Saved: Last 7 days', 188 description='The number of no cost requests in the last 7 days.\nThis includes both "COALESCED" and "REVALIDATED" modes.', 189 datasource='prometheus', 190 valueName='current', 191 format='short', 192 ) 193 .addTarget(prometheus.target( 194 'sum(increase(ghcache_responses{mode=~"COALESCED|REVALIDATED"}[7d]) * on(token_hash) group_left(login) max(github_user_info{login="%s"}) by (token_hash, login))' % botName, 195 instant=true, 196 )), gridPos={ 197 h: 6, 198 w: 4, 199 x: 20, 200 y: 0, 201 }) 202 .addPanel( 203 (graphPanel.new( 204 'Token Usage', 205 description='GitHub token usage by login and API version.', 206 datasource='prometheus', 207 legend_alignAsTable=true, 208 legend_rightSide=true, 209 legend_values=true, 210 legend_current=true, 211 min='0', 212 max='5000', 213 ) + legendConfig) 214 .addTarget(prometheus.target( 215 'sum(github_token_usage * on(token_hash) group_left(login) max(github_user_info{login="%s"}) by (token_hash, login)) by (api_version, login)' % botName, 216 legendFormat='{{login}} : {{api_version}}', 217 )), gridPos={ 218 h: 9, 219 w: 24, 220 x: 0, 221 y: 18, 222 }) 223 .addPanel( 224 (graphPanel.new( 225 'Request Rates: Overview by status with ${range}', 226 description='GitHub request rates by status.', 227 datasource='prometheus', 228 legend_alignAsTable=true, 229 legend_rightSide=true, 230 stack=true, 231 ) + legendConfig) 232 .addTarget(prometheus.target( 233 'sum(rate(github_request_duration_count[${range}]) * on(token_hash) group_left(login) max(github_user_info{login="%s"}) by (token_hash, login)) by (status)' % botName, 234 legendFormat='{{status}}', 235 )), gridPos={ 236 h: 9, 237 w: 24, 238 x: 0, 239 y: 18, 240 }) 241 .addPanel( 242 (graphPanel.new( 243 'Request Rates: Overview by path for ${status} with ${range}', 244 description='GitHub request rates by path.', 245 datasource='prometheus', 246 legend_alignAsTable=true, 247 legend_rightSide=true, 248 stack=true, 249 ) + legendConfig) 250 .addTarget(prometheus.target( 251 'sum(rate(github_request_duration_count{status="${status}"}[${range}]) * on(token_hash) group_left(login) max(github_user_info{login="%s"}) by (token_hash, login)) by (path)' % botName, 252 legendFormat='{{path}}', 253 )), gridPos={ 254 h: 9, 255 w: 24, 256 x: 0, 257 y: 18, 258 }) 259 .addPanel( 260 (graphPanel.new( 261 'Request Rates: ${login}, ${path}, and ${status} with ${range}', 262 description='GitHub request rates by login, path and status.', 263 datasource='prometheus', 264 legend_alignAsTable=true, 265 legend_rightSide=true, 266 legend_values=true, 267 legend_current=true, 268 legend_sort='current', 269 legend_sortDesc=true, 270 ) + legendConfig) 271 .addTarget(prometheus.target( 272 'sum(rate(github_request_duration_count{path="${path}", status="${status}"}[${range}]) * on(token_hash) group_left(login) max(github_user_info{login=~"${login}"}) by (token_hash, login)) by (login, path, status)', 273 legendFormat='{{status}}:{{login}}:{{path}}', 274 )), gridPos={ 275 h: 9, 276 w: 24, 277 x: 0, 278 y: 18, 279 }) 280 .addPanel( 281 (graphPanel.new( 282 'Latency Distribution Overview with ${range}', 283 description='histogram_quantile(<phi>, sum(rate(github_request_duration_bucket[${range}])) by (le))', 284 datasource='prometheus', 285 legend_alignAsTable=true, 286 legend_rightSide=true, 287 legend_values=true, 288 legend_current=true, 289 legend_avg=true, 290 legend_sort='avg', 291 legend_sortDesc=true, 292 ) + legendConfig) 293 .addTarget(histogramQuantileTargetOverview('0.99')) 294 .addTarget(histogramQuantileTargetOverview('0.95')) 295 .addTarget(histogramQuantileTargetOverview('0.5')), gridPos={ 296 h: 9, 297 w: 24, 298 x: 0, 299 y: 18, 300 }) 301 .addPanel( 302 (graphPanel.new( 303 'Latency Distribution for ${login}, ${path}, and ${status} with ${range}', 304 description='histogram_quantile(<phi>, sum(rate(github_request_duration_bucket{path=~"${path}", status=~"${status}"}[${range}])) by (le))', 305 datasource='prometheus', 306 legend_alignAsTable=true, 307 legend_rightSide=true, 308 legend_values=true, 309 legend_current=true, 310 legend_avg=true, 311 legend_sort='avg', 312 legend_sortDesc=true, 313 ) + legendConfig) 314 .addTarget(histogramQuantileTarget('0.99')) 315 .addTarget(histogramQuantileTarget('0.95')) 316 .addTarget(histogramQuantileTarget('0.5')), gridPos={ 317 h: 9, 318 w: 24, 319 x: 0, 320 y: 18, 321 }) 322 .addPanel( 323 (graphPanel.new( 324 'Token Consumption by User Agent', 325 description='sum(increase(ghcache_responses{mode=~"MISS|NO-STORE|CHANGED"}[1h])) by (user_agent)', 326 datasource='prometheus', 327 legend_alignAsTable=true, 328 legend_rightSide=true, 329 legend_values=true, 330 legend_current=true, 331 legend_avg=true, 332 legend_sort='avg', 333 legend_sortDesc=true, 334 stack=true, 335 ) + legendConfig) 336 .addTarget(prometheus.target( 337 'sum(increase(ghcache_responses{mode=~"MISS|NO-STORE|CHANGED"}[1h]) * on(token_hash) group_left(login) max(github_user_info{login="%s"}) by (token_hash, login)) by (user_agent)' % botName, 338 legendFormat='{{user_agent}}', 339 )), gridPos={ 340 h: 9, 341 w: 24, 342 x: 0, 343 y: 18, 344 }) 345 .addPanel( 346 (graphPanel.new( 347 'Token Consumption by Path', 348 description='sum(increase(ghcache_responses{mode=~"MISS|NO-STORE|CHANGED"}[1h])) by (path)', 349 datasource='prometheus', 350 legend_alignAsTable=true, 351 legend_rightSide=true, 352 legend_values=true, 353 legend_current=true, 354 legend_avg=true, 355 legend_sort='avg', 356 legend_sortDesc=true, 357 stack=true, 358 ) + legendConfig) 359 .addTarget(prometheus.target( 360 'sum(increase(ghcache_responses{mode=~"MISS|NO-STORE|CHANGED"}[1h]) * on(token_hash) group_left(login) max(github_user_info{login="%s"}) by (token_hash, login)) by (path)' % botName, 361 legendFormat='{{path}}', 362 )), gridPos={ 363 h: 9, 364 w: 24, 365 x: 0, 366 y: 18, 367 }) 368 .addPanel( 369 (graphPanel.new( 370 'Token Consumption For Path ${path} by User Agent', 371 description='sum(increase(ghcache_responses{mode=~"MISS|NO-STORE|CHANGED",path="${path}"}[1h])) by (user_agent)', 372 datasource='prometheus', 373 legend_alignAsTable=true, 374 legend_rightSide=true, 375 legend_values=true, 376 legend_current=true, 377 legend_avg=true, 378 legend_sort='avg', 379 legend_sortDesc=true, 380 ) + legendConfig) 381 .addTarget(prometheus.target( 382 'sum(increase(ghcache_responses{mode=~"MISS|NO-STORE|CHANGED",path="${path}"}[1h]) * on(token_hash) group_left(login) max(github_user_info{login="%s"}) by (token_hash, login)) by (user_agent)' % botName, 383 legendFormat='{{user_agent}}', 384 )), gridPos={ 385 h: 9, 386 w: 24, 387 x: 0, 388 y: 18, 389 }) 390 .addPanel( 391 (graphPanel.new( 392 'Token Consumption for User Agent ${user_agent} by Path', 393 description='sum(increase(ghcache_responses{mode=~"MISS|NO-STORE|CHANGED",user_agent="${user_agent}"}[1h])) by (path)', 394 datasource='prometheus', 395 legend_alignAsTable=true, 396 legend_rightSide=true, 397 legend_values=true, 398 legend_current=true, 399 legend_avg=true, 400 legend_sort='avg', 401 legend_sortDesc=true, 402 ) + legendConfig) 403 .addTarget(prometheus.target( 404 'sum(increase(ghcache_responses{mode=~"MISS|NO-STORE|CHANGED",user_agent="${user_agent}"}[1h]) * on(token_hash) group_left(login) max(github_user_info{login="%s"}) by (token_hash, login)) by (path)' % botName, 405 legendFormat='{{path}}', 406 )), gridPos={ 407 h: 9, 408 w: 24, 409 x: 0, 410 y: 18, 411 }) 412 + dashboardConfig