|
| 1 | +local g = import './g.libsonnet'; |
| 2 | +local logslib = import 'logs-lib/logs/main.libsonnet'; |
| 3 | + |
| 4 | +{ |
| 5 | + local root = self, |
| 6 | + |
| 7 | + new(this):: |
| 8 | + local prefix = this.config.dashboardNamePrefix; |
| 9 | + local links = this.grafana.links; |
| 10 | + local tags = this.config.dashboardTags; |
| 11 | + local uid = g.util.string.slugify(this.config.uid); |
| 12 | + local vars = this.grafana.variables; |
| 13 | + local annotations = this.grafana.annotations; |
| 14 | + local refresh = this.config.dashboardRefresh; |
| 15 | + local period = this.config.dashboardPeriod; |
| 16 | + local timezone = this.config.dashboardTimezone; |
| 17 | + { |
| 18 | + 'ibm-mq-cluster-overview.json': |
| 19 | + g.dashboard.new(prefix + ' cluster overview') |
| 20 | + + g.dashboard.withPanels( |
| 21 | + g.util.panel.resolveCollapsedFlagOnRows( |
| 22 | + g.util.grid.wrapPanels( |
| 23 | + [ |
| 24 | + this.grafana.rows.clusterOverview, |
| 25 | + ] |
| 26 | + ), |
| 27 | + ) |
| 28 | + ) + root.applyCommon( |
| 29 | + vars.multiInstance, |
| 30 | + uid + '-cluster-overview', |
| 31 | + tags, |
| 32 | + links { ibmMqClusterOverview+:: {} }, |
| 33 | + annotations, |
| 34 | + timezone, |
| 35 | + refresh, |
| 36 | + period |
| 37 | + ), |
| 38 | + |
| 39 | + 'ibm-mq-queue-manager-overview.json': |
| 40 | + g.dashboard.new(prefix + ' queue manager overview') |
| 41 | + + g.dashboard.withPanels( |
| 42 | + g.util.panel.resolveCollapsedFlagOnRows( |
| 43 | + g.util.grid.wrapPanels( |
| 44 | + [ |
| 45 | + this.grafana.rows.queueManagerOverview, |
| 46 | + this.grafana.rows.queueManagerLogs, |
| 47 | + ] |
| 48 | + ), |
| 49 | + ) |
| 50 | + ) + root.applyCommon( |
| 51 | + vars.multiInstance, |
| 52 | + uid + '-queue-manager-overview', |
| 53 | + tags, |
| 54 | + links { ibmMqQueueManagerOverview+:: {} }, |
| 55 | + annotations, |
| 56 | + timezone, |
| 57 | + refresh, |
| 58 | + period |
| 59 | + ), |
| 60 | + |
| 61 | + 'ibm-mq-queue-overview.json': |
| 62 | + g.dashboard.new(prefix + ' queue overview') |
| 63 | + + g.dashboard.withPanels( |
| 64 | + g.util.panel.resolveCollapsedFlagOnRows( |
| 65 | + g.util.grid.wrapPanels( |
| 66 | + [ |
| 67 | + this.grafana.rows.queueOverview, |
| 68 | + ] |
| 69 | + ), |
| 70 | + ) |
| 71 | + ) + root.applyCommon( |
| 72 | + vars.multiInstance + [ |
| 73 | + g.dashboard.variable.query.new('queue') |
| 74 | + + g.dashboard.variable.custom.generalOptions.withLabel('Queue') |
| 75 | + + g.dashboard.variable.custom.selectionOptions.withMulti(true) |
| 76 | + + g.dashboard.variable.query.queryTypes.withLabelValues(label='queue', metric='ibmmq_queue_average_queue_time_seconds') |
| 77 | + + g.dashboard.variable.query.withDatasourceFromVariable(variable=vars.datasources.prometheus) |
| 78 | + + g.dashboard.variable.custom.selectionOptions.withIncludeAll(true, '.+') |
| 79 | + + g.dashboard.variable.query.refresh.onTime(), |
| 80 | + ], |
| 81 | + uid + '-queue-overview', |
| 82 | + tags, |
| 83 | + links { ibmMqQueueOverview+:: {} }, |
| 84 | + annotations, |
| 85 | + timezone, |
| 86 | + refresh, |
| 87 | + period |
| 88 | + ), |
| 89 | + |
| 90 | + 'ibm-mq-topics-overview.json': |
| 91 | + g.dashboard.new(prefix + ' topics overview') |
| 92 | + + g.dashboard.withPanels( |
| 93 | + g.util.panel.resolveCollapsedFlagOnRows( |
| 94 | + g.util.grid.wrapPanels( |
| 95 | + [ |
| 96 | + this.grafana.rows.topicsRow, |
| 97 | + this.grafana.rows.subscriptionsRow, |
| 98 | + ] |
| 99 | + ), |
| 100 | + ) |
| 101 | + ) + root.applyCommon( |
| 102 | + vars.multiInstance + [ |
| 103 | + g.dashboard.variable.query.new('topic') |
| 104 | + + g.dashboard.variable.custom.generalOptions.withLabel('Topic') |
| 105 | + + g.dashboard.variable.custom.selectionOptions.withMulti(true) |
| 106 | + + g.dashboard.variable.query.queryTypes.withLabelValues(label='topic', metric='ibmmq_topic_subscriber_count{qmgr=~"$qmgr",topic!~"SYSTEM.*|\\\\$SYS.*|"}') |
| 107 | + + g.dashboard.variable.query.withDatasourceFromVariable(variable=vars.datasources.prometheus) |
| 108 | + + g.dashboard.variable.custom.selectionOptions.withIncludeAll(true, '.+') |
| 109 | + + g.dashboard.variable.query.refresh.onTime(), |
| 110 | + |
| 111 | + g.dashboard.variable.query.new('subscription') |
| 112 | + + g.dashboard.variable.custom.generalOptions.withLabel('Subscription') |
| 113 | + + g.dashboard.variable.custom.selectionOptions.withMulti(true) |
| 114 | + + g.dashboard.variable.query.queryTypes.withLabelValues(label='subscription', metric='ibmmq_subscription_messsages_received{qmgr=~"$qmgr",subscription!~"SYSTEM.*|"}') |
| 115 | + + g.dashboard.variable.query.withDatasourceFromVariable(variable=vars.datasources.prometheus) |
| 116 | + + g.dashboard.variable.custom.selectionOptions.withIncludeAll(true, '.+') |
| 117 | + + g.dashboard.variable.query.refresh.onTime(), |
| 118 | + ], |
| 119 | + uid + '-topics-overview', |
| 120 | + tags, |
| 121 | + links { ibmMqTopicsOverview+:: {} }, |
| 122 | + annotations, |
| 123 | + timezone, |
| 124 | + refresh, |
| 125 | + period |
| 126 | + ), |
| 127 | + } |
| 128 | + + if this.config.enableLokiLogs then { |
| 129 | + 'ibm-mq-logs.json': |
| 130 | + logslib.new( |
| 131 | + prefix + ' logs', |
| 132 | + datasourceName=this.grafana.variables.datasources.loki.name, |
| 133 | + datasourceRegex=this.grafana.variables.datasources.loki.regex, |
| 134 | + filterSelector=this.config.filteringSelector, |
| 135 | + labels=this.config.groupLabels + this.config.extraLogLabels + ['qmgr'], |
| 136 | + formatParser=null, |
| 137 | + showLogsVolume=this.config.showLogsVolume, |
| 138 | + ) |
| 139 | + { |
| 140 | + dashboards+: |
| 141 | + { |
| 142 | + logs+: |
| 143 | + root.applyCommon(super.logs.templating.list, uid=uid + '-logs', tags=tags, links=links, annotations=annotations, timezone=timezone, refresh=refresh, period=period), |
| 144 | + }, |
| 145 | + panels+: |
| 146 | + { |
| 147 | + logs+: |
| 148 | + g.panel.logs.options.withEnableLogDetails(true) |
| 149 | + + g.panel.logs.options.withShowTime(false) |
| 150 | + + g.panel.logs.options.withWrapLogMessage(false), |
| 151 | + }, |
| 152 | + variables+: { |
| 153 | + toArray+: [ |
| 154 | + this.grafana.variables.datasources.prometheus { hide: 2 }, |
| 155 | + ], |
| 156 | + }, |
| 157 | + }.dashboards.logs, |
| 158 | + } |
| 159 | + else {}, |
| 160 | + |
| 161 | + applyCommon(vars, uid, tags, links, annotations, timezone, refresh, period): |
| 162 | + g.dashboard.withTags(tags) |
| 163 | + + g.dashboard.withUid(uid) |
| 164 | + + g.dashboard.withLinks(std.objectValues(links)) |
| 165 | + + g.dashboard.withTimezone(timezone) |
| 166 | + + g.dashboard.withRefresh(refresh) |
| 167 | + + g.dashboard.time.withFrom(period) |
| 168 | + + g.dashboard.withVariables(vars) |
| 169 | + + g.dashboard.withAnnotations(std.objectValues(annotations)), |
| 170 | +} |
0 commit comments