|
| 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 rows = this.grafana.rows; |
| 16 | + |
| 17 | + { |
| 18 | + 'clickhouse-replica.json': |
| 19 | + g.dashboard.new(prefix + ' replica') |
| 20 | + + g.dashboard.withPanels( |
| 21 | + g.util.panel.resolveCollapsedFlagOnRows( |
| 22 | + g.util.grid.wrapPanels( |
| 23 | + [rows.replicaOperationsPanels, rows.replicaZookeeperPanels] |
| 24 | + ) |
| 25 | + ) |
| 26 | + ) |
| 27 | + + root.applyCommon( |
| 28 | + vars.singleInstance, |
| 29 | + uid + '_replica', |
| 30 | + tags, |
| 31 | + links { clickhouseReplica+:: {} }, |
| 32 | + annotations, |
| 33 | + timezone, |
| 34 | + refresh, |
| 35 | + period |
| 36 | + ), |
| 37 | + |
| 38 | + 'clickhouse-overview.json': |
| 39 | + g.dashboard.new(prefix + ' overview') |
| 40 | + + g.dashboard.withPanels( |
| 41 | + g.util.panel.resolveCollapsedFlagOnRows( |
| 42 | + g.util.grid.wrapPanels( |
| 43 | + [rows.overviewQueriesPanels, rows.overviewMemoryPanels, rows.overviewNetworkPanels] |
| 44 | + ) |
| 45 | + ) |
| 46 | + ) |
| 47 | + + root.applyCommon( |
| 48 | + vars.singleInstance, |
| 49 | + uid + '_overview', |
| 50 | + tags, |
| 51 | + links { clickhouseOverview+:: {} }, |
| 52 | + annotations, |
| 53 | + timezone, |
| 54 | + refresh, |
| 55 | + period |
| 56 | + ), |
| 57 | + |
| 58 | + 'clickhouse-latency.json': |
| 59 | + g.dashboard.new(prefix + ' latency') |
| 60 | + + g.dashboard.withPanels( |
| 61 | + g.util.panel.resolveCollapsedFlagOnRows( |
| 62 | + g.util.grid.wrapPanels( |
| 63 | + [rows.latencyDiskPanels, rows.latencyNetworkPanels, rows.latencyZooKeeperPanels] |
| 64 | + ) |
| 65 | + ) |
| 66 | + ) |
| 67 | + + root.applyCommon( |
| 68 | + vars.singleInstance, |
| 69 | + uid + '_latency', |
| 70 | + tags, |
| 71 | + links { clickhouseLatency+:: {} }, |
| 72 | + annotations, |
| 73 | + timezone, |
| 74 | + refresh, |
| 75 | + period |
| 76 | + ), |
| 77 | + |
| 78 | + } |
| 79 | + + |
| 80 | + if this.config.enableLokiLogs then |
| 81 | + { |
| 82 | + 'logs.json': |
| 83 | + logslib.new( |
| 84 | + prefix + ' logs', |
| 85 | + datasourceName=this.grafana.variables.datasources.loki.name, |
| 86 | + datasourceRegex=this.grafana.variables.datasources.loki.regex, |
| 87 | + filterSelector=this.config.filteringSelector, |
| 88 | + labels=this.config.logLabels + this.config.extraLogLabels, |
| 89 | + formatParser=null, |
| 90 | + showLogsVolume=this.config.showLogsVolume, |
| 91 | + ) |
| 92 | + { |
| 93 | + dashboards+: |
| 94 | + { |
| 95 | + logs+: |
| 96 | + // reference to self, already generated variables, to keep them, but apply other common data in applyCommon |
| 97 | + root.applyCommon(super.logs.templating.list, uid=uid + '-logs', tags=tags, links=links { logs+:: {} }, annotations=annotations, timezone=timezone, refresh=refresh, period=period), |
| 98 | + }, |
| 99 | + panels+: |
| 100 | + { |
| 101 | + logs+: |
| 102 | + g.panel.logs.options.withEnableLogDetails(true) |
| 103 | + + g.panel.logs.options.withShowTime(false) |
| 104 | + + g.panel.logs.options.withWrapLogMessage(false), |
| 105 | + }, |
| 106 | + variables+: { |
| 107 | + // add prometheus datasource for annotations processing |
| 108 | + toArray+: [ |
| 109 | + this.grafana.variables.datasources.prometheus { hide: 2 }, |
| 110 | + ], |
| 111 | + }, |
| 112 | + }.dashboards.logs, |
| 113 | + } |
| 114 | + else {}, |
| 115 | + |
| 116 | + applyCommon(vars, uid, tags, links, annotations, timezone, refresh, period): |
| 117 | + g.dashboard.withTags(tags) |
| 118 | + + g.dashboard.withUid(uid) |
| 119 | + + g.dashboard.withLinks(std.objectValues(links)) |
| 120 | + + g.dashboard.withTimezone(timezone) |
| 121 | + + g.dashboard.withRefresh(refresh) |
| 122 | + + g.dashboard.time.withFrom(period) |
| 123 | + + g.dashboard.withVariables(vars) |
| 124 | + + g.dashboard.withAnnotations(std.objectValues(annotations)), |
| 125 | +} |
0 commit comments