|
| 1 | +local g = import './g.libsonnet'; |
| 2 | +local commonlib = import 'common-lib/common/main.libsonnet'; |
| 3 | +local logslib = import 'logs-lib/logs/main.libsonnet'; |
| 4 | +{ |
| 5 | + local root = self, |
| 6 | + new(this):: |
| 7 | + |
| 8 | + local links = this.grafana.links; |
| 9 | + local tags = this.config.dashboardTags; |
| 10 | + local uid = g.util.string.slugify(this.config.uid); |
| 11 | + local vars = this.grafana.variables; |
| 12 | + local annotations = this.grafana.annotations; |
| 13 | + local refresh = this.config.dashboardRefresh; |
| 14 | + local period = this.config.dashboardPeriod; |
| 15 | + local timezone = this.config.dashboardTimezone; |
| 16 | + local extraLogLabels = this.config.extraLogLabels; |
| 17 | + { |
| 18 | + |
| 19 | + 'wildfly-overview.json': |
| 20 | + g.dashboard.new(this.config.dashboardNamePrefix + ' Overview') |
| 21 | + + g.dashboard.withPanels( |
| 22 | + g.util.panel.resolveCollapsedFlagOnRows( |
| 23 | + g.util.grid.wrapPanels([ |
| 24 | + this.grafana.rows.requestsRow, |
| 25 | + this.grafana.rows.networkRow, |
| 26 | + this.grafana.rows.sessionsRow, |
| 27 | + ]) |
| 28 | + ) |
| 29 | + ) + root.applyCommon( |
| 30 | + vars.multiInstance + [ |
| 31 | + g.dashboard.variable.query.new('server') |
| 32 | + + g.dashboard.variable.custom.selectionOptions.withMulti(true) |
| 33 | + + g.dashboard.variable.query.queryTypes.withLabelValues(label='server', metric='wildfly_undertow_request_count_total{%(queriesSelectorGroupOnly)s}' % vars) |
| 34 | + + g.dashboard.variable.query.withDatasourceFromVariable(vars.datasources.prometheus), |
| 35 | + g.dashboard.variable.query.new('deployment') |
| 36 | + + g.dashboard.variable.custom.selectionOptions.withMulti(true) |
| 37 | + + g.dashboard.variable.query.queryTypes.withLabelValues(label='deployment', metric='wildfly_undertow_active_sessions{%(queriesSelectorGroupOnly)s}' % vars) |
| 38 | + + g.dashboard.variable.query.withDatasourceFromVariable(vars.datasources.prometheus), |
| 39 | + ], |
| 40 | + uid + '-overview', |
| 41 | + tags, |
| 42 | + links { wildflyOverview+:: {} }, |
| 43 | + annotations, |
| 44 | + timezone, |
| 45 | + refresh, |
| 46 | + period, |
| 47 | + ), |
| 48 | + 'wildfly-datasource.json': |
| 49 | + g.dashboard.new(this.config.dashboardNamePrefix + ' Datasource') |
| 50 | + + g.dashboard.withPanels( |
| 51 | + g.util.panel.resolveCollapsedFlagOnRows( |
| 52 | + g.util.grid.wrapPanels([ |
| 53 | + this.grafana.rows.connectionsRow, |
| 54 | + this.grafana.rows.transactionsRow, |
| 55 | + ]) |
| 56 | + ) |
| 57 | + ) + root.applyCommon( |
| 58 | + vars.multiInstance + [ |
| 59 | + g.dashboard.variable.query.new('datasource') |
| 60 | + + g.dashboard.variable.custom.selectionOptions.withMulti(true) |
| 61 | + + g.dashboard.variable.query.queryTypes.withLabelValues(label='data_source', metric='wildfly_datasources_pool_in_use_count{%(queriesSelectorGroupOnly)s}' % vars) |
| 62 | + + g.dashboard.variable.query.withDatasourceFromVariable(vars.datasources.prometheus), |
| 63 | + ], |
| 64 | + uid + '-datasource', |
| 65 | + tags, |
| 66 | + links { wildflyDatasource+:: {} }, |
| 67 | + annotations, |
| 68 | + timezone, |
| 69 | + refresh, |
| 70 | + period, |
| 71 | + ), |
| 72 | + |
| 73 | + } + if this.config.enableLokiLogs then { |
| 74 | + 'wildfly-logs.json': |
| 75 | + logslib.new( |
| 76 | + this.config.dashboardNamePrefix + ' Logs', |
| 77 | + datasourceName=this.grafana.variables.datasources.loki.name, |
| 78 | + datasourceRegex=this.grafana.variables.datasources.loki.regex, |
| 79 | + filterSelector=this.config.filteringSelector, |
| 80 | + labels=this.config.groupLabels + this.config.extraLogLabels, |
| 81 | + formatParser=null, |
| 82 | + showLogsVolume=this.config.showLogsVolume, |
| 83 | + ) |
| 84 | + { |
| 85 | + dashboards+: |
| 86 | + { |
| 87 | + logs+: |
| 88 | + root.applyCommon(super.logs.templating.list, uid=uid + '-logs', tags=tags, links=links { logs+:: {} }, annotations=annotations, timezone=timezone, refresh=refresh, period=period), |
| 89 | + }, |
| 90 | + panels+: |
| 91 | + { |
| 92 | + logs+: |
| 93 | + g.panel.logs.options.withEnableLogDetails(true) |
| 94 | + + g.panel.logs.options.withShowTime(false) |
| 95 | + + g.panel.logs.options.withWrapLogMessage(false), |
| 96 | + }, |
| 97 | + variables+: { |
| 98 | + toArray+: [ |
| 99 | + this.grafana.variables.datasources.prometheus { hide: 2 }, |
| 100 | + ], |
| 101 | + }, |
| 102 | + }.dashboards.logs, |
| 103 | + |
| 104 | + } else {}, |
| 105 | + |
| 106 | + applyCommon(vars, uid, tags, links, annotations, timezone, refresh, period): |
| 107 | + g.dashboard.withTags(tags) |
| 108 | + + g.dashboard.withUid(uid) |
| 109 | + + g.dashboard.withLinks(std.objectValues(links)) |
| 110 | + + g.dashboard.withTimezone(timezone) |
| 111 | + + g.dashboard.withRefresh(refresh) |
| 112 | + + g.dashboard.time.withFrom(period) |
| 113 | + + g.dashboard.withVariables(vars) |
| 114 | + + g.dashboard.withAnnotations(std.objectValues(annotations)), |
| 115 | +} |
0 commit comments