|
| 1 | +local g = import './g.libsonnet'; |
| 2 | +local logslib = import 'logs-lib/logs/main.libsonnet'; |
| 3 | +{ |
| 4 | + local root = self, |
| 5 | + new(this):: |
| 6 | + local prefix = this.config.dashboardNamePrefix; |
| 7 | + local links = this.grafana.links; |
| 8 | + local tags = this.config.dashboardTags; |
| 9 | + local uid = g.util.string.slugify(this.config.uid); |
| 10 | + local vars = this.grafana.variables; |
| 11 | + local annotations = this.grafana.annotations; |
| 12 | + local refresh = this.config.dashboardRefresh; |
| 13 | + local period = this.config.dashboardPeriod; |
| 14 | + local timezone = this.config.dashboardTimezone; |
| 15 | + local panels = this.grafana.panels; |
| 16 | + |
| 17 | + { |
| 18 | + 'couchbase-bucket-overview.json': |
| 19 | + g.dashboard.new(prefix + ' bucket overview') |
| 20 | + + g.dashboard.withPanels( |
| 21 | + g.util.grid.wrapPanels( |
| 22 | + [ |
| 23 | + panels.bucket_topBucketsByMemoryUsedPanel { gridPos+: { w: 12 } }, |
| 24 | + panels.bucket_topBucketsByDiskUsedPanel { gridPos+: { w: 12 } }, |
| 25 | + panels.bucket_topBucketsByCurrentItemsPanel { gridPos+: { w: 8 } }, |
| 26 | + panels.bucket_topBucketsByOperationsPanel { gridPos+: { w: 8 } }, |
| 27 | + panels.bucket_topBucketsByOperationsFailedPanel { gridPos+: { w: 8 } }, |
| 28 | + panels.bucket_topBucketsByHighPriorityRequestsPanel { gridPos+: { w: 12 } }, |
| 29 | + panels.bucket_bottomBucketsByCacheHitRatioPanel { gridPos+: { w: 12 } }, |
| 30 | + panels.bucket_topBucketsByVBucketsCountPanel { gridPos+: { w: 12 } }, |
| 31 | + panels.bucket_topBucketsByVBucketQueueMemoryPanel { gridPos+: { w: 12 } }, |
| 32 | + ], |
| 33 | + ) |
| 34 | + ) |
| 35 | + + root.applyCommon( |
| 36 | + vars.multiInstance, |
| 37 | + uid + '_couchbase_bucket_overview', |
| 38 | + tags, |
| 39 | + links { couchbaseBucketOverview+:: {} }, |
| 40 | + annotations, |
| 41 | + timezone, |
| 42 | + refresh, |
| 43 | + period |
| 44 | + ), |
| 45 | + |
| 46 | + 'couchbase-node-overview.json': |
| 47 | + g.dashboard.new(prefix + ' node overview') |
| 48 | + + g.dashboard.withPanels( |
| 49 | + g.util.panel.resolveCollapsedFlagOnRows( |
| 50 | + g.util.grid.wrapPanels( |
| 51 | + [ |
| 52 | + panels.node_memoryUtilizationPanel { gridPos+: { w: 12 } }, |
| 53 | + panels.node_cpuUtilizationPanel { gridPos+: { w: 12 } }, |
| 54 | + panels.node_totalMemoryUsedByServicePanel { gridPos+: { w: 8 } }, |
| 55 | + panels.node_backupSizePanel { gridPos+: { w: 8 } }, |
| 56 | + panels.node_currentConnectionsPanel { gridPos+: { w: 8 } }, |
| 57 | + panels.node_httpResponseCodesPanel { gridPos+: { w: 12 } }, |
| 58 | + panels.node_httpRequestMethodsPanel { gridPos+: { w: 12 } }, |
| 59 | + panels.node_queryServiceRequestsPanel { gridPos+: { w: 12 } }, |
| 60 | + panels.node_queryServiceRequestProcessingTimePanel { gridPos+: { w: 12 } }, |
| 61 | + panels.node_indexServiceRequestsPanel { gridPos+: { w: 8 } }, |
| 62 | + panels.node_indexCacheHitRatioPanel { gridPos+: { w: 8 } }, |
| 63 | + panels.node_averageScanLatencyPanel { gridPos+: { w: 8 } }, |
| 64 | + ] |
| 65 | + ) |
| 66 | + ) |
| 67 | + ) |
| 68 | + + root.applyCommon( |
| 69 | + vars.multiInstance, |
| 70 | + uid + '_couchbase_node_overview', |
| 71 | + tags, |
| 72 | + links { couchbaseNodeOverview+:: {} }, |
| 73 | + annotations, |
| 74 | + timezone, |
| 75 | + refresh, |
| 76 | + period |
| 77 | + ), |
| 78 | + |
| 79 | + 'couchbase-cluster-overview.json': |
| 80 | + g.dashboard.new(prefix + ' cluster overview') |
| 81 | + + g.dashboard.withPanels( |
| 82 | + g.util.panel.resolveCollapsedFlagOnRows( |
| 83 | + g.util.grid.wrapPanels( |
| 84 | + [ |
| 85 | + panels.cluster_topNodesByMemoryUsagePanel { gridPos+: { w: 12 } }, |
| 86 | + panels.cluster_topNodesByHTTPRequestsPanel { gridPos+: { w: 12 } }, |
| 87 | + panels.cluster_topNodesByQueryServiceRequestsPanel { gridPos+: { w: 12 } }, |
| 88 | + panels.cluster_topNodesByIndexAverageScanLatencyPanel { gridPos+: { w: 12 } }, |
| 89 | + panels.cluster_xdcrReplicationRatePanel { gridPos+: { w: 8 } }, |
| 90 | + panels.cluster_xdcrDocsReceivedPanel { gridPos+: { w: 8 } }, |
| 91 | + panels.cluster_localBackupSizePanel { gridPos+: { w: 8 } }, |
| 92 | + ] + this.grafana.rows.clusterOverviewBucket, |
| 93 | + ) |
| 94 | + ) |
| 95 | + ) |
| 96 | + + root.applyCommon( |
| 97 | + vars.multiInstance, |
| 98 | + uid + '_couchbase_cluster_overview', |
| 99 | + tags, |
| 100 | + links { couchbaseClusterOverview+:: {} }, |
| 101 | + annotations, |
| 102 | + timezone, |
| 103 | + refresh, |
| 104 | + period |
| 105 | + ), |
| 106 | + |
| 107 | + } |
| 108 | + + |
| 109 | + if this.config.enableLokiLogs then |
| 110 | + { |
| 111 | + 'couchbase-logs.json': |
| 112 | + logslib.new( |
| 113 | + prefix + ' logs', |
| 114 | + datasourceName=this.grafana.variables.datasources.loki.name, |
| 115 | + datasourceRegex=this.grafana.variables.datasources.loki.regex, |
| 116 | + filterSelector=this.config.filteringSelector, |
| 117 | + labels=this.config.groupLabels + this.config.extraLogLabels, |
| 118 | + formatParser=null, |
| 119 | + showLogsVolume=this.config.showLogsVolume, |
| 120 | + ) |
| 121 | + { |
| 122 | + dashboards+: |
| 123 | + { |
| 124 | + logs+: |
| 125 | + // reference to self, already generated variables, to keep them, but apply other common data in applyCommon |
| 126 | + root.applyCommon(super.logs.templating.list, uid=uid + '-logs', tags=tags, links=links { logs+:: {} }, annotations=annotations, timezone=timezone, refresh=refresh, period=period), |
| 127 | + }, |
| 128 | + panels+: |
| 129 | + { |
| 130 | + // modify log panel |
| 131 | + logs+: |
| 132 | + g.panel.logs.options.withEnableLogDetails(true) |
| 133 | + + g.panel.logs.options.withShowTime(false) |
| 134 | + + g.panel.logs.options.withWrapLogMessage(false), |
| 135 | + }, |
| 136 | + variables+: { |
| 137 | + // add prometheus datasource for annotations processing |
| 138 | + toArray+: [ |
| 139 | + this.grafana.variables.datasources.prometheus { hide: 2 }, |
| 140 | + ], |
| 141 | + }, |
| 142 | + }.dashboards.logs, |
| 143 | + } |
| 144 | + else {}, |
| 145 | + |
| 146 | + applyCommon(vars, uid, tags, links, annotations, timezone, refresh, period): |
| 147 | + g.dashboard.withTags(tags) |
| 148 | + + g.dashboard.withUid(uid) |
| 149 | + + g.dashboard.withLinks(std.objectValues(links)) |
| 150 | + + g.dashboard.withTimezone(timezone) |
| 151 | + + g.dashboard.withRefresh(refresh) |
| 152 | + + g.dashboard.time.withFrom(period) |
| 153 | + + g.dashboard.withVariables(vars) |
| 154 | + + g.dashboard.withAnnotations(std.objectValues(annotations)), |
| 155 | +} |
0 commit comments