From 77c2d10423a0dda3f39c618576d3020924ae75f2 Mon Sep 17 00:00:00 2001 From: schmikei Date: Mon, 13 Oct 2025 18:25:15 -0400 Subject: [PATCH 1/9] modernize the apache tomcat mixin --- .../{alerts => }/alerts.libsonnet | 38 +- apache-tomcat-mixin/config.libsonnet | 45 +- apache-tomcat-mixin/dashboards.libsonnet | 100 ++ .../dashboards/apache-tomcat-hosts.libsonnet | 512 ---------- .../apache-tomcat-overview.libsonnet | 794 --------------- .../dashboards/dashboards.libsonnet | 2 - .../dashboards_out/apache-tomcat-hosts.json | 654 ++++--------- .../dashboards_out/apache-tomcat-logs.json | 327 +++++++ .../apache-tomcat-overview.json | 919 +++++------------- apache-tomcat-mixin/g.libsonnet | 1 + apache-tomcat-mixin/jsonnetfile.json | 27 + apache-tomcat-mixin/links.libsonnet | 24 + apache-tomcat-mixin/main.libsonnet | 48 + apache-tomcat-mixin/mixin.libsonnet | 33 +- apache-tomcat-mixin/panels.libsonnet | 131 +++ .../prometheus_alerts.yaml | 12 +- apache-tomcat-mixin/rows.libsonnet | 32 + apache-tomcat-mixin/signals/hosts.libsonnet | 214 ++++ .../signals/overview.libsonnet | 294 ++++++ 19 files changed, 1746 insertions(+), 2461 deletions(-) rename apache-tomcat-mixin/{alerts => }/alerts.libsonnet (63%) create mode 100644 apache-tomcat-mixin/dashboards.libsonnet delete mode 100644 apache-tomcat-mixin/dashboards/apache-tomcat-hosts.libsonnet delete mode 100644 apache-tomcat-mixin/dashboards/apache-tomcat-overview.libsonnet delete mode 100644 apache-tomcat-mixin/dashboards/dashboards.libsonnet create mode 100644 apache-tomcat-mixin/dashboards_out/apache-tomcat-logs.json create mode 100644 apache-tomcat-mixin/g.libsonnet create mode 100644 apache-tomcat-mixin/links.libsonnet create mode 100644 apache-tomcat-mixin/main.libsonnet create mode 100644 apache-tomcat-mixin/panels.libsonnet create mode 100644 apache-tomcat-mixin/rows.libsonnet create mode 100644 apache-tomcat-mixin/signals/hosts.libsonnet create mode 100644 apache-tomcat-mixin/signals/overview.libsonnet diff --git a/apache-tomcat-mixin/alerts/alerts.libsonnet b/apache-tomcat-mixin/alerts.libsonnet similarity index 63% rename from apache-tomcat-mixin/alerts/alerts.libsonnet rename to apache-tomcat-mixin/alerts.libsonnet index 0c8b87487..b7fb7df3b 100644 --- a/apache-tomcat-mixin/alerts/alerts.libsonnet +++ b/apache-tomcat-mixin/alerts.libsonnet @@ -1,5 +1,5 @@ { - prometheusAlerts+:: { + new(this): { groups+: [ { name: 'ApacheTomcatAlerts', @@ -7,8 +7,8 @@ { alert: 'ApacheTomcatAlertsHighCpuUsage', expr: ||| - sum by (%(agg)s) (jvm_process_cpu_load{%(filteringSelector)s}) > %(ApacheTomcatAlertsCriticalCpuUsage)s - ||| % $._config { agg: std.join(',', $._config.groupLabels + $._config.instanceLabels) }, + sum by (%(agg)s) (jvm_process_cpu_load{%(filteringSelector)s}) > %(alertsCriticalCpuUsage)s + ||| % this.config { agg: std.join(',', this.config.groupLabels + this.config.instanceLabels) }, 'for': '5m', labels: { severity: 'critical', @@ -18,15 +18,15 @@ description: ( 'The CPU usage has been at {{ printf "%%.0f" $value }} percent over the last 5 minutes on {{$labels.instance}}, ' + - 'which is above the threshold of %(ApacheTomcatAlertsCriticalCpuUsage)s percent.' - ) % $._config, + 'which is above the threshold of %(alertsCriticalCpuUsage)s percent.' + ) % this.config, }, }, { alert: 'ApacheTomcatAlertsHighMemoryUsage', expr: ||| - sum(jvm_memory_usage_used_bytes{%(filteringSelector)s}) by (%(agg)s) / sum(jvm_physical_memory_bytes{%(filteringSelector)s}) by (%(agg)s) * 100 > %(ApacheTomcatAlertsCriticalMemoryUsage)s - ||| % $._config { agg: std.join(',', $._config.groupLabels + $._config.instanceLabels) }, + sum(jvm_memory_usage_used_bytes{%(filteringSelector)s}) by (%(agg)s) / sum(jvm_physical_memory_bytes{%(filteringSelector)s}) by (%(agg)s) * 100 > %(alertsCriticalMemoryUsage)s + ||| % this.config { agg: std.join(',', this.config.groupLabels + this.config.instanceLabels) }, 'for': '5m', labels: { severity: 'critical', @@ -36,15 +36,15 @@ description: ( 'The memory usage has been at {{ printf "%%.0f" $value }} percent over the last 5 minutes on {{$labels.instance}}, ' + - 'which is above the threshold of %(ApacheTomcatAlertsCriticalMemoryUsage)s percent.' - ) % $._config, + 'which is above the threshold of %(alertsCriticalMemoryUsage)s percent.' + ) % this.config, }, }, { - alert: 'ApacheTomcatAlertsHighRequestErrorPercent', + alert: 'ApacheTomcatAlertsRequestErrors', expr: ||| - sum by (%(agg)s) (increase(tomcat_errorcount_total{%(filteringSelector)s}[5m]) / increase(tomcat_requestcount_total{%(filteringSelector)s}[5m]) * 100) > %(ApacheTomcatAlertsCriticalRequestErrorPercentage)s - ||| % $._config { agg: std.join(',', $._config.groupLabels + $._config.instanceLabels) }, + sum by (%(agg)s) (increase(tomcat_errorcount_total{%(filteringSelector)s}[5m]) / increase(tomcat_requestcount_total{%(filteringSelector)s}[5m]) * 100) > %(alertsCriticalRequestErrorPercentage)s + ||| % this.config { agg: std.join(',', this.config.groupLabels + this.config.instanceLabels) }, 'for': '5m', labels: { severity: 'critical', @@ -54,15 +54,15 @@ description: ( 'The percentage of request errors has been at {{ printf "%%.0f" $value }} percent over the last 5 minutes on {{$labels.instance}}, ' + - 'which is above the threshold of %(ApacheTomcatAlertsCriticalRequestErrorPercentage)s percent.' - ) % $._config, + 'which is above the threshold of %(alertsCriticalRequestErrorPercentage)s percent.' + ) % this.config, }, }, { - alert: 'ApacheTomcatAlertsModeratelyHighProcessingTime', + alert: 'ApacheTomcatAlertsHighProcessingTime', expr: ||| - sum by (%(agg)s) (increase(tomcat_processingtime_total{%(filteringSelector)s}[5m]) / increase(tomcat_requestcount_total{%(filteringSelector)s}[5m])) > %(ApacheTomcatAlertsWarningProcessingTime)s - ||| % $._config { agg: std.join(',', $._config.groupLabels + $._config.instanceLabels) }, + sum by (%(agg)s) (increase(tomcat_processingtime_total{%(filteringSelector)s}[5m]) / increase(tomcat_requestcount_total{%(filteringSelector)s}[5m])) > %(alertsWarningProcessingTime)s + ||| % this.config { agg: std.join(',', this.config.groupLabels + this.config.instanceLabels) }, 'for': '5m', labels: { severity: 'warning', @@ -72,8 +72,8 @@ description: ( 'The processing time has been at {{ printf "%%.0f" $value }}ms over the last 5 minutes on {{$labels.instance}}, ' + - 'which is above the threshold of %(ApacheTomcatAlertsWarningProcessingTime)sms.' - ) % $._config, + 'which is above the threshold of %(alertsWarningProcessingTime)sms.' + ) % this.config, }, }, ], diff --git a/apache-tomcat-mixin/config.libsonnet b/apache-tomcat-mixin/config.libsonnet index 281b888f3..386d42329 100644 --- a/apache-tomcat-mixin/config.libsonnet +++ b/apache-tomcat-mixin/config.libsonnet @@ -1,24 +1,33 @@ { - _config+:: { - dashboardTags: ['apache-tomcat-mixin'], - dashboardPeriod: 'now-1h', - dashboardTimezone: 'default', - dashboardRefresh: '1m', + local this = self, + filteringSelector: 'job="integrations/tomcat"', + groupLabels: ['job', 'cluster'], + logLabels: [], + instanceLabels: ['instance'], - //alert thresholds - ApacheTomcatAlertsCriticalCpuUsage: 80, //% - ApacheTomcatAlertsCriticalMemoryUsage: 80, //% - ApacheTomcatAlertsCriticalRequestErrorPercentage: 5, //% - ApacheTomcatAlertsWarningProcessingTime: 300, //ms + uid: 'apache-tomcat', + dashboardTags: [self.uid + '-mixin'], + dashboardNamePrefix: 'Apache Tomcat', + dashboardPeriod: 'now-1h', + dashboardTimezone: 'default', + dashboardRefresh: '1m', + metricsSource: ['prometheus'], // metrics source for signals - // used in alerts: - filteringSelector: 'job="integrations/tomcat"', - groupLabels: if self.enableMultiCluster then ['job', 'cluster'] else ['job'], - instanceLabels: ['instance'], - enableLokiLogs: true, - enableMultiCluster: false, - multiclusterSelector: 'job=~"$job"', - tomcatSelector: if self.enableMultiCluster then 'job=~"$job", cluster=~"$cluster"' else 'job=~"$job"', + // Logging configuration + enableLokiLogs: true, + extraLogLabels: ['level'], // Required by logs-lib + logsVolumeGroupBy: 'level', + showLogsVolume: true, + + // alert thresholds + alertsCriticalCpuUsage: 80, //% + alertsCriticalMemoryUsage: 80, //% + alertsCriticalRequestErrorPercentage: 5, //% + alertsWarningProcessingTime: 300, //ms + + signals+: { + overview: (import './signals/overview.libsonnet')(this), + hosts: (import './signals/hosts.libsonnet')(this), }, } diff --git a/apache-tomcat-mixin/dashboards.libsonnet b/apache-tomcat-mixin/dashboards.libsonnet new file mode 100644 index 000000000..9a0ec7062 --- /dev/null +++ b/apache-tomcat-mixin/dashboards.libsonnet @@ -0,0 +1,100 @@ +local g = import './g.libsonnet'; +local commonlib = import 'common-lib/common/main.libsonnet'; +local logslib = import 'logs-lib/logs/main.libsonnet'; + +{ + local root = self, + new(this):: + local prefix = this.config.dashboardNamePrefix; + local links = this.grafana.links; + local tags = this.config.dashboardTags; + local uid = g.util.string.slugify(this.config.uid); + local vars = this.grafana.variables; + local annotations = this.grafana.annotations; + local refresh = this.config.dashboardRefresh; + local period = this.config.dashboardPeriod; + local timezone = this.config.dashboardTimezone; + { + 'apache-tomcat-overview.json': + g.dashboard.new(prefix + ' overview') + + g.dashboard.withPanels( + g.util.panel.resolveCollapsedFlagOnRows( + g.util.grid.wrapPanels( + [ + this.grafana.rows.overview, + ], + ), + ), + ) + root.applyCommon( + vars.multiInstance, + uid + '_overview', + tags, + links { apacheTomcatOverview:: {} }, + annotations, + timezone, + refresh, + period + ), + + 'apache-tomcat-hosts.json': + g.dashboard.new(prefix + ' hosts') + + g.dashboard.withPanels( + g.util.panel.resolveCollapsedFlagOnRows( + g.util.grid.wrapPanels( + [ + this.grafana.rows.hosts, + ], + ), + ), + ) + root.applyCommon( + vars.multiInstance, + uid + '_hosts', + tags, + links { apacheTomcatHosts:: {} }, + annotations, + timezone, + refresh, + period + ), + } + if this.config.enableLokiLogs then { + 'apache-tomcat-logs.json': + logslib.new( + prefix + ' logs', + datasourceName=this.grafana.variables.datasources.loki.name, + datasourceRegex=this.grafana.variables.datasources.loki.regex, + filterSelector=this.config.filteringSelector, + labels=this.config.groupLabels + this.config.extraLogLabels, + formatParser=null, + showLogsVolume=this.config.showLogsVolume, + ) + { + dashboards+: + { + logs+: + root.applyCommon(super.logs.templating.list, uid=uid + '-logs', tags=tags, links=links { logs+:: {} }, annotations=annotations, timezone=timezone, refresh=refresh, period=period), + }, + panels+: + { + logs+: + g.panel.logs.options.withEnableLogDetails(true) + + g.panel.logs.options.withShowTime(false) + + g.panel.logs.options.withWrapLogMessage(false), + }, + variables+: { + toArray+: [ + this.grafana.variables.datasources.prometheus { hide: 2 }, + ], + }, + }.dashboards.logs, + }, + + applyCommon(vars, uid, tags, links, annotations, timezone, refresh, period): + g.dashboard.withTags(tags) + + g.dashboard.withUid(uid) + + g.dashboard.withLinks(std.objectValues(links)) + + g.dashboard.withTimezone(timezone) + + g.dashboard.withRefresh(refresh) + + g.dashboard.time.withFrom(period) + + g.dashboard.withVariables(vars) + + g.dashboard.withAnnotations(std.objectValues(annotations)), +} diff --git a/apache-tomcat-mixin/dashboards/apache-tomcat-hosts.libsonnet b/apache-tomcat-mixin/dashboards/apache-tomcat-hosts.libsonnet deleted file mode 100644 index d971f306c..000000000 --- a/apache-tomcat-mixin/dashboards/apache-tomcat-hosts.libsonnet +++ /dev/null @@ -1,512 +0,0 @@ -local g = (import 'grafana-builder/grafana.libsonnet'); -local grafana = (import 'grafonnet/grafana.libsonnet'); -local dashboard = grafana.dashboard; -local template = grafana.template; -local prometheus = grafana.prometheus; - -local dashboardUid = 'apache-tomcat-hosts'; - -local promDatasourceName = 'prometheus_datasource'; - -local getMatcher(cfg) = '%(tomcatSelector)s, instance=~"$instance"' % cfg; - -local promDatasource = { - uid: '${%s}' % promDatasourceName, -}; - -local sessionsPanel(matcher) = { - datasource: promDatasource, - targets: [ - prometheus.target( - 'sum(increase(tomcat_session_sessioncounter_total{' + matcher + ', host=~"$host", context=~"$context"}[$__interval:] offset -$__interval)) by (job, instance)', - datasource=promDatasource, - legendFormat='{{instance}} - total sessions', - interval='1m', - ), - prometheus.target( - 'sum(increase(tomcat_session_rejectedsessions_total{' + matcher + ', host=~"$host", context=~"$context"}[$__interval:] offset -$__interval)) by (job, instance)', - datasource=promDatasource, - legendFormat='{{instance}} - rejected', - interval='1m', - ), - prometheus.target( - 'sum(increase(tomcat_session_expiredsessions_total{' + matcher + ', host=~"$host", context=~"$context"}[$__interval:] offset -$__interval)) by (job, instance)', - datasource=promDatasource, - legendFormat='{{instance}} - expired', - interval='1m', - ), - prometheus.target( - 'increase(tomcat_session_sessioncounter_total{' + matcher + ', host=~"$host", context=~"$context"}[$__interval:] offset -$__interval)', - datasource=promDatasource, - legendFormat='{{instance}} - {{host}}{{context}} - sessions', - interval='1m', - ), - prometheus.target( - 'increase(tomcat_session_rejectedsessions_total{' + matcher + ', host=~"$host", context=~"$context"}[$__interval:] offset -$__interval)', - datasource=promDatasource, - legendFormat='{{instance}} - {{host}}{{context}} - rejected', - interval='1m', - ), - prometheus.target( - 'increase(tomcat_session_expiredsessions_total{' + matcher + ', host=~"$host", context=~"$context"}[$__interval:] offset -$__interval)', - datasource=promDatasource, - legendFormat='{{instance}} - {{host}}{{context}} - expired', - interval='1m', - ), - ], - type: 'timeseries', - title: 'Sessions', - description: 'The number of different types of sessions created for a Tomcat host', - fieldConfig: { - defaults: { - color: { - mode: 'palette-classic', - }, - custom: { - axisCenteredZero: false, - axisColorMode: 'text', - axisLabel: '', - axisPlacement: 'auto', - barAlignment: 0, - drawStyle: 'line', - fillOpacity: 0, - gradientMode: 'none', - hideFrom: { - legend: false, - tooltip: false, - viz: false, - }, - lineInterpolation: 'linear', - lineStyle: { - fill: 'solid', - }, - lineWidth: 1, - pointSize: 5, - scaleDistribution: { - type: 'linear', - }, - showPoints: 'auto', - spanNulls: false, - stacking: { - group: 'A', - mode: 'none', - }, - thresholdsStyle: { - mode: 'off', - }, - }, - mappings: [], - thresholds: { - mode: 'absolute', - steps: [ - { - color: 'green', - value: null, - }, - { - color: 'red', - value: 80, - }, - ], - }, - }, - overrides: [], - }, - options: { - legend: { - calcs: [], - displayMode: 'list', - placement: 'right', - showLegend: true, - }, - tooltip: { - mode: 'single', - sort: 'none', - }, - }, -}; - -local sessionProcessingTimePanel(matcher) = { - datasource: promDatasource, - targets: [ - prometheus.target( - 'sum(increase(tomcat_session_processingtime_total{' + matcher + ', host=~"$host", context=~"$context"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{job=~"$job", instance=~"$instance", host=~"$host", context=~"$context"}[$__interval:] offset -$__interval), 1)) by (job, instance)', - datasource=promDatasource, - legendFormat='{{instance}} - total', - interval='1m', - ), - prometheus.target( - 'increase(tomcat_session_processingtime_total{' + matcher + ', host=~"$host", context=~"$context"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{job=~"$job", instance=~"$instance", host=~"$host", context=~"$context"}[$__interval:] offset -$__interval), 1)', - datasource=promDatasource, - legendFormat='{{instance}} - {{host}}{{context}}', - interval='1m', - ), - ], - type: 'timeseries', - title: 'Session processing time', - description: 'The average time taken to process recent sessions for a Tomcat host', - fieldConfig: { - defaults: { - color: { - mode: 'palette-classic', - }, - custom: { - axisCenteredZero: false, - axisColorMode: 'text', - axisLabel: '', - axisPlacement: 'auto', - barAlignment: 0, - drawStyle: 'line', - fillOpacity: 0, - gradientMode: 'none', - hideFrom: { - legend: false, - tooltip: false, - viz: false, - }, - lineInterpolation: 'linear', - lineWidth: 1, - pointSize: 5, - scaleDistribution: { - type: 'linear', - }, - showPoints: 'auto', - spanNulls: false, - stacking: { - group: 'A', - mode: 'none', - }, - thresholdsStyle: { - mode: 'off', - }, - }, - mappings: [], - thresholds: { - mode: 'absolute', - steps: [ - { - color: 'green', - value: null, - }, - { - color: 'red', - value: 80, - }, - ], - }, - unit: 'ms', - }, - overrides: [], - }, - options: { - legend: { - calcs: [], - displayMode: 'list', - placement: 'bottom', - showLegend: true, - }, - tooltip: { - mode: 'single', - sort: 'none', - }, - }, -}; - -local servletRow = { - datasource: promDatasource, - targets: [], - type: 'row', - title: 'Servlet', - collapsed: false, -}; - -local servletRequestsPanel(matcher) = { - datasource: promDatasource, - targets: [ - prometheus.target( - 'sum(rate(tomcat_servlet_requestcount_total{' + matcher + ', module=~"$host$context", servlet=~"$servlet"}[$__rate_interval])) by (job, instance)', - datasource=promDatasource, - legendFormat='{{instance}} - total requests', - ), - prometheus.target( - 'sum(rate(tomcat_servlet_errorcount_total{' + matcher + ', module=~"$host$context", servlet=~"$servlet"}[$__rate_interval])) by (job, instance)', - datasource=promDatasource, - legendFormat='{{instance}} - total errors', - ), - prometheus.target( - 'rate(tomcat_servlet_requestcount_total{' + matcher + ', module=~"$host$context", servlet=~"$servlet"}[$__rate_interval])', - datasource=promDatasource, - legendFormat='{{instance}} - {{module}}{{servlet}} - requests', - ), - prometheus.target( - 'rate(tomcat_servlet_errorcount_total{' + matcher + ', module=~"$host$context", servlet=~"$servlet"}[$__rate_interval])', - datasource=promDatasource, - legendFormat='{{instance}} - {{module}}{{servlet}} - errors', - ), - ], - type: 'timeseries', - title: 'Servlet requests', - description: 'The total requests and errors for a Tomcat servlet', - fieldConfig: { - defaults: { - color: { - mode: 'palette-classic', - }, - custom: { - axisCenteredZero: false, - axisColorMode: 'text', - axisLabel: '', - axisPlacement: 'auto', - barAlignment: 0, - drawStyle: 'line', - fillOpacity: 0, - gradientMode: 'none', - hideFrom: { - legend: false, - tooltip: false, - viz: false, - }, - lineInterpolation: 'linear', - lineWidth: 1, - pointSize: 5, - scaleDistribution: { - type: 'linear', - }, - showPoints: 'auto', - spanNulls: false, - stacking: { - group: 'A', - mode: 'none', - }, - thresholdsStyle: { - mode: 'off', - }, - }, - mappings: [], - thresholds: { - mode: 'absolute', - steps: [ - { - color: 'green', - value: null, - }, - { - color: 'red', - value: 80, - }, - ], - }, - unit: 'r/s', - }, - overrides: [], - }, - options: { - legend: { - calcs: [], - displayMode: 'list', - placement: 'right', - showLegend: true, - }, - tooltip: { - mode: 'single', - sort: 'none', - }, - }, -}; - -local servletProcessingTimePanel(matcher) = { - datasource: promDatasource, - targets: [ - prometheus.target( - 'sum(increase(tomcat_servlet_processingtime_total{' + matcher + ', module=~"$host$context", servlet=~"$servlet"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{' + matcher + ', module=~"$host$context", servlet=~"$servlet"}[$__interval:] offset -$__interval), 1)) by (job, instance)', - datasource=promDatasource, - legendFormat='{{instance}} - total', - interval='1m', - ), - prometheus.target( - 'increase(tomcat_servlet_processingtime_total{' + matcher + ', module=~"$host$context", servlet=~"$servlet"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{' + matcher + ', module=~"$host$context", servlet=~"$servlet"}[$__interval:] offset -$__interval), 1)', - datasource=promDatasource, - legendFormat='{{instance}} - {{module}}{{servlet}}', - interval='1m', - ), - ], - type: 'timeseries', - title: 'Servlet processing time', - description: 'The average time taken to process recent requests in a Tomcat servlet', - fieldConfig: { - defaults: { - color: { - mode: 'palette-classic', - }, - custom: { - axisCenteredZero: false, - axisColorMode: 'text', - axisLabel: '', - axisPlacement: 'auto', - barAlignment: 0, - drawStyle: 'line', - fillOpacity: 0, - gradientMode: 'none', - hideFrom: { - legend: false, - tooltip: false, - viz: false, - }, - lineInterpolation: 'linear', - lineWidth: 1, - pointSize: 5, - scaleDistribution: { - type: 'linear', - }, - showPoints: 'auto', - spanNulls: false, - stacking: { - group: 'A', - mode: 'none', - }, - thresholdsStyle: { - mode: 'off', - }, - }, - mappings: [], - thresholds: { - mode: 'absolute', - steps: [ - { - color: 'green', - value: null, - }, - { - color: 'red', - value: 80, - }, - ], - }, - unit: 'ms', - }, - overrides: [], - }, - options: { - legend: { - calcs: [], - displayMode: 'list', - placement: 'bottom', - showLegend: true, - }, - tooltip: { - mode: 'single', - sort: 'none', - }, - }, -}; - -{ - grafanaDashboards+:: { - 'apache-tomcat-hosts.json': - dashboard.new( - 'Apache Tomcat hosts', - time_from='%s' % $._config.dashboardPeriod, - tags=($._config.dashboardTags), - timezone='%s' % $._config.dashboardTimezone, - refresh='%s' % $._config.dashboardRefresh, - description='', - uid=dashboardUid, - ) - - .addLink(grafana.link.dashboards( - asDropdown=false, - title='Other Apache Tomcat dashboards', - includeVars=true, - keepTime=true, - tags=($._config.dashboardTags), - )) - - .addTemplates( - [ - template.datasource( - promDatasourceName, - 'prometheus', - null, - label='Data Source', - refresh='load' - ), - template.new( - 'job', - promDatasource, - 'label_values(tomcat_bytesreceived_total, job)', - label='Job', - refresh=1, - includeAll=false, - multi=false, - allValues='', - sort=0 - ), - template.new( - 'cluster', - promDatasource, - 'label_values(tomcat_bytesreceived_total{%(multiclusterSelector)s}, cluster)' % $._config, - label='Cluster', - refresh=2, - includeAll=true, - multi=true, - allValues='.*', - hide=if $._config.enableMultiCluster then '' else 'variable', - sort=0 - ), - template.new( - 'instance', - promDatasource, - 'label_values(tomcat_bytesreceived_total{%(tomcatSelector)s}, instance)' % $._config, - label='Instance', - refresh=1, - includeAll=false, - multi=false, - allValues='', - sort=0 - ), - template.new( - 'host', - promDatasource, - 'label_values(tomcat_session_sessioncounter_total{%(tomcatSelector)s}, host)' % $._config, - label='Host', - refresh=1, - includeAll=true, - multi=true, - allValues='', - sort=0 - ), - template.new( - 'context', - promDatasource, - 'label_values(tomcat_session_sessioncounter_total{%(tomcatSelector)s, host=~"$host"}, context)' % $._config, - label='Context', - refresh=1, - includeAll=true, - multi=true, - allValues='', - sort=0 - ), - template.new( - 'servlet', - promDatasource, - 'label_values(tomcat_servlet_requestcount_total{%(tomcatSelector)s, module=~"$host$context"}, servlet)' % $._config, - label='Servlet', - refresh=1, - includeAll=true, - multi=true, - allValues='', - sort=0 - ), - ] - ) - .addPanels( - [ - sessionsPanel(getMatcher($._config)) { gridPos: { h: 10, w: 12, x: 0, y: 0 } }, - sessionProcessingTimePanel(getMatcher($._config)) { gridPos: { h: 10, w: 12, x: 12, y: 0 } }, - servletRow { gridPos: { h: 1, w: 24, x: 0, y: 10 } }, - servletRequestsPanel(getMatcher($._config)) { gridPos: { h: 10, w: 12, x: 0, y: 11 } }, - servletProcessingTimePanel(getMatcher($._config)) { gridPos: { h: 10, w: 12, x: 12, y: 11 } }, - ] - ), - }, -} diff --git a/apache-tomcat-mixin/dashboards/apache-tomcat-overview.libsonnet b/apache-tomcat-mixin/dashboards/apache-tomcat-overview.libsonnet deleted file mode 100644 index 856b3a21e..000000000 --- a/apache-tomcat-mixin/dashboards/apache-tomcat-overview.libsonnet +++ /dev/null @@ -1,794 +0,0 @@ -local g = (import 'grafana-builder/grafana.libsonnet'); -local grafana = (import 'grafonnet/grafana.libsonnet'); -local dashboard = grafana.dashboard; -local template = grafana.template; -local prometheus = grafana.prometheus; - -local dashboardUid = 'apache-tomcat-overview'; - -local promDatasourceName = 'prometheus_datasource'; -local lokiDatasourceName = 'loki_datasource'; - -local filenameLogFilter = 'filename=~"/var/log/tomcat.*/catalina.out|/opt/tomcat/logs/catalina.out|/Program Files/Apache Software Foundation/Tomcat .*..*/logs/catalina.out"'; - -local getMatcher(cfg) = '%(tomcatSelector)s, instance=~"$instance"' % cfg; - -local promDatasource = { - uid: '${%s}' % promDatasourceName, -}; - -local lokiDatasource = { - uid: '${%s}' % lokiDatasourceName, -}; - -local memoryUsagePanel(matcher) = { - datasource: promDatasource, - targets: [ - prometheus.target( - 'jvm_memory_usage_used_bytes{' + matcher + '}', - datasource=promDatasource, - legendFormat='{{instance}} - {{area}}', - ), - ], - type: 'timeseries', - title: 'Memory usage', - description: 'The memory usage of the JVM of the instance', - fieldConfig: { - defaults: { - color: { - mode: 'palette-classic', - }, - custom: { - axisCenteredZero: false, - axisColorMode: 'text', - axisLabel: '', - axisPlacement: 'auto', - barAlignment: 0, - drawStyle: 'line', - fillOpacity: 0, - gradientMode: 'none', - hideFrom: { - legend: false, - tooltip: false, - viz: false, - }, - lineInterpolation: 'linear', - lineStyle: { - fill: 'solid', - }, - lineWidth: 1, - pointSize: 5, - scaleDistribution: { - type: 'linear', - }, - showPoints: 'auto', - spanNulls: false, - stacking: { - group: 'A', - mode: 'none', - }, - thresholdsStyle: { - mode: 'off', - }, - }, - mappings: [], - thresholds: { - mode: 'absolute', - steps: [ - { - color: 'green', - value: null, - }, - { - color: 'red', - value: 80, - }, - ], - }, - unit: 'bytes', - }, - overrides: [], - }, - options: { - legend: { - calcs: [], - displayMode: 'list', - placement: 'bottom', - showLegend: true, - }, - tooltip: { - mode: 'single', - sort: 'none', - }, - }, -}; - -local cpuUsagePanel(matcher) = { - datasource: promDatasource, - targets: [ - prometheus.target( - 'jvm_process_cpu_load{' + matcher + '}', - datasource=promDatasource, - legendFormat='{{instance}}', - ), - ], - type: 'timeseries', - title: 'CPU usage', - description: 'The CPU usage of the JVM process', - fieldConfig: { - defaults: { - color: { - mode: 'palette-classic', - }, - custom: { - axisCenteredZero: false, - axisColorMode: 'text', - axisLabel: '', - axisPlacement: 'auto', - barAlignment: 0, - drawStyle: 'line', - fillOpacity: 0, - gradientMode: 'none', - hideFrom: { - legend: false, - tooltip: false, - viz: false, - }, - lineInterpolation: 'linear', - lineWidth: 1, - pointSize: 5, - scaleDistribution: { - type: 'linear', - }, - showPoints: 'auto', - spanNulls: false, - stacking: { - group: 'A', - mode: 'none', - }, - thresholdsStyle: { - mode: 'line', - }, - }, - mappings: [], - thresholds: { - mode: 'absolute', - steps: [ - { - color: 'green', - value: null, - }, - { - color: 'red', - value: 80, - }, - ], - }, - unit: 'percentunit', - }, - overrides: [], - }, - options: { - legend: { - calcs: [], - displayMode: 'list', - placement: 'bottom', - showLegend: true, - }, - tooltip: { - mode: 'single', - sort: 'none', - }, - }, -}; - -local trafficSentPanel(matcher) = { - datasource: promDatasource, - targets: [ - prometheus.target( - 'sum(rate(tomcat_bytessent_total{' + matcher + ', protocol=~"$protocol", port=~"$port"}[$__rate_interval])) by (job, instance)', - datasource=promDatasource, - legendFormat='{{instance}} - total', - ), - prometheus.target( - 'rate(tomcat_bytessent_total{' + matcher + ', protocol=~"$protocol", port=~"$port"}[$__rate_interval])', - datasource=promDatasource, - legendFormat='{{instance}} - {{protocol}}-{{port}}', - ), - ], - type: 'timeseries', - title: 'Traffic sent', - description: 'The sent traffic for a Tomcat connector', - fieldConfig: { - defaults: { - color: { - mode: 'palette-classic', - }, - custom: { - axisCenteredZero: false, - axisColorMode: 'text', - axisLabel: '', - axisPlacement: 'auto', - barAlignment: 0, - drawStyle: 'line', - fillOpacity: 0, - gradientMode: 'none', - hideFrom: { - legend: false, - tooltip: false, - viz: false, - }, - lineInterpolation: 'linear', - lineWidth: 1, - pointSize: 5, - scaleDistribution: { - type: 'linear', - }, - showPoints: 'auto', - spanNulls: false, - stacking: { - group: 'A', - mode: 'none', - }, - thresholdsStyle: { - mode: 'off', - }, - }, - mappings: [], - thresholds: { - mode: 'absolute', - steps: [ - { - color: 'green', - value: null, - }, - { - color: 'red', - value: 80, - }, - ], - }, - unit: 'Bps', - }, - overrides: [], - }, - options: { - legend: { - calcs: [], - displayMode: 'list', - placement: 'bottom', - showLegend: true, - }, - tooltip: { - mode: 'single', - sort: 'none', - }, - }, -}; - -local trafficReceivedPanel(matcher) = { - datasource: promDatasource, - targets: [ - prometheus.target( - 'sum(rate(tomcat_bytesreceived_total{' + matcher + ', protocol=~"$protocol", port=~"$port"}[$__rate_interval])) by (job, instance)', - datasource=promDatasource, - legendFormat='{{instance}} - total', - ), - prometheus.target( - 'rate(tomcat_bytesreceived_total{' + matcher + ', protocol=~"$protocol", port=~"$port"}[$__rate_interval])', - datasource=promDatasource, - legendFormat='{{instance}} - {{protocol}}-{{port}}', - ), - ], - type: 'timeseries', - title: 'Traffic received', - description: 'The received traffic for a Tomcat connector', - fieldConfig: { - defaults: { - color: { - mode: 'palette-classic', - }, - custom: { - axisCenteredZero: false, - axisColorMode: 'text', - axisLabel: '', - axisPlacement: 'auto', - barAlignment: 0, - drawStyle: 'line', - fillOpacity: 0, - gradientMode: 'none', - hideFrom: { - legend: false, - tooltip: false, - viz: false, - }, - lineInterpolation: 'linear', - lineWidth: 1, - pointSize: 5, - scaleDistribution: { - type: 'linear', - }, - showPoints: 'auto', - spanNulls: false, - stacking: { - group: 'A', - mode: 'none', - }, - thresholdsStyle: { - mode: 'off', - }, - }, - mappings: [], - thresholds: { - mode: 'absolute', - steps: [ - { - color: 'green', - value: null, - }, - { - color: 'red', - value: 80, - }, - ], - }, - unit: 'Bps', - }, - overrides: [], - }, - options: { - legend: { - calcs: [], - displayMode: 'list', - placement: 'bottom', - showLegend: true, - }, - tooltip: { - mode: 'single', - sort: 'none', - }, - }, -}; - -local requestsPanel(matcher) = { - datasource: promDatasource, - targets: [ - prometheus.target( - 'sum(rate(tomcat_requestcount_total{' + matcher + ', protocol=~"$protocol", port=~"$port"}[$__rate_interval])) by (job, instance)', - datasource=promDatasource, - legendFormat='{{instance}} - total requests', - ), - prometheus.target( - 'sum(rate(tomcat_errorcount_total{' + matcher + ', protocol=~"$protocol", port=~"$port"}[$__rate_interval])) by (job, instance)', - datasource=promDatasource, - legendFormat='{{instance}} - total errors', - ), - prometheus.target( - 'rate(tomcat_requestcount_total{' + matcher + ', protocol=~"$protocol", port=~"$port"}[$__rate_interval])', - datasource=promDatasource, - legendFormat='{{instance}} - {{protocol}}-{{port}} - requests', - ), - prometheus.target( - 'rate(tomcat_errorcount_total{' + matcher + ', protocol=~"$protocol", port=~"$port"}[$__rate_interval])', - datasource=promDatasource, - legendFormat='{{instance}} - {{protocol}}-{{port}} - errors', - ), - ], - type: 'timeseries', - title: 'Requests', - description: 'The total requests and errors for a Tomcat connector', - fieldConfig: { - defaults: { - color: { - mode: 'palette-classic', - }, - custom: { - axisCenteredZero: false, - axisColorMode: 'text', - axisLabel: '', - axisPlacement: 'auto', - barAlignment: 0, - drawStyle: 'line', - fillOpacity: 0, - gradientMode: 'none', - hideFrom: { - legend: false, - tooltip: false, - viz: false, - }, - lineInterpolation: 'linear', - lineWidth: 1, - pointSize: 5, - scaleDistribution: { - type: 'linear', - }, - showPoints: 'auto', - spanNulls: false, - stacking: { - group: 'A', - mode: 'none', - }, - thresholdsStyle: { - mode: 'off', - }, - }, - mappings: [], - thresholds: { - mode: 'absolute', - steps: [ - { - color: 'green', - value: null, - }, - { - color: 'red', - value: 80, - }, - ], - }, - unit: 'r/s', - }, - overrides: [], - }, - options: { - legend: { - calcs: [], - displayMode: 'list', - placement: 'bottom', - showLegend: true, - }, - tooltip: { - mode: 'single', - sort: 'none', - }, - }, -}; - -local processingTimePanel(matcher) = { - datasource: promDatasource, - targets: [ - prometheus.target( - 'sum(increase(tomcat_processingtime_total{' + matcher + ', protocol=~"$protocol", port=~"$port"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_requestcount_total{' + matcher + ', protocol=~"$protocol", port=~"$port"}[$__interval:] offset -$__interval), 1)) by (job, instance)', - datasource=promDatasource, - legendFormat='{{instance}} - total', - interval='1m', - ), - prometheus.target( - 'increase(tomcat_processingtime_total{' + matcher + ', protocol=~"$protocol", port=~"$port"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_requestcount_total{' + matcher + ', protocol=~"$protocol", port=~"$port"}[$__interval:] offset -$__interval), 1)', - datasource=promDatasource, - legendFormat='{{instance}} - {{protocol}}-{{port}}', - interval='1m', - ), - ], - type: 'timeseries', - title: 'Processing time', - description: 'The average time taken to process recent requests for a Tomcat connector', - fieldConfig: { - defaults: { - color: { - mode: 'palette-classic', - }, - custom: { - axisCenteredZero: false, - axisColorMode: 'text', - axisLabel: '', - axisPlacement: 'auto', - axisSoftMin: 0, - barAlignment: 0, - drawStyle: 'line', - fillOpacity: 0, - gradientMode: 'none', - hideFrom: { - legend: false, - tooltip: false, - viz: false, - }, - lineInterpolation: 'linear', - lineWidth: 1, - pointSize: 5, - scaleDistribution: { - type: 'linear', - }, - showPoints: 'auto', - spanNulls: false, - stacking: { - group: 'A', - mode: 'none', - }, - thresholdsStyle: { - mode: 'line', - }, - }, - mappings: [], - thresholds: { - mode: 'absolute', - steps: [ - { - color: 'green', - value: null, - }, - { - color: 'red', - value: 300, - }, - ], - }, - unit: 'ms', - }, - overrides: [], - }, - options: { - legend: { - calcs: [], - displayMode: 'list', - placement: 'bottom', - showLegend: true, - }, - tooltip: { - mode: 'single', - sort: 'none', - }, - }, -}; - -local threadsPanel(matcher) = { - datasource: promDatasource, - targets: [ - prometheus.target( - 'sum(tomcat_threadpool_connectioncount{' + matcher + ', protocol=~"$protocol", port=~"$port"}) by (job, instance)', - datasource=promDatasource, - legendFormat='{{instance}} - total connections', - ), - prometheus.target( - 'sum(tomcat_threadpool_pollerthreadcount{' + matcher + ', protocol=~"$protocol", port=~"$port"}) by (job, instance)', - datasource=promDatasource, - legendFormat='{{instance}} - poller total', - ), - prometheus.target( - 'sum(tomcat_threadpool_keepalivecount{' + matcher + ', protocol=~"$protocol", port=~"$port"}) by (job, instance)', - datasource=promDatasource, - legendFormat='{{instance}} - idle total', - ), - prometheus.target( - 'sum(tomcat_threadpool_currentthreadcount{' + matcher + ', protocol=~"$protocol", port=~"$port"}) by (job, instance)', - datasource=promDatasource, - legendFormat='{{instance}} - active total', - ), - prometheus.target( - 'tomcat_threadpool_connectioncount{' + matcher + ', protocol=~"$protocol", port=~"$port"}', - datasource=promDatasource, - legendFormat='{{instance}} - {{protocol}}-{{port}} - connections', - ), - prometheus.target( - 'tomcat_threadpool_pollerthreadcount{' + matcher + ', protocol=~"$protocol", port=~"$port"}', - datasource=promDatasource, - legendFormat='{{instance}} - {{protocol}}-{{port}} - poller', - ), - prometheus.target( - 'tomcat_threadpool_keepalivecount{' + matcher + ', protocol=~"$protocol", port=~"$port"}', - datasource=promDatasource, - legendFormat='{{instance}} - {{protocol}}-{{port}} - idle', - ), - prometheus.target( - 'tomcat_threadpool_currentthreadcount{' + matcher + ', protocol=~"$protocol", port=~"$port"}', - datasource=promDatasource, - legendFormat='{{instance}} - {{protocol}}-{{port}} - active', - ), - ], - type: 'timeseries', - title: 'Threads', - description: 'The number of various threads being used by a Tomcat connector', - fieldConfig: { - defaults: { - color: { - mode: 'palette-classic', - }, - custom: { - axisCenteredZero: false, - axisColorMode: 'text', - axisLabel: '', - axisPlacement: 'auto', - barAlignment: 0, - drawStyle: 'line', - fillOpacity: 0, - gradientMode: 'none', - hideFrom: { - legend: false, - tooltip: false, - viz: false, - }, - lineInterpolation: 'linear', - lineWidth: 1, - pointSize: 5, - scaleDistribution: { - type: 'linear', - }, - showPoints: 'auto', - spanNulls: false, - stacking: { - group: 'A', - mode: 'none', - }, - thresholdsStyle: { - mode: 'off', - }, - }, - mappings: [], - thresholds: { - mode: 'absolute', - steps: [ - { - color: 'green', - value: null, - }, - { - color: 'red', - value: 80, - }, - ], - }, - }, - overrides: [], - }, - options: { - legend: { - calcs: [], - displayMode: 'list', - placement: 'right', - showLegend: true, - }, - tooltip: { - mode: 'single', - sort: 'none', - }, - }, -}; - -local logsPanel(matcher) = { - datasource: lokiDatasource, - targets: [ - { - datasource: lokiDatasource, - editorMode: 'code', - expr: '{' + matcher + '} |= `` | (' + filenameLogFilter + ' or log_type="catalina.out")', - queryType: 'range', - refId: 'A', - }, - ], - type: 'logs', - title: 'Logs', - description: 'Recent logs from the Catalina.out logs file\n', - options: { - dedupStrategy: 'none', - enableLogDetails: true, - prettifyLogMessage: false, - showCommonLabels: false, - showLabels: false, - showTime: false, - sortOrder: 'Descending', - wrapLogMessage: false, - }, -}; - -{ - grafanaDashboards+:: { - 'apache-tomcat-overview.json': - dashboard.new( - 'Apache Tomcat overview', - time_from='%s' % $._config.dashboardPeriod, - tags=($._config.dashboardTags), - timezone='%s' % $._config.dashboardTimezone, - refresh='%s' % $._config.dashboardRefresh, - description='', - uid=dashboardUid, - ) - - .addLink(grafana.link.dashboards( - asDropdown=false, - title='Other Apache Tomcat dashboards', - includeVars=true, - keepTime=true, - tags=($._config.dashboardTags), - )) - - .addTemplates( - std.flattenArrays([ - [ - template.datasource( - promDatasourceName, - 'prometheus', - null, - label='Data Source', - refresh='load' - ), - ], - if $._config.enableLokiLogs then [ - template.datasource( - lokiDatasourceName, - 'loki', - null, - label='Loki Datasource', - refresh='load' - ), - ] else [], - [ - template.new( - 'job', - promDatasource, - 'label_values(tomcat_bytesreceived_total, job)', - label='Job', - refresh=1, - includeAll=false, - multi=false, - allValues='', - sort=0 - ), - template.new( - 'cluster', - promDatasource, - 'label_values(tomcat_bytesreceived_total{%(multiclusterSelector)s}, cluster)' % $._config, - label='Cluster', - refresh=2, - includeAll=true, - multi=true, - allValues='.*', - hide=if $._config.enableMultiCluster then '' else 'variable', - sort=0 - ), - template.new( - 'instance', - promDatasource, - 'label_values(tomcat_bytesreceived_total{%(tomcatSelector)s}, instance)' % $._config, - label='Instance', - refresh=2, - includeAll=true, - multi=true, - allValues='.+', - sort=1 - ), - template.new( - 'protocol', - promDatasource, - 'label_values(tomcat_bytesreceived_total{%(tomcatSelector)s}, protocol)' % $._config, - label='Protocol', - refresh=1, - includeAll=true, - multi=true, - allValues='.+', - sort=0 - ), - template.new( - 'port', - promDatasource, - 'label_values(tomcat_bytesreceived_total{%(tomcatSelector)s}, port)' % $._config, - label='Port', - refresh=1, - includeAll=true, - multi=true, - allValues='.+', - sort=0 - ), - ], - ]) - ) - .addPanels( - std.flattenArrays([ - [ - memoryUsagePanel(getMatcher($._config)) { gridPos: { h: 6, w: 12, x: 0, y: 0 } }, - cpuUsagePanel(getMatcher($._config)) { gridPos: { h: 6, w: 12, x: 12, y: 0 } }, - trafficSentPanel(getMatcher($._config)) { gridPos: { h: 6, w: 12, x: 0, y: 6 } }, - trafficReceivedPanel(getMatcher($._config)) { gridPos: { h: 6, w: 12, x: 12, y: 6 } }, - requestsPanel(getMatcher($._config)) { gridPos: { h: 6, w: 12, x: 0, y: 12 } }, - processingTimePanel(getMatcher($._config)) { gridPos: { h: 6, w: 12, x: 12, y: 12 } }, - threadsPanel(getMatcher($._config)) { gridPos: { h: 6, w: 24, x: 0, y: 18 } }, - ], - if $._config.enableLokiLogs then [ - logsPanel(getMatcher($._config)) { gridPos: { h: 6, w: 24, x: 0, y: 24 } }, - ] else [], - [ - ], - ]) - ), - - }, -} diff --git a/apache-tomcat-mixin/dashboards/dashboards.libsonnet b/apache-tomcat-mixin/dashboards/dashboards.libsonnet deleted file mode 100644 index dda76b478..000000000 --- a/apache-tomcat-mixin/dashboards/dashboards.libsonnet +++ /dev/null @@ -1,2 +0,0 @@ -(import 'apache-tomcat-overview.libsonnet') + -(import 'apache-tomcat-hosts.libsonnet') diff --git a/apache-tomcat-mixin/dashboards_out/apache-tomcat-hosts.json b/apache-tomcat-mixin/dashboards_out/apache-tomcat-hosts.json index 293ad5315..67afd06e6 100644 --- a/apache-tomcat-mixin/dashboards_out/apache-tomcat-hosts.json +++ b/apache-tomcat-mixin/dashboards_out/apache-tomcat-hosts.json @@ -1,170 +1,150 @@ { - "__inputs": [ ], - "__requires": [ ], "annotations": { "list": [ ] }, - "description": "", "editable": false, - "gnetId": null, - "graphTooltip": 0, - "hideControls": false, "id": null, "links": [ { - "asDropdown": false, - "icon": "external link", + "keepTime": true, + "title": "Apache Tomcat logs", + "type": "link", + "url": "/d/apachetomcat-logs" + }, + { + "keepTime": true, + "title": "Apache Tomcat overview", + "type": "link", + "url": "/d/apachetomcat_overview" + }, + { + "asDropdown": true, "includeVars": true, "keepTime": true, "tags": [ "apache-tomcat-mixin" ], - "targetBlank": false, - "title": "Other Apache Tomcat dashboards", - "type": "dashboards", - "url": "" + "title": "All dashboards", + "type": "dashboards" } ], "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 0, + "x": 0, + "y": 0 + }, + "id": 1, + "panels": [ ], + "title": "Hosts", + "type": "row" + }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "description": "The number of different types of sessions created for a Tomcat host", + "description": "The number of different types of sessions created for a Tomcat host.", "fieldConfig": { "defaults": { - "color": { - "mode": "palette-classic" - }, "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineStyle": { - "fill": "solid" - }, - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [ ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] + "fillOpacity": 30, + "gradientMode": "opacity", + "lineInterpolation": "smooth", + "lineWidth": 2, + "showPoints": "never" } - }, - "overrides": [ ] + } }, "gridPos": { - "h": 10, - "w": 12, + "h": 8, + "w": 8, "x": 0, - "y": 0 + "y": 1 }, "id": 2, "options": { "legend": { + "asTable": true, "calcs": [ ], "displayMode": "list", - "placement": "right", - "showLegend": true + "placement": "right" }, "tooltip": { - "mode": "single", - "sort": "none" + "mode": "multi", + "sort": "desc" } }, + "pluginVersion": "v11.0.0", "targets": [ { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(increase(tomcat_session_sessioncounter_total{job=~\"$job\", instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval)) by (job, instance)", + "expr": "sum(increase(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)) by (job, instance)", "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{instance}} - total sessions" + "instant": false, + "legendFormat": "{{ instance }} - total sessions", + "refId": "Total sessions" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(increase(tomcat_session_rejectedsessions_total{job=~\"$job\", instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval)) by (job, instance)", + "expr": "sum(increase(tomcat_session_rejectedsessions_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)) by (job, instance)", "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{instance}} - rejected" + "instant": false, + "legendFormat": "{{ instance }} - rejected sessions", + "refId": "Rejected sessions" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(increase(tomcat_session_expiredsessions_total{job=~\"$job\", instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval)) by (job, instance)", + "expr": "sum(increase(tomcat_session_expiredsessions_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)) by (job, instance)", "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{instance}} - expired" + "instant": false, + "legendFormat": "{{ instance }} - expired sessions", + "refId": "Expired sessions" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "increase(tomcat_session_sessioncounter_total{job=~\"$job\", instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval)", + "expr": "increase(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)", "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{instance}} - {{host}}{{context}} - sessions" + "instant": false, + "legendFormat": "{{ instance }} - {{host}}{{context}} - sessions", + "refId": "Session rate" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "increase(tomcat_session_rejectedsessions_total{job=~\"$job\", instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval)", + "expr": "increase(tomcat_session_rejectedsessions_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)", "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{instance}} - {{host}}{{context}} - rejected" + "instant": false, + "legendFormat": "{{ instance }} - {{host}}{{context}} - rejected", + "refId": "Rejected rate" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "increase(tomcat_session_expiredsessions_total{job=~\"$job\", instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval)", + "expr": "increase(tomcat_session_expiredsessions_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)", "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{instance}} - {{host}}{{context}} - expired" + "instant": false, + "legendFormat": "{{ instance }} - {{host}}{{context}} - expired", + "refId": "Expired rate" } ], "title": "Sessions", @@ -172,528 +152,296 @@ }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "description": "The average time taken to process recent sessions for a Tomcat host", + "description": "The average time taken to process recent sessions for a Tomcat host.", "fieldConfig": { "defaults": { - "color": { - "mode": "palette-classic" - }, "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [ ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] + "fillOpacity": 30, + "gradientMode": "opacity", + "lineInterpolation": "smooth", + "lineWidth": 2, + "showPoints": "never" }, "unit": "ms" - }, - "overrides": [ ] + } }, "gridPos": { - "h": 10, - "w": 12, - "x": 12, - "y": 0 + "h": 8, + "w": 8, + "x": 8, + "y": 1 }, "id": 3, "options": { "legend": { + "asTable": true, "calcs": [ ], "displayMode": "list", - "placement": "bottom", - "showLegend": true + "placement": "right" }, "tooltip": { - "mode": "single", - "sort": "none" + "mode": "multi", + "sort": "desc" } }, + "pluginVersion": "v11.0.0", "targets": [ { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(increase(tomcat_session_processingtime_total{job=~\"$job\", instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{job=~\"$job\", instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval), 1)) by (job, instance)", + "expr": "sum(increase(tomcat_session_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval), 1)) by (job, instance)", "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{instance}} - total" + "instant": false, + "legendFormat": "{{ instance }} - total", + "refId": "Total session processing time" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "increase(tomcat_session_processingtime_total{job=~\"$job\", instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{job=~\"$job\", instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval), 1)", + "expr": "increase(tomcat_session_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval), 1)", "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{instance}} - {{host}}{{context}}" + "instant": false, + "legendFormat": "{{ instance }} - {{host}}{{context}}", + "refId": "Session processing time" } ], "title": "Session processing time", "type": "timeseries" }, - { - "collapsed": false, - "datasource": { - "uid": "${prometheus_datasource}" - }, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 10 - }, - "id": 4, - "targets": [ ], - "title": "Servlet", - "type": "row" - }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "description": "The total requests and errors for a Tomcat servlet", + "description": "The total requests and errors for a Tomcat servlet.", "fieldConfig": { "defaults": { - "color": { - "mode": "palette-classic" - }, "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } + "fillOpacity": 30, + "gradientMode": "opacity", + "lineInterpolation": "smooth", + "lineWidth": 2, + "showPoints": "never" }, - "mappings": [ ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "r/s" - }, - "overrides": [ ] + "unit": "reqps" + } }, "gridPos": { - "h": 10, - "w": 12, - "x": 0, - "y": 11 + "h": 8, + "w": 8, + "x": 16, + "y": 1 }, - "id": 5, + "id": 4, "options": { "legend": { + "asTable": true, "calcs": [ ], "displayMode": "list", - "placement": "right", - "showLegend": true + "placement": "right" }, "tooltip": { - "mode": "single", - "sort": "none" + "mode": "multi", + "sort": "desc" } }, + "pluginVersion": "v11.0.0", "targets": [ { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(rate(tomcat_servlet_requestcount_total{job=~\"$job\", instance=~\"$instance\", module=~\"$host$context\", servlet=~\"$servlet\"}[$__rate_interval])) by (job, instance)", + "expr": "sum(rate(tomcat_servlet_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - total requests" + "instant": false, + "legendFormat": "{{ instance }} - total requests", + "refId": "Total servlet requests" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(rate(tomcat_servlet_errorcount_total{job=~\"$job\", instance=~\"$instance\", module=~\"$host$context\", servlet=~\"$servlet\"}[$__rate_interval])) by (job, instance)", + "expr": "sum(rate(tomcat_servlet_errorcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - total errors" + "instant": false, + "legendFormat": "{{ instance }} - total errors", + "refId": "Total servlet errors" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "rate(tomcat_servlet_requestcount_total{job=~\"$job\", instance=~\"$instance\", module=~\"$host$context\", servlet=~\"$servlet\"}[$__rate_interval])", + "expr": "rate(tomcat_servlet_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - {{module}}{{servlet}} - requests" + "instant": false, + "legendFormat": "{{ instance }} - {{host}}{{servlet}} - requests", + "refId": "Servlet request rate" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "rate(tomcat_servlet_errorcount_total{job=~\"$job\", instance=~\"$instance\", module=~\"$host$context\", servlet=~\"$servlet\"}[$__rate_interval])", + "expr": "rate(tomcat_servlet_errorcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - {{module}}{{servlet}} - errors" + "instant": false, + "legendFormat": "{{ instance }} - {{host}}{{context}} - errors", + "refId": "Servlet error rate" } ], - "title": "Servlet requests", + "title": "Servlet", "type": "timeseries" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "description": "The average time taken to process recent requests in a Tomcat servlet", + "description": "The average time taken to process recent servlet requests for a Tomcat host.", "fieldConfig": { "defaults": { - "color": { - "mode": "palette-classic" - }, "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [ ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] + "fillOpacity": 30, + "gradientMode": "opacity", + "lineInterpolation": "smooth", + "lineWidth": 2, + "showPoints": "never" }, "unit": "ms" - }, - "overrides": [ ] + } }, "gridPos": { - "h": 10, - "w": 12, - "x": 12, - "y": 11 + "h": 8, + "w": 8, + "x": 0, + "y": 9 }, - "id": 6, + "id": 5, "options": { "legend": { + "asTable": true, "calcs": [ ], "displayMode": "list", - "placement": "bottom", - "showLegend": true + "placement": "right" }, "tooltip": { - "mode": "single", - "sort": "none" + "mode": "multi", + "sort": "desc" } }, + "pluginVersion": "v11.0.0", "targets": [ { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(increase(tomcat_servlet_processingtime_total{job=~\"$job\", instance=~\"$instance\", module=~\"$host$context\", servlet=~\"$servlet\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{job=~\"$job\", instance=~\"$instance\", module=~\"$host$context\", servlet=~\"$servlet\"}[$__interval:] offset -$__interval), 1)) by (job, instance)", + "expr": "sum(increase(tomcat_servlet_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval), 1)) by (job, instance)", "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{instance}} - total" + "instant": false, + "legendFormat": "{{ instance }} - total", + "refId": "Total servlet processing time" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "increase(tomcat_servlet_processingtime_total{job=~\"$job\", instance=~\"$instance\", module=~\"$host$context\", servlet=~\"$servlet\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{job=~\"$job\", instance=~\"$instance\", module=~\"$host$context\", servlet=~\"$servlet\"}[$__interval:] offset -$__interval), 1)", + "expr": "increase(tomcat_servlet_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval), 1)", "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{instance}} - {{module}}{{servlet}}" + "instant": false, + "legendFormat": "{{ instance }} - {{host}}{{servlet}}", + "refId": "Servlet processing time" } ], "title": "Servlet processing time", "type": "timeseries" } ], - "refresh": "1m", - "rows": [ ], - "schemaVersion": 14, - "style": "dark", + "refresh": "30s", + "schemaVersion": 39, "tags": [ "apache-tomcat-mixin" ], "templating": { "list": [ { - "current": { }, - "hide": 0, - "label": "Data Source", + "label": "Prometheus data source", "name": "prometheus_datasource", - "options": [ ], "query": "prometheus", - "refresh": 1, - "regex": "", + "regex": "(?!grafanacloud-usage|grafanacloud-ml-metrics).+", "type": "datasource" }, { - "allValue": "", - "current": { }, + "allValue": ".+", "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "hide": 0, - "includeAll": false, + "includeAll": true, "label": "Job", - "multi": false, + "multi": true, "name": "job", - "options": [ ], - "query": "label_values(tomcat_bytesreceived_total, job)", - "refresh": 1, - "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [ ], - "tagsQuery": "", - "type": "query", - "useTags": false + "query": "label_values(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\"}, job)", + "refresh": 2, + "sort": 1, + "type": "query" }, { "allValue": ".*", - "current": { }, "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "hide": 2, "includeAll": true, "label": "Cluster", "multi": true, "name": "cluster", - "options": [ ], - "query": "label_values(tomcat_bytesreceived_total{job=~\"$job\"}, cluster)", + "query": "label_values(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\"}, cluster)", "refresh": 2, - "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [ ], - "tagsQuery": "", - "type": "query", - "useTags": false + "sort": 1, + "type": "query" }, { - "allValue": "", - "current": { }, + "allValue": ".+", "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "hide": 0, - "includeAll": false, - "label": "Instance", - "multi": false, - "name": "instance", - "options": [ ], - "query": "label_values(tomcat_bytesreceived_total{job=~\"$job\"}, instance)", - "refresh": 1, - "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [ ], - "tagsQuery": "", - "type": "query", - "useTags": false - }, - { - "allValue": "", - "current": { }, - "datasource": { - "uid": "${prometheus_datasource}" - }, - "hide": 0, - "includeAll": true, - "label": "Host", - "multi": true, - "name": "host", - "options": [ ], - "query": "label_values(tomcat_session_sessioncounter_total{job=~\"$job\"}, host)", - "refresh": 1, - "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [ ], - "tagsQuery": "", - "type": "query", - "useTags": false - }, - { - "allValue": "", - "current": { }, - "datasource": { - "uid": "${prometheus_datasource}" - }, - "hide": 0, "includeAll": true, - "label": "Context", + "label": "Instance", "multi": true, - "name": "context", - "options": [ ], - "query": "label_values(tomcat_session_sessioncounter_total{job=~\"$job\", host=~\"$host\"}, context)", - "refresh": 1, - "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [ ], - "tagsQuery": "", - "type": "query", - "useTags": false + "name": "instance", + "query": "label_values(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\"}, instance)", + "refresh": 2, + "sort": 1, + "type": "query" }, { - "allValue": "", - "current": { }, - "datasource": { - "uid": "${prometheus_datasource}" - }, - "hide": 0, - "includeAll": true, - "label": "Servlet", - "multi": true, - "name": "servlet", - "options": [ ], - "query": "label_values(tomcat_servlet_requestcount_total{job=~\"$job\", module=~\"$host$context\"}, servlet)", - "refresh": 1, - "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [ ], - "tagsQuery": "", - "type": "query", - "useTags": false + "hide": 2, + "label": "Loki data source", + "name": "loki_datasource", + "query": "loki", + "regex": "(?!grafanacloud.+usage-insights|grafanacloud.+alert-state-history).+", + "type": "datasource" } ] }, "time": { - "from": "now-1h", + "from": "now-30m", "to": "now" }, - "timepicker": { - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] - }, "timezone": "default", "title": "Apache Tomcat hosts", - "uid": "apache-tomcat-hosts", - "version": 0 + "uid": "apachetomcat_hosts" } \ No newline at end of file diff --git a/apache-tomcat-mixin/dashboards_out/apache-tomcat-logs.json b/apache-tomcat-mixin/dashboards_out/apache-tomcat-logs.json new file mode 100644 index 000000000..68b392c50 --- /dev/null +++ b/apache-tomcat-mixin/dashboards_out/apache-tomcat-logs.json @@ -0,0 +1,327 @@ +{ + "annotations": { + "list": [ ] + }, + "editable": false, + "id": null, + "links": [ + { + "keepTime": true, + "title": "Apache Tomcat hosts", + "type": "link", + "url": "/d/apachetomcat_hosts" + }, + { + "keepTime": true, + "title": "Apache Tomcat logs", + "type": "link", + "url": "/d/apachetomcat-logs" + }, + { + "keepTime": true, + "title": "Apache Tomcat overview", + "type": "link", + "url": "/d/apachetomcat_overview" + }, + { + "asDropdown": true, + "includeVars": true, + "keepTime": true, + "tags": [ + "apache-tomcat-mixin" + ], + "title": "All dashboards", + "type": "dashboards" + } + ], + "panels": [ + { + "datasource": { + "type": "loki", + "uid": "${loki_datasource}" + }, + "description": "Logs volume grouped by \"level\" label.", + "fieldConfig": { + "defaults": { + "custom": { + "drawStyle": "bars", + "fillOpacity": 50, + "stacking": { + "mode": "normal" + } + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "(E|e)merg|(F|f)atal|(A|a)lert|(C|c)rit.*" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "purple", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "(E|e)(rr.*|RR.*)" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "red", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "(W|w)(arn.*|ARN.*|rn|RN)" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "(N|n)(otice|ote)|(I|i)(nf.*|NF.*)" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "green", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "dbg.*|DBG.*|(D|d)(EBUG|ebug)" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "(T|t)(race|RACE)" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "light-blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "logs" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "text", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 1, + "maxDataPoints": 100, + "options": { + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "v11.0.0", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${loki_datasource}" + }, + "expr": "sum by (level) (count_over_time({job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",level=~\"$level\"}\n|~ \"$regex_search\"\n\n[$__auto]))\n", + "legendFormat": "{{ level }}" + } + ], + "title": "Logs volume", + "transformations": [ + { + "id": "renameByRegex", + "options": { + "regex": "Value", + "renamePattern": "logs" + } + } + ], + "type": "timeseries" + }, + { + "datasource": { + "type": "datasource", + "uid": "-- Mixed --" + }, + "gridPos": { + "h": 18, + "w": 24, + "x": 0, + "y": 18 + }, + "id": 2, + "options": { + "dedupStrategy": "exact", + "enableLogDetails": true, + "prettifyLogMessage": true, + "showTime": false, + "wrapLogMessage": false + }, + "pluginVersion": "v11.0.0", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${loki_datasource}" + }, + "expr": "{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",level=~\"$level\"} \n|~ \"$regex_search\"\n\n\n" + } + ], + "title": "Logs", + "type": "logs" + } + ], + "refresh": "30s", + "schemaVersion": 39, + "tags": [ + "apache-tomcat-mixin" + ], + "templating": { + "list": [ + { + "label": "Loki data source", + "name": "loki_datasource", + "query": "loki", + "regex": "(?!grafanacloud.+usage-insights|grafanacloud.+alert-state-history).+", + "type": "datasource" + }, + { + "allValue": ".*", + "datasource": { + "type": "loki", + "uid": "${loki_datasource}" + }, + "includeAll": true, + "label": "Job", + "multi": true, + "name": "job", + "query": "label_values({job=\"integrations/tomcat\"}, job)", + "refresh": 2, + "sort": 1, + "type": "query" + }, + { + "allValue": ".*", + "datasource": { + "type": "loki", + "uid": "${loki_datasource}" + }, + "includeAll": true, + "label": "Cluster", + "multi": true, + "name": "cluster", + "query": "label_values({job=\"integrations/tomcat\",job=~\"$job\"}, cluster)", + "refresh": 2, + "sort": 1, + "type": "query" + }, + { + "allValue": ".*", + "datasource": { + "type": "loki", + "uid": "${loki_datasource}" + }, + "includeAll": true, + "label": "Level", + "multi": true, + "name": "level", + "query": "label_values({job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\"}, level)", + "refresh": 2, + "sort": 1, + "type": "query" + }, + { + "current": { + "selected": false, + "text": "", + "value": "" + }, + "label": "Regex search", + "name": "regex_search", + "options": [ + { + "selected": true, + "text": "", + "value": "" + } + ], + "query": "", + "type": "textbox" + }, + { + "hide": 2, + "label": "Prometheus data source", + "name": "prometheus_datasource", + "query": "prometheus", + "regex": "(?!grafanacloud-usage|grafanacloud-ml-metrics).+", + "type": "datasource" + } + ] + }, + "time": { + "from": "now-30m", + "to": "now" + }, + "timezone": "default", + "title": "Apache Tomcat logs", + "uid": "apachetomcat-logs" + } \ No newline at end of file diff --git a/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json b/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json index 59c472ca6..4ede776a5 100644 --- a/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json +++ b/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json @@ -1,120 +1,93 @@ { - "__inputs": [ ], - "__requires": [ ], "annotations": { "list": [ ] }, - "description": "", "editable": false, - "gnetId": null, - "graphTooltip": 0, - "hideControls": false, "id": null, "links": [ { - "asDropdown": false, - "icon": "external link", + "keepTime": true, + "title": "Apache Tomcat hosts", + "type": "link", + "url": "/d/apachetomcat_hosts" + }, + { + "keepTime": true, + "title": "Apache Tomcat logs", + "type": "link", + "url": "/d/apachetomcat-logs" + }, + { + "asDropdown": true, "includeVars": true, "keepTime": true, "tags": [ "apache-tomcat-mixin" ], - "targetBlank": false, - "title": "Other Apache Tomcat dashboards", - "type": "dashboards", - "url": "" + "title": "All dashboards", + "type": "dashboards" } ], "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 0, + "x": 0, + "y": 0 + }, + "id": 1, + "panels": [ ], + "title": "Overview", + "type": "row" + }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "description": "The memory usage of the JVM of the instance", + "description": "The memory usage of the JVM of the instance.", "fieldConfig": { "defaults": { - "color": { - "mode": "palette-classic" - }, "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineStyle": { - "fill": "solid" - }, - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [ ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "bytes" - }, - "overrides": [ ] + "fillOpacity": 30, + "gradientMode": "opacity", + "lineInterpolation": "smooth", + "lineWidth": 2, + "showPoints": "never" + } + } }, "gridPos": { - "h": 6, - "w": 12, + "h": 8, + "w": 8, "x": 0, - "y": 0 + "y": 1 }, "id": 2, "options": { "legend": { "calcs": [ ], - "displayMode": "list", - "placement": "bottom", - "showLegend": true + "displayMode": "list" }, "tooltip": { - "mode": "single", - "sort": "none" + "mode": "multi", + "sort": "desc" } }, + "pluginVersion": "v11.0.0", "targets": [ { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "jvm_memory_usage_used_bytes{job=~\"$job\", instance=~\"$instance\"}", + "expr": "jvm_memory_usage_used_bytes{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - {{area}}" + "instant": false, + "legendFormat": "{{ instance }} - {{area}}", + "refId": "Memory usage" } ], "title": "Memory usage", @@ -122,90 +95,50 @@ }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "description": "The CPU usage of the JVM process", + "description": "The CPU usage of the JVM process.", "fieldConfig": { "defaults": { - "color": { - "mode": "palette-classic" - }, "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "line" - } - }, - "mappings": [ ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "percentunit" - }, - "overrides": [ ] + "fillOpacity": 30, + "gradientMode": "opacity", + "lineInterpolation": "smooth", + "lineWidth": 2, + "showPoints": "never" + } + } }, "gridPos": { - "h": 6, - "w": 12, - "x": 12, - "y": 0 + "h": 8, + "w": 8, + "x": 8, + "y": 1 }, "id": 3, "options": { "legend": { "calcs": [ ], - "displayMode": "list", - "placement": "bottom", - "showLegend": true + "displayMode": "list" }, "tooltip": { - "mode": "single", - "sort": "none" + "mode": "multi", + "sort": "desc" } }, + "pluginVersion": "v11.0.0", "targets": [ { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "jvm_process_cpu_load{job=~\"$job\", instance=~\"$instance\"}", + "expr": "jvm_process_cpu_load{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}}" + "instant": false, + "legendFormat": "{{instance}}: CPU usage", + "refId": "CPU usage" } ], "title": "CPU usage", @@ -213,99 +146,61 @@ }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "description": "The sent traffic for a Tomcat connector", + "description": "The traffic sent for a Tomcat connector.", "fieldConfig": { "defaults": { - "color": { - "mode": "palette-classic" - }, "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [ ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "Bps" - }, - "overrides": [ ] + "fillOpacity": 30, + "gradientMode": "opacity", + "lineInterpolation": "smooth", + "lineWidth": 2, + "showPoints": "never" + } + } }, "gridPos": { - "h": 6, - "w": 12, - "x": 0, - "y": 6 + "h": 8, + "w": 8, + "x": 16, + "y": 1 }, "id": 4, "options": { "legend": { "calcs": [ ], - "displayMode": "list", - "placement": "bottom", - "showLegend": true + "displayMode": "list" }, "tooltip": { - "mode": "single", - "sort": "none" + "mode": "multi", + "sort": "desc" } }, + "pluginVersion": "v11.0.0", "targets": [ { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(rate(tomcat_bytessent_total{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])) by (job, instance)", + "expr": "sum(rate(tomcat_bytessent_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - total" + "instant": false, + "legendFormat": "{{ instance }} - total", + "refId": "Traffic sent total" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "rate(tomcat_bytessent_total{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])", + "expr": "rate(tomcat_bytessent_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - {{protocol}}-{{port}}" + "instant": false, + "legendFormat": "{{ instance }} - {{protocol}} - {{port}}", + "refId": "Traffic sent rate" } ], "title": "Traffic sent", @@ -313,99 +208,61 @@ }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "description": "The received traffic for a Tomcat connector", + "description": "The traffic received for a Tomcat connector.", "fieldConfig": { "defaults": { - "color": { - "mode": "palette-classic" - }, "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [ ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "Bps" - }, - "overrides": [ ] + "fillOpacity": 30, + "gradientMode": "opacity", + "lineInterpolation": "smooth", + "lineWidth": 2, + "showPoints": "never" + } + } }, "gridPos": { - "h": 6, - "w": 12, - "x": 12, - "y": 6 + "h": 8, + "w": 8, + "x": 0, + "y": 9 }, "id": 5, "options": { "legend": { "calcs": [ ], - "displayMode": "list", - "placement": "bottom", - "showLegend": true + "displayMode": "list" }, "tooltip": { - "mode": "single", - "sort": "none" + "mode": "multi", + "sort": "desc" } }, + "pluginVersion": "v11.0.0", "targets": [ { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(rate(tomcat_bytesreceived_total{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])) by (job, instance)", + "expr": "sum(rate(tomcat_bytesreceived_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - total" + "instant": false, + "legendFormat": "{{ instance }} - total", + "refId": "Traffic received total" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "rate(tomcat_bytesreceived_total{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])", + "expr": "rate(tomcat_bytesreceived_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - {{protocol}}-{{port}}" + "instant": false, + "legendFormat": "{{ instance }} - {{protocol}} - {{port}}", + "refId": "Traffic received rate" } ], "title": "Traffic received", @@ -413,117 +270,83 @@ }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "description": "The total requests and errors for a Tomcat connector", + "description": "The total requests and errors for a Tomcat connector.", "fieldConfig": { "defaults": { - "color": { - "mode": "palette-classic" - }, "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [ ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "r/s" - }, - "overrides": [ ] + "fillOpacity": 30, + "gradientMode": "opacity", + "lineInterpolation": "smooth", + "lineWidth": 2, + "showPoints": "never" + } + } }, "gridPos": { - "h": 6, - "w": 12, - "x": 0, - "y": 12 + "h": 8, + "w": 8, + "x": 8, + "y": 9 }, "id": 6, "options": { "legend": { "calcs": [ ], - "displayMode": "list", - "placement": "bottom", - "showLegend": true + "displayMode": "list" }, "tooltip": { - "mode": "single", - "sort": "none" + "mode": "multi", + "sort": "desc" } }, + "pluginVersion": "v11.0.0", "targets": [ { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(rate(tomcat_requestcount_total{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])) by (job, instance)", + "expr": "sum(rate(tomcat_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - total requests" + "instant": false, + "legendFormat": "{{ instance }} - total requests", + "refId": "Requests total" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(rate(tomcat_errorcount_total{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])) by (job, instance)", + "expr": "rate(tomcat_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - total errors" + "instant": false, + "legendFormat": "{{ instance }} - {{protocol}} - {{port}} - requests", + "refId": "Requests rate" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "rate(tomcat_requestcount_total{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])", + "expr": "sum(rate(tomcat_errorcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - {{protocol}}-{{port}} - requests" + "instant": false, + "legendFormat": "{{ instance }} - total errors", + "refId": "Requests errors" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "rate(tomcat_errorcount_total{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])", + "expr": "rate(tomcat_errorcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - {{protocol}}-{{port}} - errors" + "instant": false, + "legendFormat": "{{ instance }} - {{protocol}} - {{port}} - errors", + "refId": "Requests errors rate" } ], "title": "Requests", @@ -531,102 +354,51 @@ }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "description": "The average time taken to process recent requests for a Tomcat connector", + "description": "The average time taken to process recent requests for a Tomcat connector.", "fieldConfig": { "defaults": { - "color": { - "mode": "palette-classic" - }, "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "axisSoftMin": 0, - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "line" - } - }, - "mappings": [ ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 300 - } - ] + "fillOpacity": 30, + "gradientMode": "opacity", + "lineInterpolation": "smooth", + "lineWidth": 2, + "showPoints": "never" }, "unit": "ms" - }, - "overrides": [ ] + } }, "gridPos": { - "h": 6, - "w": 12, - "x": 12, - "y": 12 + "h": 8, + "w": 8, + "x": 16, + "y": 9 }, "id": 7, "options": { "legend": { "calcs": [ ], - "displayMode": "list", - "placement": "bottom", - "showLegend": true + "displayMode": "list" }, "tooltip": { - "mode": "single", - "sort": "none" + "mode": "multi", + "sort": "desc" } }, + "pluginVersion": "v11.0.0", "targets": [ { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(increase(tomcat_processingtime_total{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_requestcount_total{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__interval:] offset -$__interval), 1)) by (job, instance)", - "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{instance}} - total" - }, - { - "datasource": { - "uid": "${prometheus_datasource}" - }, - "expr": "increase(tomcat_processingtime_total{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_requestcount_total{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__interval:] offset -$__interval), 1)", + "expr": "sum(increase(tomcat_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval), 1)) by (job, instance)", "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{instance}} - {{protocol}}-{{port}}" + "instant": false, + "legendFormat": "{{ instance }} - total", + "refId": "Processing time total" } ], "title": "Processing time", @@ -634,368 +406,207 @@ }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "description": "The number of various threads being used by a Tomcat connector", + "description": "The number of various threads used by a Tomcat connector.", "fieldConfig": { "defaults": { - "color": { - "mode": "palette-classic" - }, "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [ ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] + "fillOpacity": 30, + "gradientMode": "opacity", + "lineInterpolation": "smooth", + "lineWidth": 2, + "showPoints": "never" } - }, - "overrides": [ ] + } }, "gridPos": { - "h": 6, - "w": 24, + "h": 8, + "w": 8, "x": 0, - "y": 18 + "y": 17 }, "id": 8, "options": { "legend": { "calcs": [ ], - "displayMode": "list", - "placement": "right", - "showLegend": true + "displayMode": "list" }, "tooltip": { - "mode": "single", - "sort": "none" + "mode": "multi", + "sort": "desc" } }, + "pluginVersion": "v11.0.0", "targets": [ { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(tomcat_threadpool_connectioncount{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}) by (job, instance)", + "expr": "sum(tomcat_threadpool_connectioncount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}) by (job, instance)", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - total connections" + "instant": false, + "legendFormat": "{{ instance }} - total connections", + "refId": "Total connection threads" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(tomcat_threadpool_pollerthreadcount{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}) by (job, instance)", + "expr": "sum(tomcat_threadpool_pollerthreadcount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}) by (job, instance)", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - poller total" + "instant": false, + "legendFormat": "{{ instance }} - poller total", + "refId": "Total poller threads" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(tomcat_threadpool_keepalivecount{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}) by (job, instance)", + "expr": "sum(tomcat_threadpool_keepalivecount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}) by (job, instance)", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - idle total" + "instant": false, + "legendFormat": "{{ instance }} - idle total", + "refId": "Total idle threads" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(tomcat_threadpool_currentthreadcount{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}) by (job, instance)", + "expr": "sum(tomcat_threadpool_currentthreadcount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}) by (job, instance)", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - active total" + "instant": false, + "legendFormat": "{{ instance }} - active total", + "refId": "Total active threads" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "tomcat_threadpool_connectioncount{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}", + "expr": "tomcat_threadpool_connectioncount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - {{protocol}}-{{port}} - connections" + "instant": false, + "legendFormat": "{{ instance }} - {{protocol}} - {{port}} - connections", + "refId": "Connection threads" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "tomcat_threadpool_pollerthreadcount{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}", + "expr": "tomcat_threadpool_pollerthreadcount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - {{protocol}}-{{port}} - poller" + "instant": false, + "legendFormat": "{{ instance }} - {{protocol}} - {{port}} - poller", + "refId": "Poller threads" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "tomcat_threadpool_keepalivecount{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}", + "expr": "tomcat_threadpool_keepalivecount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - {{protocol}}-{{port}} - idle" + "instant": false, + "legendFormat": "{{ instance }} - {{protocol}} - {{port}} - idle", + "refId": "Idle threads" }, { "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "tomcat_threadpool_currentthreadcount{job=~\"$job\", instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}", + "expr": "tomcat_threadpool_currentthreadcount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{instance}} - {{protocol}}-{{port}} - active" + "instant": false, + "legendFormat": "{{ instance }} - {{protocol}} - {{port}} - active", + "refId": "Active threads" } ], "title": "Threads", "type": "timeseries" - }, - { - "datasource": { - "uid": "${loki_datasource}" - }, - "description": "Recent logs from the Catalina.out logs file\n", - "gridPos": { - "h": 6, - "w": 24, - "x": 0, - "y": 24 - }, - "id": 9, - "options": { - "dedupStrategy": "none", - "enableLogDetails": true, - "prettifyLogMessage": false, - "showCommonLabels": false, - "showLabels": false, - "showTime": false, - "sortOrder": "Descending", - "wrapLogMessage": false - }, - "targets": [ - { - "datasource": { - "uid": "${loki_datasource}" - }, - "editorMode": "code", - "expr": "{job=~\"$job\", instance=~\"$instance\"} |= `` | (filename=~\"/var/log/tomcat.*/catalina.out|/opt/tomcat/logs/catalina.out|/Program Files/Apache Software Foundation/Tomcat .*..*/logs/catalina.out\" or log_type=\"catalina.out\")", - "queryType": "range", - "refId": "A" - } - ], - "title": "Logs", - "type": "logs" } ], - "refresh": "1m", - "rows": [ ], - "schemaVersion": 14, - "style": "dark", + "refresh": "30s", + "schemaVersion": 39, "tags": [ "apache-tomcat-mixin" ], "templating": { "list": [ { - "current": { }, - "hide": 0, - "label": "Data Source", + "label": "Prometheus data source", "name": "prometheus_datasource", - "options": [ ], "query": "prometheus", - "refresh": 1, - "regex": "", - "type": "datasource" - }, - { - "current": { }, - "hide": 0, - "label": "Loki Datasource", - "name": "loki_datasource", - "options": [ ], - "query": "loki", - "refresh": 1, - "regex": "", + "regex": "(?!grafanacloud-usage|grafanacloud-ml-metrics).+", "type": "datasource" }, { - "allValue": "", - "current": { }, + "allValue": ".+", "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "hide": 0, - "includeAll": false, + "includeAll": true, "label": "Job", - "multi": false, + "multi": true, "name": "job", - "options": [ ], - "query": "label_values(tomcat_bytesreceived_total, job)", - "refresh": 1, - "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [ ], - "tagsQuery": "", - "type": "query", - "useTags": false + "query": "label_values(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\"}, job)", + "refresh": 2, + "sort": 1, + "type": "query" }, { "allValue": ".*", - "current": { }, "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "hide": 2, "includeAll": true, "label": "Cluster", "multi": true, "name": "cluster", - "options": [ ], - "query": "label_values(tomcat_bytesreceived_total{job=~\"$job\"}, cluster)", + "query": "label_values(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\"}, cluster)", "refresh": 2, - "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [ ], - "tagsQuery": "", - "type": "query", - "useTags": false + "sort": 1, + "type": "query" }, { "allValue": ".+", - "current": { }, "datasource": { + "type": "prometheus", "uid": "${prometheus_datasource}" }, - "hide": 0, "includeAll": true, "label": "Instance", "multi": true, "name": "instance", - "options": [ ], - "query": "label_values(tomcat_bytesreceived_total{job=~\"$job\"}, instance)", + "query": "label_values(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\"}, instance)", "refresh": 2, - "regex": "", "sort": 1, - "tagValuesQuery": "", - "tags": [ ], - "tagsQuery": "", - "type": "query", - "useTags": false + "type": "query" }, { - "allValue": ".+", - "current": { }, - "datasource": { - "uid": "${prometheus_datasource}" - }, - "hide": 0, - "includeAll": true, - "label": "Protocol", - "multi": true, - "name": "protocol", - "options": [ ], - "query": "label_values(tomcat_bytesreceived_total{job=~\"$job\"}, protocol)", - "refresh": 1, - "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [ ], - "tagsQuery": "", - "type": "query", - "useTags": false - }, - { - "allValue": ".+", - "current": { }, - "datasource": { - "uid": "${prometheus_datasource}" - }, - "hide": 0, - "includeAll": true, - "label": "Port", - "multi": true, - "name": "port", - "options": [ ], - "query": "label_values(tomcat_bytesreceived_total{job=~\"$job\"}, port)", - "refresh": 1, - "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [ ], - "tagsQuery": "", - "type": "query", - "useTags": false + "hide": 2, + "label": "Loki data source", + "name": "loki_datasource", + "query": "loki", + "regex": "(?!grafanacloud.+usage-insights|grafanacloud.+alert-state-history).+", + "type": "datasource" } ] }, "time": { - "from": "now-1h", + "from": "now-30m", "to": "now" }, - "timepicker": { - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] - }, "timezone": "default", "title": "Apache Tomcat overview", - "uid": "apache-tomcat-overview", - "version": 0 + "uid": "apachetomcat_overview" } \ No newline at end of file diff --git a/apache-tomcat-mixin/g.libsonnet b/apache-tomcat-mixin/g.libsonnet new file mode 100644 index 000000000..e6a2060ee --- /dev/null +++ b/apache-tomcat-mixin/g.libsonnet @@ -0,0 +1 @@ +import 'github.com/grafana/grafonnet/gen/grafonnet-v11.4.0/main.libsonnet' diff --git a/apache-tomcat-mixin/jsonnetfile.json b/apache-tomcat-mixin/jsonnetfile.json index 65cebf84b..a5c199b4f 100644 --- a/apache-tomcat-mixin/jsonnetfile.json +++ b/apache-tomcat-mixin/jsonnetfile.json @@ -9,6 +9,33 @@ } }, "version": "master" + }, + { + "source": { + "git": { + "remote": "https://github.com/grafana/jsonnet-libs.git", + "subdir": "common-lib" + } + }, + "version": "master" + }, + { + "source": { + "git": { + "remote": "https://github.com/grafana/jsonnet-libs.git", + "subdir": "grafana-cloud-integration-utils" + } + }, + "version": "master" + }, + { + "source": { + "git": { + "remote": "https://github.com/grafana/jsonnet-libs.git", + "subdir": "logs-lib" + } + }, + "version": "master" } ], "legacyImports": true diff --git a/apache-tomcat-mixin/links.libsonnet b/apache-tomcat-mixin/links.libsonnet new file mode 100644 index 000000000..fda9229b4 --- /dev/null +++ b/apache-tomcat-mixin/links.libsonnet @@ -0,0 +1,24 @@ +local g = import './g.libsonnet'; + +{ + local link = g.dashboard.link, + + new(this): + { + apacheTomcatOverview: link.link.new(this.config.dashboardNamePrefix + ' overview', '/d/' + this.grafana.dashboards['apache-tomcat-overview.json'].uid) + + link.link.options.withKeepTime(true), + + apacheTomcatHosts: link.link.new(this.config.dashboardNamePrefix + ' hosts', '/d/' + this.grafana.dashboards['apache-tomcat-hosts.json'].uid) + + link.link.options.withKeepTime(true), + + otherDashboards: link.dashboards.new('All dashboards', this.config.dashboardTags) + + link.dashboards.options.withIncludeVars(true) + + link.dashboards.options.withKeepTime(true) + + link.dashboards.options.withAsDropdown(true), + + + } + if this.config.enableLokiLogs then { + apacheTomcatLogs: link.link.new(this.config.dashboardNamePrefix + ' logs', '/d/' + this.grafana.dashboards['apache-tomcat-logs.json'].uid) + + link.link.options.withKeepTime(true), + }, +} diff --git a/apache-tomcat-mixin/main.libsonnet b/apache-tomcat-mixin/main.libsonnet new file mode 100644 index 000000000..83dcab972 --- /dev/null +++ b/apache-tomcat-mixin/main.libsonnet @@ -0,0 +1,48 @@ +local alerts = import './alerts.libsonnet'; +local config = import './config.libsonnet'; +local dashboards = import './dashboards.libsonnet'; +local links = import './links.libsonnet'; +local panels = import './panels.libsonnet'; +local rows = import './rows.libsonnet'; +local commonlib = import 'common-lib/common/main.libsonnet'; + +{ + withConfigMixin(config): { + config+: config, + }, + + new(): { + local this = self, + config: config, + signals: + { + [sig]: commonlib.signals.unmarshallJsonMulti( + this.config.signals[sig], + type=this.config.metricsSource + ) + for sig in std.objectFields(this.config.signals) + }, + + + grafana: { + variables: commonlib.variables.new( + filteringSelector=this.config.filteringSelector, + groupLabels=this.config.groupLabels, + instanceLabels=this.config.instanceLabels, + varMetric='tomcat_session_sessioncounter_total', + customAllValue='.+', + enableLokiLogs=this.config.enableLokiLogs, + ), + annotations: {}, + links: links.new(this), + panels: panels.new(this), + dashboards: dashboards.new(this), + rows: rows.new(this), + }, + + prometheus: { + alerts: alerts.new(this), + recordingRules: {}, + }, + }, +} diff --git a/apache-tomcat-mixin/mixin.libsonnet b/apache-tomcat-mixin/mixin.libsonnet index 4d987cf31..6a906870c 100644 --- a/apache-tomcat-mixin/mixin.libsonnet +++ b/apache-tomcat-mixin/mixin.libsonnet @@ -1,3 +1,30 @@ -(import 'dashboards/dashboards.libsonnet') + -(import 'alerts/alerts.libsonnet') + -(import 'config.libsonnet') +local tomcatLib = import './main.libsonnet'; +local config = (import './config.libsonnet'); +local util = import 'grafana-cloud-integration-utils/util.libsonnet'; + +local mixin = + tomcatLib.new() + + tomcatLib.withConfigMixin({ + filteringSelector: config.filteringSelector, + uid: config.uid, + enableLokiLogs: config.enableLokiLogs, + }); + +local k8s_patch = { + cluster+: { + allValue: '.*', + }, +}; + +{ + grafanaDashboards+:: { + local tags = config.dashboardTags, + [fname]: + local dashboard = util.decorate_dashboard(mixin.grafana.dashboards[fname], tags=tags); + dashboard + util.patch_variables(dashboard, k8s_patch) + + for fname in std.objectFields(mixin.grafana.dashboards) + }, + prometheusAlerts+:: mixin.prometheus.alerts, + prometheusRules+:: mixin.prometheus.recordingRules, +} diff --git a/apache-tomcat-mixin/panels.libsonnet b/apache-tomcat-mixin/panels.libsonnet new file mode 100644 index 000000000..d0a88e56a --- /dev/null +++ b/apache-tomcat-mixin/panels.libsonnet @@ -0,0 +1,131 @@ +local g = import './g.libsonnet'; +local commonlib = import 'common-lib/common/main.libsonnet'; + +{ + new(this):: + { + local signals = this.signals, + + // Overview Panels + + overviewMemoryUsagePanel: + commonlib.panels.generic.timeSeries.base.new( + 'Memory usage', + targets=[signals.overview.memoryUsage.asTarget()] + ) + + g.panel.timeSeries.panelOptions.withDescription('The memory usage of the JVM of the instance.'), + + overviewCPUUsagePanel: + commonlib.panels.generic.timeSeries.base.new( + 'CPU usage', + targets=[signals.overview.cpuUsage.asTarget()] + ) + + g.panel.timeSeries.panelOptions.withDescription('The CPU usage of the JVM process.'), + + overviewTrafficSentPanel: + commonlib.panels.generic.timeSeries.base.new( + 'Traffic sent', + targets=[signals.overview.trafficSentTotal.asTarget(), signals.overview.trafficSentRate.asTarget()] + ) + + g.panel.timeSeries.panelOptions.withDescription('The traffic sent for a Tomcat connector.'), + + overviewTrafficReceivedPanel: + commonlib.panels.generic.timeSeries.base.new( + 'Traffic received', + targets=[signals.overview.trafficReceivedTotal.asTarget(), signals.overview.trafficReceivedRate.asTarget()] + ) + + g.panel.timeSeries.panelOptions.withDescription('The traffic received for a Tomcat connector.'), + + overviewRequestsPanel: + commonlib.panels.generic.timeSeries.base.new( + 'Requests', + targets=[signals.overview.requestsTotal.asTarget(), signals.overview.requestsRate.asTarget(), signals.overview.requestsErrors.asTarget(), signals.overview.requestsErrorsRate.asTarget()] + ) + + g.panel.timeSeries.panelOptions.withDescription('The total requests and errors for a Tomcat connector.'), + + overviewProcessingTimePanel: + commonlib.panels.generic.timeSeries.base.new( + 'Processing time', + targets=[signals.overview.processingTimeTotal.asTarget()] + ) + + g.panel.timeSeries.panelOptions.withDescription('The average time taken to process recent requests for a Tomcat connector.') + + g.panel.timeSeries.standardOptions.withUnit('ms'), + + + overviewThreadsPanel: + commonlib.panels.generic.timeSeries.base.new( + 'Threads', + targets=[ + signals.overview.totalConnectionThreads.asTarget(), + signals.overview.totalPollerThreads.asTarget(), + signals.overview.totalIdleThreads.asTarget(), + signals.overview.totalActiveThreads.asTarget(), + signals.overview.connectionThreads.asTarget(), + signals.overview.pollerThreads.asTarget(), + signals.overview.idleThreads.asTarget(), + signals.overview.activeThreads.asTarget(), + ] + ) + + g.panel.timeSeries.panelOptions.withDescription('The number of various threads used by a Tomcat connector.'), + + // Hosts Panels + + hostsSessionsPanel: + commonlib.panels.generic.timeSeries.base.new( + 'Sessions', + targets=[ + signals.hosts.totalSessions.asTarget(), + signals.hosts.rejectedSessions.asTarget(), + signals.hosts.expiredSessions.asTarget(), + signals.hosts.sessionRate.asTarget(), + signals.hosts.rejectedSessionRate.asTarget(), + signals.hosts.expiredSessionRate.asTarget(), + ] + ) + + g.panel.timeSeries.panelOptions.withDescription('The number of different types of sessions created for a Tomcat host.') + + g.panel.timeSeries.options.legend.withAsTable(true) + + g.panel.timeSeries.options.legend.withPlacement('right'), + + hostsSessionProcessingTimePanel: + commonlib.panels.generic.timeSeries.base.new( + 'Session processing time', + targets=[ + signals.hosts.totalSessionProcessingTime.asTarget(), + signals.hosts.sessionProcessingTime.asTarget(), + ] + ) + + g.panel.timeSeries.panelOptions.withDescription('The average time taken to process recent sessions for a Tomcat host.') + + g.panel.timeSeries.standardOptions.withUnit('ms') + + g.panel.timeSeries.options.legend.withAsTable(true) + + g.panel.timeSeries.options.legend.withPlacement('right'), + + hostsServletPanel: + commonlib.panels.generic.timeSeries.base.new( + 'Servlet', + targets=[ + signals.hosts.totalServletRequests.asTarget(), + signals.hosts.totalServletErrors.asTarget(), + signals.hosts.servletRequestRate.asTarget(), + signals.hosts.servletErrorRate.asTarget(), + ] + ) + + g.panel.timeSeries.panelOptions.withDescription('The total requests and errors for a Tomcat servlet.') + + g.panel.timeSeries.standardOptions.withUnit('reqps') + + g.panel.timeSeries.options.legend.withAsTable(true) + + g.panel.timeSeries.options.legend.withPlacement('right'), + + hostsServletProcessingTimePanel: + commonlib.panels.generic.timeSeries.base.new( + 'Servlet processing time', + targets=[ + signals.hosts.totalServletProcessingTime.asTarget(), + signals.hosts.servletProcessingTime.asTarget(), + ] + ) + + g.panel.timeSeries.panelOptions.withDescription('The average time taken to process recent servlet requests for a Tomcat host.') + + g.panel.timeSeries.standardOptions.withUnit('ms') + + g.panel.timeSeries.options.legend.withAsTable(true) + + g.panel.timeSeries.options.legend.withPlacement('right'), + + }, +} diff --git a/apache-tomcat-mixin/prometheus_rules_out/prometheus_alerts.yaml b/apache-tomcat-mixin/prometheus_rules_out/prometheus_alerts.yaml index a42d882c8..c9baf70f5 100644 --- a/apache-tomcat-mixin/prometheus_rules_out/prometheus_alerts.yaml +++ b/apache-tomcat-mixin/prometheus_rules_out/prometheus_alerts.yaml @@ -6,7 +6,7 @@ groups: description: The CPU usage has been at {{ printf "%.0f" $value }} percent over the last 5 minutes on {{$labels.instance}}, which is above the threshold of 80 percent. summary: The instance has a CPU usage higher than the configured threshold. expr: | - sum by (job,instance) (jvm_process_cpu_load{job="integrations/tomcat"}) > 80 + sum by (job,cluster,instance) (jvm_process_cpu_load{job="integrations/tomcat"}) > 80 for: 5m labels: severity: critical @@ -15,25 +15,25 @@ groups: description: The memory usage has been at {{ printf "%.0f" $value }} percent over the last 5 minutes on {{$labels.instance}}, which is above the threshold of 80 percent. summary: The instance has a higher memory usage than the configured threshold. expr: | - sum(jvm_memory_usage_used_bytes{job="integrations/tomcat"}) by (job,instance) / sum(jvm_physical_memory_bytes{job="integrations/tomcat"}) by (job,instance) * 100 > 80 + sum(jvm_memory_usage_used_bytes{job="integrations/tomcat"}) by (job,cluster,instance) / sum(jvm_physical_memory_bytes{job="integrations/tomcat"}) by (job,cluster,instance) * 100 > 80 for: 5m labels: severity: critical - - alert: ApacheTomcatAlertsHighRequestErrorPercent + - alert: ApacheTomcatAlertsRequestErrors annotations: description: The percentage of request errors has been at {{ printf "%.0f" $value }} percent over the last 5 minutes on {{$labels.instance}}, which is above the threshold of 5 percent. summary: There are a high number of request errors. expr: | - sum by (job,instance) (increase(tomcat_errorcount_total{job="integrations/tomcat"}[5m]) / increase(tomcat_requestcount_total{job="integrations/tomcat"}[5m]) * 100) > 5 + sum by (job,cluster,instance) (increase(tomcat_errorcount_total{job="integrations/tomcat"}[5m]) / increase(tomcat_requestcount_total{job="integrations/tomcat"}[5m]) * 100) > 5 for: 5m labels: severity: critical - - alert: ApacheTomcatAlertsModeratelyHighProcessingTime + - alert: ApacheTomcatAlertsHighProcessingTime annotations: description: The processing time has been at {{ printf "%.0f" $value }}ms over the last 5 minutes on {{$labels.instance}}, which is above the threshold of 300ms. summary: The processing time has been moderately high. expr: | - sum by (job,instance) (increase(tomcat_processingtime_total{job="integrations/tomcat"}[5m]) / increase(tomcat_requestcount_total{job="integrations/tomcat"}[5m])) > 300 + sum by (job,cluster,instance) (increase(tomcat_processingtime_total{job="integrations/tomcat"}[5m]) / increase(tomcat_requestcount_total{job="integrations/tomcat"}[5m])) > 300 for: 5m labels: severity: warning diff --git a/apache-tomcat-mixin/rows.libsonnet b/apache-tomcat-mixin/rows.libsonnet new file mode 100644 index 000000000..1a325a714 --- /dev/null +++ b/apache-tomcat-mixin/rows.libsonnet @@ -0,0 +1,32 @@ +local g = import './g.libsonnet'; + + +{ + new(this): + { + local panels = this.grafana.panels, + + // overview rows + overview: g.panel.row.new('Overview') + + g.panel.row.withCollapsed(value=false) + + g.panel.row.withPanels([ + panels.overviewMemoryUsagePanel, + panels.overviewCPUUsagePanel, + panels.overviewTrafficSentPanel, + panels.overviewTrafficReceivedPanel, + panels.overviewRequestsPanel, + panels.overviewProcessingTimePanel, + panels.overviewThreadsPanel, + ]), + + // hosts rows + hosts: g.panel.row.new('Hosts') + + g.panel.row.withCollapsed(value=false) + + g.panel.row.withPanels([ + panels.hostsSessionsPanel, + panels.hostsSessionProcessingTimePanel, + panels.hostsServletPanel, + panels.hostsServletProcessingTimePanel, + ]), + }, +} diff --git a/apache-tomcat-mixin/signals/hosts.libsonnet b/apache-tomcat-mixin/signals/hosts.libsonnet new file mode 100644 index 000000000..5446dcd64 --- /dev/null +++ b/apache-tomcat-mixin/signals/hosts.libsonnet @@ -0,0 +1,214 @@ +function(this) { + local legendCustomTemplate = '{{ instance }}', + filteringSelector: this.filteringSelector, + groupLabels: this.groupLabels, + instanceLabels: this.instanceLabels, + enableLokiLogs: this.enableLokiLogs, + aggLevel: 'none', + aggFunction: 'sum', + alertsInterval: '2m', + discoveryMetric: { + prometheus: 'tomcat_session_sessioncounter_total', + }, + signals: { + totalSessions: { + name: 'Total sessions', + nameShort: 'Total sessions', + type: 'raw', + description: 'The total number of sessions.', + unit: 'none', + sources: { + prometheus: { + expr: 'sum(increase(tomcat_session_sessioncounter_total{%(queriesSelector)s}[$__interval:] offset -$__interval)) by (job, instance)', + legendCustomTemplate: legendCustomTemplate + ' - total sessions', + }, + }, + }, + + rejectedSessions: { + name: 'Rejected sessions', + nameShort: 'Rejected sessions', + type: 'raw', + description: 'The number of rejected sessions.', + unit: 'none', + sources: { + prometheus: { + expr: 'sum(increase(tomcat_session_rejectedsessions_total{%(queriesSelector)s}[$__interval:] offset -$__interval)) by (job, instance)', + legendCustomTemplate: legendCustomTemplate + ' - rejected sessions', + }, + }, + }, + + expiredSessions: { + name: 'Expired sessions', + nameShort: 'Expired sessions', + type: 'raw', + description: 'The number of expired sessions.', + unit: 'none', + sources: { + prometheus: { + expr: 'sum(increase(tomcat_session_expiredsessions_total{%(queriesSelector)s}[$__interval:] offset -$__interval)) by (job, instance)', + legendCustomTemplate: legendCustomTemplate + ' - expired sessions', + }, + }, + }, + + sessionRate: { + name: 'Session rate', + nameShort: 'Session rate', + type: 'counter', + description: 'The rate of sessions.', + unit: 'none', + sources: { + prometheus: { + expr: 'tomcat_session_sessioncounter_total{%(queriesSelector)s}', + rangeFunction: 'increase', + legendCustomTemplate: legendCustomTemplate + ' - {{host}}{{context}} - sessions', + }, + }, + }, + + rejectedSessionRate: { + name: 'Rejected rate', + nameShort: 'Rejected rate', + type: 'counter', + description: 'The rate of rejected sessions.', + unit: 'none', + sources: { + prometheus: { + expr: 'tomcat_session_rejectedsessions_total{%(queriesSelector)s}', + rangeFunction: 'increase', + legendCustomTemplate: legendCustomTemplate + ' - {{host}}{{context}} - rejected', + }, + }, + }, + + expiredSessionRate: { + name: 'Expired rate', + nameShort: 'Expired rate', + type: 'counter', + description: 'The rate of expired sessions.', + unit: 'none', + sources: { + prometheus: { + expr: 'tomcat_session_expiredsessions_total{%(queriesSelector)s}', + rangeFunction: 'increase', + legendCustomTemplate: legendCustomTemplate + ' - {{host}}{{context}} - expired', + }, + }, + }, + + totalSessionProcessingTime: { + name: 'Total session processing time', + nameShort: 'Total session processing time', + type: 'raw', + description: 'The total time spent processing sessions.', + unit: 'ms', + sources: { + prometheus: { + expr: 'sum(increase(tomcat_session_processingtime_total{%(queriesSelector)s}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{%(queriesSelector)s}[$__interval:] offset -$__interval), 1)) by (job, instance)', + legendCustomTemplate: legendCustomTemplate + ' - total', + }, + }, + }, + + sessionProcessingTime: { + name: 'Session processing time', + nameShort: 'Session processing time', + type: 'raw', + description: 'The time spent processing sessions.', + unit: 'ms', + sources: { + prometheus: { + expr: 'increase(tomcat_session_processingtime_total{%(queriesSelector)s}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{%(queriesSelector)s}[$__interval:] offset -$__interval), 1)', + legendCustomTemplate: legendCustomTemplate + ' - {{host}}{{context}}', + }, + }, + }, + + totalServletRequests: { + name: 'Total servlet requests', + nameShort: 'Total servlet requests', + type: 'raw', + description: 'The total number of servlet requests.', + unit: 'r/s', + sources: { + prometheus: { + expr: 'sum(rate(tomcat_servlet_requestcount_total{%(queriesSelector)s}[$__rate_interval])) by (job, instance)', + legendCustomTemplate: legendCustomTemplate + ' - total requests', + }, + }, + }, + + + totalServletErrors: { + name: 'Total servlet errors', + nameShort: 'Total servlet errors', + type: 'raw', + description: 'The total number of servlet errors.', + unit: 'r/s', + sources: { + prometheus: { + expr: 'sum(rate(tomcat_servlet_errorcount_total{%(queriesSelector)s}[$__rate_interval])) by (job, instance)', + legendCustomTemplate: legendCustomTemplate + ' - total errors', + }, + }, + }, + + servletRequestRate: { + name: 'Servlet request rate', + nameShort: 'Servlet request rate', + type: 'counter', + description: 'The rate of servlet requests.', + unit: 'r/s', + sources: { + prometheus: { + expr: 'tomcat_servlet_requestcount_total{%(queriesSelector)s}', + legendCustomTemplate: legendCustomTemplate + ' - {{host}}{{servlet}} - requests', + }, + }, + }, + + servletErrorRate: { + name: 'Servlet error rate', + nameShort: 'Servlet error rate', + type: 'counter', + description: 'The rate of servlet errors.', + unit: 'r/s', + sources: { + prometheus: { + expr: 'tomcat_servlet_errorcount_total{%(queriesSelector)s}', + legendCustomTemplate: legendCustomTemplate + ' - {{host}}{{context}} - errors', + }, + }, + }, + + totalServletProcessingTime: { + name: 'Total servlet processing time', + nameShort: 'Total servlet processing time', + type: 'raw', + description: 'The total time spent processing servlet requests.', + unit: 'ms', + sources: { + prometheus: { + expr: 'sum(increase(tomcat_servlet_processingtime_total{%(queriesSelector)s}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{%(queriesSelector)s}[$__interval:] offset -$__interval), 1)) by (job, instance)', + legendCustomTemplate: legendCustomTemplate + ' - total', + }, + }, + }, + + servletProcessingTime: { + name: 'Servlet processing time', + nameShort: 'Servlet processing time', + type: 'raw', + description: 'The time spent processing servlet requests.', + unit: 'ms', + sources: { + prometheus: { + expr: 'increase(tomcat_servlet_processingtime_total{%(queriesSelector)s}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{%(queriesSelector)s}[$__interval:] offset -$__interval), 1)', + legendCustomTemplate: legendCustomTemplate + ' - {{host}}{{servlet}}', + }, + }, + }, + }, +} diff --git a/apache-tomcat-mixin/signals/overview.libsonnet b/apache-tomcat-mixin/signals/overview.libsonnet new file mode 100644 index 000000000..762d6e651 --- /dev/null +++ b/apache-tomcat-mixin/signals/overview.libsonnet @@ -0,0 +1,294 @@ +function(this) { + local legendCustomTemplate = '{{ instance }}', + filteringSelector: this.filteringSelector, + groupLabels: this.groupLabels, + instanceLabels: this.instanceLabels, + enableLokiLogs: this.enableLokiLogs, + aggLevel: 'none', + aggFunction: 'avg', + discoveryMetric: { + prometheus: 'tomcat_session_sessioncounter_total', + }, + + signals: { + memoryUsage: { + name: 'Memory usage', + nameShort: 'Memory usage', + type: 'gauge', + description: 'The memory usage of the JVM of the instance.', + unit: 'bytes', + sources: { + prometheus: { + expr: 'jvm_memory_usage_used_bytes{%(queriesSelector)s}', + legendCustomTemplate: legendCustomTemplate + ' - {{area}}', + }, + }, + }, + + cpuUsage: { + name: 'CPU usage', + nameShort: 'CPU usage', + type: 'gauge', + description: 'The CPU usage of the JVM of the instance.', + unit: 'percent', + sources: { + prometheus: { + expr: 'jvm_process_cpu_load{%(queriesSelector)s}', + }, + }, + }, + + trafficSentTotal: { + name: 'Traffic sent total', + nameShort: 'Traffic sent total', + type: 'raw', + description: 'The total traffic sent by the instance.', + unit: 'Bps', + sources: { + prometheus: { + expr: 'sum(rate(tomcat_bytessent_total{%(queriesSelector)s}[$__rate_interval])) by (job, instance)', + legendCustomTemplate: legendCustomTemplate + ' - total', + }, + }, + }, + + trafficSentRate: { + name: 'Traffic sent rate', + nameShort: 'Traffic sent rate', + type: 'counter', + description: 'The rate of traffic sent by the instance.', + unit: 'Bps', + sources: { + prometheus: { + expr: 'tomcat_bytessent_total{%(queriesSelector)s}', + legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}}', + }, + }, + }, + + trafficReceivedTotal: { + name: 'Traffic received total', + nameShort: 'Traffic received total', + type: 'raw', + description: 'The total traffic received by the instance.', + unit: 'Bps', + sources: { + prometheus: { + expr: 'sum(rate(tomcat_bytesreceived_total{%(queriesSelector)s}[$__rate_interval])) by (job, instance)', + legendCustomTemplate: legendCustomTemplate + ' - total', + }, + }, + }, + + trafficReceivedRate: { + name: 'Traffic received rate', + nameShort: 'Traffic received rate', + type: 'counter', + description: 'The rate of traffic received by the instance.', + unit: 'Bps', + sources: { + prometheus: { + expr: 'tomcat_bytesreceived_total{%(queriesSelector)s}', + legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}}', + }, + }, + }, + + + requestsTotal: { + name: 'Requests total', + nameShort: 'Requests total', + type: 'raw', + description: 'The total number of requests by the instance.', + unit: 'r/s', + sources: { + prometheus: { + expr: 'sum(rate(tomcat_requestcount_total{%(queriesSelector)s}[$__rate_interval])) by (job, instance)', + legendCustomTemplate: legendCustomTemplate + ' - total requests', + }, + }, + }, + + requestsErrors: { + name: 'Requests errors', + nameShort: 'Requests errors', + type: 'raw', + description: 'The total number of requests errors by the instance.', + unit: 'r/s', + sources: { + prometheus: { + expr: 'sum(rate(tomcat_errorcount_total{%(queriesSelector)s}[$__rate_interval])) by (job, instance)', + legendCustomTemplate: legendCustomTemplate + ' - total errors', + }, + }, + }, + + requestsRate: { + name: 'Requests rate', + nameShort: 'Requests rate', + type: 'counter', + description: 'The rate of requests by the instance.', + unit: 'r/s', + sources: { + prometheus: { + expr: 'tomcat_requestcount_total{%(queriesSelector)s}', + legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}} - requests', + }, + }, + }, + + requestsErrorsRate: { + name: 'Requests errors rate', + nameShort: 'Requests errors rate', + type: 'counter', + description: 'The rate of requests errors by the instance.', + unit: 'r/s', + sources: { + prometheus: { + expr: 'tomcat_errorcount_total{%(queriesSelector)s}', + legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}} - errors', + }, + }, + }, + + processingTimeTotal: { + name: 'Processing time total', + nameShort: 'Processing time total', + type: 'raw', + description: 'The total processing time by the tomcat connector.', + unit: 'ms', + sources: { + prometheus: { + expr: 'sum(increase(tomcat_processingtime_total{%(queriesSelector)s}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_requestcount_total{%(queriesSelector)s}[$__interval:] offset -$__interval), 1)) by (job, instance)', + legendCustomTemplate: legendCustomTemplate + ' - total', + }, + }, + }, + + processingTimeRate: { + name: 'Processing time rate', + nameShort: 'Processing time rate', + type: 'raw', + description: 'The rate of processing time by the instance.', + unit: 'ms', + sources: { + prometheus: { + expr: 'increase(tomcat_processingtime_total{%(queriesSelector)s}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_requestcount_total{%(queriesSelector)s}[$__interval:] offset -$__interval), 1)', + legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}}', + }, + }, + }, + + totalConnectionThreads: { + name: 'Total connection threads', + nameShort: 'Total connection threads', + type: 'raw', + description: 'The total number of connection threads by the tomcat connector.', + unit: 'short', + sources: { + prometheus: { + expr: 'sum(tomcat_threadpool_connectioncount{%(queriesSelector)s}) by (job, instance)', + legendCustomTemplate: legendCustomTemplate + ' - total connections', + }, + }, + }, + + totalPollerThreads: { + name: 'Total poller threads', + nameShort: 'Total poller threads', + type: 'raw', + description: 'The total number of poller threads by the tomcat connector.', + unit: 'short', + sources: { + prometheus: { + expr: 'sum(tomcat_threadpool_pollerthreadcount{%(queriesSelector)s}) by (job, instance)', + legendCustomTemplate: legendCustomTemplate + ' - poller total', + }, + }, + }, + + totalIdleThreads: { + name: 'Total idle threads', + nameShort: 'Total idle threads', + type: 'raw', + description: 'The total number of idle threads by the tomcat connector.', + unit: 'short', + sources: { + prometheus: { + expr: 'sum(tomcat_threadpool_keepalivecount{%(queriesSelector)s}) by (job, instance)', + legendCustomTemplate: legendCustomTemplate + ' - idle total', + }, + }, + }, + + totalActiveThreads: { + name: 'Total active threads', + nameShort: 'Total active threads', + type: 'raw', + description: 'The total number of active threads by the tomcat connector.', + unit: 'short', + sources: { + prometheus: { + expr: 'sum(tomcat_threadpool_currentthreadcount{%(queriesSelector)s}) by (job, instance)', + legendCustomTemplate: legendCustomTemplate + ' - active total', + }, + }, + }, + + connectionThreads: { + name: 'Connection threads', + nameShort: 'Connection threads', + type: 'gauge', + description: 'The number of connection threads by the tomcat connector.', + unit: 'short', + sources: { + prometheus: { + expr: 'tomcat_threadpool_connectioncount{%(queriesSelector)s}', + legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}} - connections', + }, + }, + }, + + pollerThreads: { + name: 'Poller threads', + nameShort: 'Poller threads', + type: 'gauge', + description: 'The number of poller threads by the tomcat connector.', + unit: 'short', + sources: { + prometheus: { + expr: 'tomcat_threadpool_pollerthreadcount{%(queriesSelector)s}', + legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}} - poller', + }, + }, + }, + + idleThreads: { + name: 'Idle threads', + nameShort: 'Idle threads', + type: 'gauge', + description: 'The number of idle threads by the tomcat connector.', + unit: 'short', + sources: { + prometheus: { + expr: 'tomcat_threadpool_keepalivecount{%(queriesSelector)s}', + legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}} - idle', + }, + }, + }, + + activeThreads: { + name: 'Active threads', + nameShort: 'Active threads', + type: 'gauge', + description: 'The number of active threads by the tomcat connector.', + unit: 'short', + sources: { + prometheus: { + expr: 'tomcat_threadpool_currentthreadcount{%(queriesSelector)s}', + legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}} - active', + }, + }, + }, + }, +} From 479f607a60179682f04b77e8fffa3721d90e629a Mon Sep 17 00:00:00 2001 From: schmikei Date: Tue, 14 Oct 2025 11:59:07 -0400 Subject: [PATCH 2/9] ensure style guide is followed --- apache-tomcat-mixin/dashboards.libsonnet | 1 + .../dashboards_out/apache-tomcat-hosts.json | 49 +++++++--- .../apache-tomcat-overview.json | 90 +++++++++++++------ apache-tomcat-mixin/mixin.libsonnet | 3 + apache-tomcat-mixin/panels.libsonnet | 73 ++++++++++----- apache-tomcat-mixin/rows.libsonnet | 27 +++--- .../signals/overview.libsonnet | 1 + 7 files changed, 173 insertions(+), 71 deletions(-) diff --git a/apache-tomcat-mixin/dashboards.libsonnet b/apache-tomcat-mixin/dashboards.libsonnet index 9a0ec7062..93a3f5b83 100644 --- a/apache-tomcat-mixin/dashboards.libsonnet +++ b/apache-tomcat-mixin/dashboards.libsonnet @@ -43,6 +43,7 @@ local logslib = import 'logs-lib/logs/main.libsonnet'; g.util.grid.wrapPanels( [ this.grafana.rows.hosts, + this.grafana.rows.hostServlets, ], ), ), diff --git a/apache-tomcat-mixin/dashboards_out/apache-tomcat-hosts.json b/apache-tomcat-mixin/dashboards_out/apache-tomcat-hosts.json index 67afd06e6..e3dd8f8be 100644 --- a/apache-tomcat-mixin/dashboards_out/apache-tomcat-hosts.json +++ b/apache-tomcat-mixin/dashboards_out/apache-tomcat-hosts.json @@ -61,7 +61,7 @@ }, "gridPos": { "h": 8, - "w": 8, + "w": 12, "x": 0, "y": 1 }, @@ -88,6 +88,7 @@ "expr": "sum(increase(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)) by (job, instance)", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - total sessions", "refId": "Total sessions" }, @@ -99,6 +100,7 @@ "expr": "sum(increase(tomcat_session_rejectedsessions_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)) by (job, instance)", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - rejected sessions", "refId": "Rejected sessions" }, @@ -110,6 +112,7 @@ "expr": "sum(increase(tomcat_session_expiredsessions_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)) by (job, instance)", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - expired sessions", "refId": "Expired sessions" }, @@ -121,6 +124,7 @@ "expr": "increase(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - {{host}}{{context}} - sessions", "refId": "Session rate" }, @@ -132,6 +136,7 @@ "expr": "increase(tomcat_session_rejectedsessions_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - {{host}}{{context}} - rejected", "refId": "Rejected rate" }, @@ -143,6 +148,7 @@ "expr": "increase(tomcat_session_expiredsessions_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - {{host}}{{context}} - expired", "refId": "Expired rate" } @@ -170,8 +176,8 @@ }, "gridPos": { "h": 8, - "w": 8, - "x": 8, + "w": 12, + "x": 12, "y": 1 }, "id": 3, @@ -197,6 +203,7 @@ "expr": "sum(increase(tomcat_session_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval), 1)) by (job, instance)", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - total", "refId": "Total session processing time" }, @@ -208,6 +215,7 @@ "expr": "increase(tomcat_session_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval), 1)", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - {{host}}{{context}}", "refId": "Session processing time" } @@ -215,6 +223,19 @@ "title": "Session processing time", "type": "timeseries" }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 0, + "x": 0, + "y": 9 + }, + "id": 4, + "panels": [ ], + "title": "Servlet", + "type": "row" + }, { "datasource": { "type": "prometheus", @@ -235,11 +256,11 @@ }, "gridPos": { "h": 8, - "w": 8, - "x": 16, - "y": 1 + "w": 12, + "x": 0, + "y": 10 }, - "id": 4, + "id": 5, "options": { "legend": { "asTable": true, @@ -262,6 +283,7 @@ "expr": "sum(rate(tomcat_servlet_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - total requests", "refId": "Total servlet requests" }, @@ -273,6 +295,7 @@ "expr": "sum(rate(tomcat_servlet_errorcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - total errors", "refId": "Total servlet errors" }, @@ -284,6 +307,7 @@ "expr": "rate(tomcat_servlet_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - {{host}}{{servlet}} - requests", "refId": "Servlet request rate" }, @@ -295,6 +319,7 @@ "expr": "rate(tomcat_servlet_errorcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - {{host}}{{context}} - errors", "refId": "Servlet error rate" } @@ -322,11 +347,11 @@ }, "gridPos": { "h": 8, - "w": 8, - "x": 0, - "y": 9 + "w": 12, + "x": 12, + "y": 10 }, - "id": 5, + "id": 6, "options": { "legend": { "asTable": true, @@ -349,6 +374,7 @@ "expr": "sum(increase(tomcat_servlet_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval), 1)) by (job, instance)", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - total", "refId": "Total servlet processing time" }, @@ -360,6 +386,7 @@ "expr": "increase(tomcat_servlet_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval), 1)", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - {{host}}{{servlet}}", "refId": "Servlet processing time" } diff --git a/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json b/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json index 4ede776a5..6853bf210 100644 --- a/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json +++ b/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json @@ -56,12 +56,13 @@ "lineInterpolation": "smooth", "lineWidth": 2, "showPoints": "never" - } + }, + "unit": "bytes" } }, "gridPos": { "h": 8, - "w": 8, + "w": 12, "x": 0, "y": 1 }, @@ -107,13 +108,14 @@ "lineInterpolation": "smooth", "lineWidth": 2, "showPoints": "never" - } + }, + "unit": "percent" } }, "gridPos": { "h": 8, - "w": 8, - "x": 8, + "w": 12, + "x": 12, "y": 1 }, "id": 3, @@ -137,7 +139,7 @@ "expr": "jvm_process_cpu_load{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}", "format": "time_series", "instant": false, - "legendFormat": "{{instance}}: CPU usage", + "legendFormat": "{{ instance }}", "refId": "CPU usage" } ], @@ -158,20 +160,23 @@ "lineInterpolation": "smooth", "lineWidth": 2, "showPoints": "never" - } + }, + "unit": "Bps" } }, "gridPos": { "h": 8, - "w": 8, - "x": 16, - "y": 1 + "w": 12, + "x": 0, + "y": 9 }, "id": 4, "options": { "legend": { + "asTable": true, "calcs": [ ], - "displayMode": "list" + "displayMode": "list", + "placement": "right" }, "tooltip": { "mode": "multi", @@ -188,6 +193,7 @@ "expr": "sum(rate(tomcat_bytessent_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - total", "refId": "Traffic sent total" }, @@ -199,6 +205,7 @@ "expr": "rate(tomcat_bytessent_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - {{protocol}} - {{port}}", "refId": "Traffic sent rate" } @@ -220,20 +227,23 @@ "lineInterpolation": "smooth", "lineWidth": 2, "showPoints": "never" - } + }, + "unit": "Bps" } }, "gridPos": { "h": 8, - "w": 8, - "x": 0, + "w": 12, + "x": 12, "y": 9 }, "id": 5, "options": { "legend": { + "asTable": true, "calcs": [ ], - "displayMode": "list" + "displayMode": "list", + "placement": "right" }, "tooltip": { "mode": "multi", @@ -250,6 +260,7 @@ "expr": "sum(rate(tomcat_bytesreceived_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - total", "refId": "Traffic received total" }, @@ -261,6 +272,7 @@ "expr": "rate(tomcat_bytesreceived_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - {{protocol}} - {{port}}", "refId": "Traffic received rate" } @@ -282,20 +294,23 @@ "lineInterpolation": "smooth", "lineWidth": 2, "showPoints": "never" - } + }, + "unit": "r/s" } }, "gridPos": { "h": 8, - "w": 8, - "x": 8, - "y": 9 + "w": 12, + "x": 0, + "y": 17 }, "id": 6, "options": { "legend": { + "asTable": true, "calcs": [ ], - "displayMode": "list" + "displayMode": "list", + "placement": "right" }, "tooltip": { "mode": "multi", @@ -312,6 +327,7 @@ "expr": "sum(rate(tomcat_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - total requests", "refId": "Requests total" }, @@ -323,6 +339,7 @@ "expr": "rate(tomcat_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - {{protocol}} - {{port}} - requests", "refId": "Requests rate" }, @@ -334,6 +351,7 @@ "expr": "sum(rate(tomcat_errorcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - total errors", "refId": "Requests errors" }, @@ -345,6 +363,7 @@ "expr": "rate(tomcat_errorcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - {{protocol}} - {{port}} - errors", "refId": "Requests errors rate" } @@ -372,15 +391,17 @@ }, "gridPos": { "h": 8, - "w": 8, - "x": 16, - "y": 9 + "w": 12, + "x": 12, + "y": 17 }, "id": 7, "options": { "legend": { + "asTable": true, "calcs": [ ], - "displayMode": "list" + "displayMode": "list", + "placement": "right" }, "tooltip": { "mode": "multi", @@ -397,8 +418,21 @@ "expr": "sum(increase(tomcat_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval), 1)) by (job, instance)", "format": "time_series", "instant": false, + "interval": "2m", "legendFormat": "{{ instance }} - total", "refId": "Processing time total" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "expr": "increase(tomcat_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval), 1)", + "format": "time_series", + "instant": false, + "interval": "2m", + "legendFormat": "{{ instance }} - {{protocol}} - {{port}}", + "refId": "Processing time rate" } ], "title": "Processing time", @@ -423,15 +457,17 @@ }, "gridPos": { "h": 8, - "w": 8, + "w": 24, "x": 0, - "y": 17 + "y": 25 }, "id": 8, "options": { "legend": { + "asTable": true, "calcs": [ ], - "displayMode": "list" + "displayMode": "list", + "placement": "right" }, "tooltip": { "mode": "multi", diff --git a/apache-tomcat-mixin/mixin.libsonnet b/apache-tomcat-mixin/mixin.libsonnet index 6a906870c..752e6c1ec 100644 --- a/apache-tomcat-mixin/mixin.libsonnet +++ b/apache-tomcat-mixin/mixin.libsonnet @@ -14,6 +14,9 @@ local k8s_patch = { cluster+: { allValue: '.*', }, + host+: { + allValue: '.*', + }, }; { diff --git a/apache-tomcat-mixin/panels.libsonnet b/apache-tomcat-mixin/panels.libsonnet index d0a88e56a..57998abe1 100644 --- a/apache-tomcat-mixin/panels.libsonnet +++ b/apache-tomcat-mixin/panels.libsonnet @@ -13,6 +13,7 @@ local commonlib = import 'common-lib/common/main.libsonnet'; 'Memory usage', targets=[signals.overview.memoryUsage.asTarget()] ) + + g.panel.timeSeries.standardOptions.withUnit('bytes') + g.panel.timeSeries.panelOptions.withDescription('The memory usage of the JVM of the instance.'), overviewCPUUsagePanel: @@ -20,34 +21,60 @@ local commonlib = import 'common-lib/common/main.libsonnet'; 'CPU usage', targets=[signals.overview.cpuUsage.asTarget()] ) + + g.panel.timeSeries.standardOptions.withUnit('percent') + g.panel.timeSeries.panelOptions.withDescription('The CPU usage of the JVM process.'), overviewTrafficSentPanel: commonlib.panels.generic.timeSeries.base.new( 'Traffic sent', - targets=[signals.overview.trafficSentTotal.asTarget(), signals.overview.trafficSentRate.asTarget()] + targets=[ + signals.overview.trafficSentTotal.asTarget() { interval: '2m' }, + signals.overview.trafficSentRate.asTarget() { interval: '2m' }, + ] ) - + g.panel.timeSeries.panelOptions.withDescription('The traffic sent for a Tomcat connector.'), + + g.panel.timeSeries.standardOptions.withUnit('Bps') + + g.panel.timeSeries.panelOptions.withDescription('The traffic sent for a Tomcat connector.') + + g.panel.timeSeries.options.legend.withAsTable(true) + + g.panel.timeSeries.options.legend.withPlacement('right'), overviewTrafficReceivedPanel: commonlib.panels.generic.timeSeries.base.new( 'Traffic received', - targets=[signals.overview.trafficReceivedTotal.asTarget(), signals.overview.trafficReceivedRate.asTarget()] + targets=[ + signals.overview.trafficReceivedTotal.asTarget() { interval: '2m' }, + signals.overview.trafficReceivedRate.asTarget() { interval: '2m' }, + ] ) - + g.panel.timeSeries.panelOptions.withDescription('The traffic received for a Tomcat connector.'), + + g.panel.timeSeries.standardOptions.withUnit('Bps') + + g.panel.timeSeries.panelOptions.withDescription('The traffic received for a Tomcat connector.') + + g.panel.timeSeries.options.legend.withAsTable(true) + + g.panel.timeSeries.options.legend.withPlacement('right'), overviewRequestsPanel: commonlib.panels.generic.timeSeries.base.new( 'Requests', - targets=[signals.overview.requestsTotal.asTarget(), signals.overview.requestsRate.asTarget(), signals.overview.requestsErrors.asTarget(), signals.overview.requestsErrorsRate.asTarget()] + targets=[ + signals.overview.requestsTotal.asTarget() { interval: '2m' }, + signals.overview.requestsRate.asTarget() { interval: '2m' }, + signals.overview.requestsErrors.asTarget() { interval: '2m' }, + signals.overview.requestsErrorsRate.asTarget() { interval: '2m' }, + ] ) - + g.panel.timeSeries.panelOptions.withDescription('The total requests and errors for a Tomcat connector.'), + + g.panel.timeSeries.standardOptions.withUnit('r/s') + + g.panel.timeSeries.panelOptions.withDescription('The total requests and errors for a Tomcat connector.') + + g.panel.timeSeries.options.legend.withAsTable(true) + + g.panel.timeSeries.options.legend.withPlacement('right'), overviewProcessingTimePanel: commonlib.panels.generic.timeSeries.base.new( 'Processing time', - targets=[signals.overview.processingTimeTotal.asTarget()] + targets=[ + signals.overview.processingTimeTotal.asTarget() { interval: '2m' }, + signals.overview.processingTimeRate.asTarget() { interval: '2m' }, + ] ) + + g.panel.timeSeries.options.legend.withAsTable(true) + + g.panel.timeSeries.options.legend.withPlacement('right') + g.panel.timeSeries.panelOptions.withDescription('The average time taken to process recent requests for a Tomcat connector.') + g.panel.timeSeries.standardOptions.withUnit('ms'), @@ -66,7 +93,9 @@ local commonlib = import 'common-lib/common/main.libsonnet'; signals.overview.activeThreads.asTarget(), ] ) - + g.panel.timeSeries.panelOptions.withDescription('The number of various threads used by a Tomcat connector.'), + + g.panel.timeSeries.panelOptions.withDescription('The number of various threads used by a Tomcat connector.') + + g.panel.timeSeries.options.legend.withAsTable(true) + + g.panel.timeSeries.options.legend.withPlacement('right'), // Hosts Panels @@ -74,12 +103,12 @@ local commonlib = import 'common-lib/common/main.libsonnet'; commonlib.panels.generic.timeSeries.base.new( 'Sessions', targets=[ - signals.hosts.totalSessions.asTarget(), - signals.hosts.rejectedSessions.asTarget(), - signals.hosts.expiredSessions.asTarget(), - signals.hosts.sessionRate.asTarget(), - signals.hosts.rejectedSessionRate.asTarget(), - signals.hosts.expiredSessionRate.asTarget(), + signals.hosts.totalSessions.asTarget() { interval: '2m' }, + signals.hosts.rejectedSessions.asTarget() { interval: '2m' }, + signals.hosts.expiredSessions.asTarget() { interval: '2m' }, + signals.hosts.sessionRate.asTarget() { interval: '2m' }, + signals.hosts.rejectedSessionRate.asTarget() { interval: '2m' }, + signals.hosts.expiredSessionRate.asTarget() { interval: '2m' }, ] ) + g.panel.timeSeries.panelOptions.withDescription('The number of different types of sessions created for a Tomcat host.') @@ -90,8 +119,8 @@ local commonlib = import 'common-lib/common/main.libsonnet'; commonlib.panels.generic.timeSeries.base.new( 'Session processing time', targets=[ - signals.hosts.totalSessionProcessingTime.asTarget(), - signals.hosts.sessionProcessingTime.asTarget(), + signals.hosts.totalSessionProcessingTime.asTarget() { interval: '2m' }, + signals.hosts.sessionProcessingTime.asTarget() { interval: '2m' }, ] ) + g.panel.timeSeries.panelOptions.withDescription('The average time taken to process recent sessions for a Tomcat host.') @@ -103,10 +132,10 @@ local commonlib = import 'common-lib/common/main.libsonnet'; commonlib.panels.generic.timeSeries.base.new( 'Servlet', targets=[ - signals.hosts.totalServletRequests.asTarget(), - signals.hosts.totalServletErrors.asTarget(), - signals.hosts.servletRequestRate.asTarget(), - signals.hosts.servletErrorRate.asTarget(), + signals.hosts.totalServletRequests.asTarget() { interval: '2m' }, + signals.hosts.totalServletErrors.asTarget() { interval: '2m' }, + signals.hosts.servletRequestRate.asTarget() { interval: '2m' }, + signals.hosts.servletErrorRate.asTarget() { interval: '2m' }, ] ) + g.panel.timeSeries.panelOptions.withDescription('The total requests and errors for a Tomcat servlet.') @@ -118,8 +147,8 @@ local commonlib = import 'common-lib/common/main.libsonnet'; commonlib.panels.generic.timeSeries.base.new( 'Servlet processing time', targets=[ - signals.hosts.totalServletProcessingTime.asTarget(), - signals.hosts.servletProcessingTime.asTarget(), + signals.hosts.totalServletProcessingTime.asTarget() { interval: '2m' }, + signals.hosts.servletProcessingTime.asTarget() { interval: '2m' }, ] ) + g.panel.timeSeries.panelOptions.withDescription('The average time taken to process recent servlet requests for a Tomcat host.') diff --git a/apache-tomcat-mixin/rows.libsonnet b/apache-tomcat-mixin/rows.libsonnet index 1a325a714..a10bcdc8e 100644 --- a/apache-tomcat-mixin/rows.libsonnet +++ b/apache-tomcat-mixin/rows.libsonnet @@ -10,23 +10,28 @@ local g = import './g.libsonnet'; overview: g.panel.row.new('Overview') + g.panel.row.withCollapsed(value=false) + g.panel.row.withPanels([ - panels.overviewMemoryUsagePanel, - panels.overviewCPUUsagePanel, - panels.overviewTrafficSentPanel, - panels.overviewTrafficReceivedPanel, - panels.overviewRequestsPanel, - panels.overviewProcessingTimePanel, - panels.overviewThreadsPanel, + panels.overviewMemoryUsagePanel { gridPos+: { w: 12 } }, + panels.overviewCPUUsagePanel { gridPos+: { w: 12 } }, + panels.overviewTrafficSentPanel { gridPos+: { w: 12 } }, + panels.overviewTrafficReceivedPanel { gridPos+: { w: 12 } }, + panels.overviewRequestsPanel { gridPos+: { w: 12 } }, + panels.overviewProcessingTimePanel { gridPos+: { w: 12 } }, + panels.overviewThreadsPanel { gridPos+: { w: 24 } }, ]), // hosts rows hosts: g.panel.row.new('Hosts') + g.panel.row.withCollapsed(value=false) + g.panel.row.withPanels([ - panels.hostsSessionsPanel, - panels.hostsSessionProcessingTimePanel, - panels.hostsServletPanel, - panels.hostsServletProcessingTimePanel, + panels.hostsSessionsPanel { gridPos+: { w: 12 } }, + panels.hostsSessionProcessingTimePanel { gridPos+: { w: 12 } }, ]), + + hostServlets: g.panel.row.new('Servlet') + + g.panel.row.withCollapsed(value=false) + + g.panel.row.withPanels([ + panels.hostsServletPanel { gridPos+: { w: 12 } }, + panels.hostsServletProcessingTimePanel { gridPos+: { w: 12 } }, + ]), }, } diff --git a/apache-tomcat-mixin/signals/overview.libsonnet b/apache-tomcat-mixin/signals/overview.libsonnet index 762d6e651..138fdc249 100644 --- a/apache-tomcat-mixin/signals/overview.libsonnet +++ b/apache-tomcat-mixin/signals/overview.libsonnet @@ -34,6 +34,7 @@ function(this) { sources: { prometheus: { expr: 'jvm_process_cpu_load{%(queriesSelector)s}', + legendCustomTemplate: legendCustomTemplate, }, }, }, From 62e26d0e44ae19570ecd3b033cab20c9d09bf3b1 Mon Sep 17 00:00:00 2001 From: schmikei Date: Tue, 14 Oct 2025 13:48:42 -0400 Subject: [PATCH 3/9] stylistic updates --- apache-tomcat-mixin/dashboards.libsonnet | 30 ++++++++- .../dashboards_out/apache-tomcat-hosts.json | 67 ++++++++++++++----- .../dashboards_out/apache-tomcat-logs.json | 6 -- .../apache-tomcat-overview.json | 58 +++++++++++----- apache-tomcat-mixin/mixin.libsonnet | 7 +- apache-tomcat-mixin/signals/hosts.libsonnet | 34 +++++----- .../signals/overview.libsonnet | 36 +++++----- 7 files changed, 154 insertions(+), 84 deletions(-) diff --git a/apache-tomcat-mixin/dashboards.libsonnet b/apache-tomcat-mixin/dashboards.libsonnet index 93a3f5b83..d0f337e0f 100644 --- a/apache-tomcat-mixin/dashboards.libsonnet +++ b/apache-tomcat-mixin/dashboards.libsonnet @@ -26,7 +26,16 @@ local logslib = import 'logs-lib/logs/main.libsonnet'; ), ), ) + root.applyCommon( - vars.multiInstance, + vars.multiInstance + [ + g.dashboard.variable.query.new('protocol', + query='label_values(tomcat_bytesreceived_total{%(queriesSelector)s}, protocol)' % vars) + g.dashboard.variable.custom.selectionOptions.withMulti(true) + + g.dashboard.variable.query.queryTypes.withLabelValues(label='protocol', metric='tomcat_bytesreceived_total{%(queriesSelector)s}' % vars) + + g.dashboard.variable.query.withDatasourceFromVariable(variable=vars.datasources.prometheus), + + g.dashboard.variable.query.new('port',query='label_values(tomcat_bytesreceived_total{%(queriesSelector)s}, port)' % vars) + g.dashboard.variable.custom.selectionOptions.withMulti(true) + + g.dashboard.variable.query.queryTypes.withLabelValues(label='port', metric='tomcat_bytesreceived_total{%(queriesSelector)s}' % vars) + + g.dashboard.variable.query.withDatasourceFromVariable(variable=vars.datasources.prometheus), + ], uid + '_overview', tags, links { apacheTomcatOverview:: {} }, @@ -48,7 +57,22 @@ local logslib = import 'logs-lib/logs/main.libsonnet'; ), ), ) + root.applyCommon( - vars.multiInstance, + vars.multiInstance + [ + g.dashboard.variable.query.new('host') + + g.dashboard.variable.custom.selectionOptions.withMulti(true) + + g.dashboard.variable.query.queryTypes.withLabelValues(label='host', metric='tomcat_session_sessioncounter_total{%(queriesSelector)s}' % vars) + + g.dashboard.variable.query.withDatasourceFromVariable(variable=vars.datasources.prometheus), + + g.dashboard.variable.query.new('context') + + g.dashboard.variable.custom.selectionOptions.withMulti(true) + + g.dashboard.variable.query.queryTypes.withLabelValues(label='context', metric='tomcat_session_sessioncounter_total{%(queriesSelector)s}' % vars) + + g.dashboard.variable.query.withDatasourceFromVariable(variable=vars.datasources.prometheus), + + g.dashboard.variable.query.new('servlet') + + g.dashboard.variable.custom.selectionOptions.withMulti(true) + + g.dashboard.variable.query.queryTypes.withLabelValues(label='servlet', metric='tomcat_servlet_requestcount_total{%(queriesSelector)s}' % vars) + + g.dashboard.variable.query.withDatasourceFromVariable(variable=vars.datasources.prometheus), + ], uid + '_hosts', tags, links { apacheTomcatHosts:: {} }, @@ -72,7 +96,7 @@ local logslib = import 'logs-lib/logs/main.libsonnet'; dashboards+: { logs+: - root.applyCommon(super.logs.templating.list, uid=uid + '-logs', tags=tags, links=links { logs+:: {} }, annotations=annotations, timezone=timezone, refresh=refresh, period=period), + root.applyCommon(super.logs.templating.list, uid=uid + '-logs', tags=tags, links=links { apacheTomcatLogs:: {} }, annotations=annotations, timezone=timezone, refresh=refresh, period=period), }, panels+: { diff --git a/apache-tomcat-mixin/dashboards_out/apache-tomcat-hosts.json b/apache-tomcat-mixin/dashboards_out/apache-tomcat-hosts.json index e3dd8f8be..81e60b1e0 100644 --- a/apache-tomcat-mixin/dashboards_out/apache-tomcat-hosts.json +++ b/apache-tomcat-mixin/dashboards_out/apache-tomcat-hosts.json @@ -85,7 +85,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(increase(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)) by (job, instance)", + "expr": "sum(increase(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval)) by (job, instance)", "format": "time_series", "instant": false, "interval": "2m", @@ -97,7 +97,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(increase(tomcat_session_rejectedsessions_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)) by (job, instance)", + "expr": "sum(increase(tomcat_session_rejectedsessions_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval)) by (job, instance)", "format": "time_series", "instant": false, "interval": "2m", @@ -109,7 +109,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(increase(tomcat_session_expiredsessions_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)) by (job, instance)", + "expr": "sum(increase(tomcat_session_expiredsessions_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval)) by (job, instance)", "format": "time_series", "instant": false, "interval": "2m", @@ -121,7 +121,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "increase(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)", + "expr": "increase(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval)", "format": "time_series", "instant": false, "interval": "2m", @@ -133,7 +133,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "increase(tomcat_session_rejectedsessions_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)", + "expr": "increase(tomcat_session_rejectedsessions_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval)", "format": "time_series", "instant": false, "interval": "2m", @@ -145,7 +145,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "increase(tomcat_session_expiredsessions_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval)", + "expr": "increase(tomcat_session_expiredsessions_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval)", "format": "time_series", "instant": false, "interval": "2m", @@ -200,7 +200,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(increase(tomcat_session_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval), 1)) by (job, instance)", + "expr": "sum(increase(tomcat_session_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval), 1)) by (job, instance)", "format": "time_series", "instant": false, "interval": "2m", @@ -212,7 +212,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "increase(tomcat_session_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval), 1)", + "expr": "increase(tomcat_session_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", host=~\"$host\", context=~\"$context\"}[$__interval:] offset -$__interval), 1)", "format": "time_series", "instant": false, "interval": "2m", @@ -280,7 +280,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(rate(tomcat_servlet_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", + "expr": "sum(rate(tomcat_servlet_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", module=~\"$host$context\", servlet=~\"$servlet\"}[$__rate_interval])) by (job, instance)", "format": "time_series", "instant": false, "interval": "2m", @@ -292,7 +292,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(rate(tomcat_servlet_errorcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", + "expr": "sum(rate(tomcat_servlet_errorcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", module=~\"$host$context\", servlet=~\"$servlet\"}[$__rate_interval])) by (job, instance)", "format": "time_series", "instant": false, "interval": "2m", @@ -304,11 +304,11 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "rate(tomcat_servlet_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", + "expr": "rate(tomcat_servlet_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", module=~\"$host$context\", servlet=~\"$servlet\"}[$__rate_interval])", "format": "time_series", "instant": false, "interval": "2m", - "legendFormat": "{{ instance }} - {{host}}{{servlet}} - requests", + "legendFormat": "{{ instance }} - {{module}}{{servlet}} - requests", "refId": "Servlet request rate" }, { @@ -316,11 +316,11 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "rate(tomcat_servlet_errorcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", + "expr": "rate(tomcat_servlet_errorcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", module=~\"$host$context\", servlet=~\"$servlet\"}[$__rate_interval])", "format": "time_series", "instant": false, "interval": "2m", - "legendFormat": "{{ instance }} - {{host}}{{context}} - errors", + "legendFormat": "{{ instance }} - {{module}}{{servlet}} - errors", "refId": "Servlet error rate" } ], @@ -371,7 +371,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(increase(tomcat_servlet_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval), 1)) by (job, instance)", + "expr": "sum(increase(tomcat_servlet_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", module=~\"$host$context\", servlet=~\"$servlet\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", module=~\"$host$context\", servlet=~\"$servlet\"}[$__interval:] offset -$__interval), 1)) by (job, instance)", "format": "time_series", "instant": false, "interval": "2m", @@ -383,11 +383,11 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "increase(tomcat_servlet_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval), 1)", + "expr": "increase(tomcat_servlet_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", module=~\"$host$context\", servlet=~\"$servlet\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", module=~\"$host$context\", servlet=~\"$servlet\"}[$__interval:] offset -$__interval), 1)", "format": "time_series", "instant": false, "interval": "2m", - "legendFormat": "{{ instance }} - {{host}}{{servlet}}", + "legendFormat": "{{ instance }} - {{module}}{{servlet}}", "refId": "Servlet processing time" } ], @@ -461,6 +461,39 @@ "query": "loki", "regex": "(?!grafanacloud.+usage-insights|grafanacloud.+alert-state-history).+", "type": "datasource" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "multi": true, + "name": "host", + "query": "label_values(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}, host)", + "refresh": 2, + "type": "query" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "multi": true, + "name": "context", + "query": "label_values(tomcat_session_sessioncounter_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}, context)", + "refresh": 2, + "type": "query" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "multi": true, + "name": "servlet", + "query": "label_values(tomcat_servlet_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}, servlet)", + "refresh": 2, + "type": "query" } ] }, diff --git a/apache-tomcat-mixin/dashboards_out/apache-tomcat-logs.json b/apache-tomcat-mixin/dashboards_out/apache-tomcat-logs.json index 68b392c50..9a997be9b 100644 --- a/apache-tomcat-mixin/dashboards_out/apache-tomcat-logs.json +++ b/apache-tomcat-mixin/dashboards_out/apache-tomcat-logs.json @@ -11,12 +11,6 @@ "type": "link", "url": "/d/apachetomcat_hosts" }, - { - "keepTime": true, - "title": "Apache Tomcat logs", - "type": "link", - "url": "/d/apachetomcat-logs" - }, { "keepTime": true, "title": "Apache Tomcat overview", diff --git a/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json b/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json index 6853bf210..d618cc0c6 100644 --- a/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json +++ b/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json @@ -190,7 +190,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(rate(tomcat_bytessent_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", + "expr": "sum(rate(tomcat_bytessent_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])) by (job, instance)", "format": "time_series", "instant": false, "interval": "2m", @@ -202,7 +202,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "rate(tomcat_bytessent_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", + "expr": "rate(tomcat_bytessent_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])", "format": "time_series", "instant": false, "interval": "2m", @@ -257,7 +257,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(rate(tomcat_bytesreceived_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", + "expr": "sum(rate(tomcat_bytesreceived_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])) by (job, instance)", "format": "time_series", "instant": false, "interval": "2m", @@ -269,7 +269,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "rate(tomcat_bytesreceived_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", + "expr": "rate(tomcat_bytesreceived_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])", "format": "time_series", "instant": false, "interval": "2m", @@ -324,7 +324,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(rate(tomcat_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", + "expr": "sum(rate(tomcat_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])) by (job, instance)", "format": "time_series", "instant": false, "interval": "2m", @@ -336,7 +336,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "rate(tomcat_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", + "expr": "rate(tomcat_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])", "format": "time_series", "instant": false, "interval": "2m", @@ -348,7 +348,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(rate(tomcat_errorcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])) by (job, instance)", + "expr": "sum(rate(tomcat_errorcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])) by (job, instance)", "format": "time_series", "instant": false, "interval": "2m", @@ -360,7 +360,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "rate(tomcat_errorcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__rate_interval])", + "expr": "rate(tomcat_errorcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])", "format": "time_series", "instant": false, "interval": "2m", @@ -415,7 +415,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(increase(tomcat_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval), 1)) by (job, instance)", + "expr": "sum(increase(tomcat_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__interval:] offset -$__interval), 1)) by (job, instance)", "format": "time_series", "instant": false, "interval": "2m", @@ -427,7 +427,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "increase(tomcat_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}[$__interval:] offset -$__interval), 1)", + "expr": "increase(tomcat_processingtime_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_requestcount_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__interval:] offset -$__interval), 1)", "format": "time_series", "instant": false, "interval": "2m", @@ -481,7 +481,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(tomcat_threadpool_connectioncount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}) by (job, instance)", + "expr": "sum(tomcat_threadpool_connectioncount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}) by (job, instance)", "format": "time_series", "instant": false, "legendFormat": "{{ instance }} - total connections", @@ -492,7 +492,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(tomcat_threadpool_pollerthreadcount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}) by (job, instance)", + "expr": "sum(tomcat_threadpool_pollerthreadcount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}) by (job, instance)", "format": "time_series", "instant": false, "legendFormat": "{{ instance }} - poller total", @@ -503,7 +503,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(tomcat_threadpool_keepalivecount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}) by (job, instance)", + "expr": "sum(tomcat_threadpool_keepalivecount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}) by (job, instance)", "format": "time_series", "instant": false, "legendFormat": "{{ instance }} - idle total", @@ -514,7 +514,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "sum(tomcat_threadpool_currentthreadcount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}) by (job, instance)", + "expr": "sum(tomcat_threadpool_currentthreadcount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}) by (job, instance)", "format": "time_series", "instant": false, "legendFormat": "{{ instance }} - active total", @@ -525,7 +525,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "tomcat_threadpool_connectioncount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}", + "expr": "tomcat_threadpool_connectioncount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}", "format": "time_series", "instant": false, "legendFormat": "{{ instance }} - {{protocol}} - {{port}} - connections", @@ -536,7 +536,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "tomcat_threadpool_pollerthreadcount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}", + "expr": "tomcat_threadpool_pollerthreadcount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}", "format": "time_series", "instant": false, "legendFormat": "{{ instance }} - {{protocol}} - {{port}} - poller", @@ -547,7 +547,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "tomcat_threadpool_keepalivecount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}", + "expr": "tomcat_threadpool_keepalivecount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}", "format": "time_series", "instant": false, "legendFormat": "{{ instance }} - {{protocol}} - {{port}} - idle", @@ -558,7 +558,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "tomcat_threadpool_currentthreadcount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}", + "expr": "tomcat_threadpool_currentthreadcount{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}", "format": "time_series", "instant": false, "legendFormat": "{{ instance }} - {{protocol}} - {{port}} - active", @@ -635,6 +635,28 @@ "query": "loki", "regex": "(?!grafanacloud.+usage-insights|grafanacloud.+alert-state-history).+", "type": "datasource" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "multi": true, + "name": "protocol", + "query": "label_values(tomcat_bytesreceived_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}, protocol)", + "refresh": 2, + "type": "query" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "multi": true, + "name": "port", + "query": "label_values(tomcat_bytesreceived_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}, port)", + "refresh": 2, + "type": "query" } ] }, diff --git a/apache-tomcat-mixin/mixin.libsonnet b/apache-tomcat-mixin/mixin.libsonnet index 752e6c1ec..8444f3c60 100644 --- a/apache-tomcat-mixin/mixin.libsonnet +++ b/apache-tomcat-mixin/mixin.libsonnet @@ -10,13 +10,10 @@ local mixin = enableLokiLogs: config.enableLokiLogs, }); -local k8s_patch = { +local labels_patch = { cluster+: { allValue: '.*', }, - host+: { - allValue: '.*', - }, }; { @@ -24,7 +21,7 @@ local k8s_patch = { local tags = config.dashboardTags, [fname]: local dashboard = util.decorate_dashboard(mixin.grafana.dashboards[fname], tags=tags); - dashboard + util.patch_variables(dashboard, k8s_patch) + dashboard + util.patch_variables(dashboard, labels_patch) for fname in std.objectFields(mixin.grafana.dashboards) }, diff --git a/apache-tomcat-mixin/signals/hosts.libsonnet b/apache-tomcat-mixin/signals/hosts.libsonnet index 5446dcd64..5991b8acf 100644 --- a/apache-tomcat-mixin/signals/hosts.libsonnet +++ b/apache-tomcat-mixin/signals/hosts.libsonnet @@ -19,7 +19,7 @@ function(this) { unit: 'none', sources: { prometheus: { - expr: 'sum(increase(tomcat_session_sessioncounter_total{%(queriesSelector)s}[$__interval:] offset -$__interval)) by (job, instance)', + expr: 'sum(increase(tomcat_session_sessioncounter_total{%(queriesSelector)s, host=~"$host", context=~"$context"}[$__interval:] offset -$__interval)) by (job, instance)', legendCustomTemplate: legendCustomTemplate + ' - total sessions', }, }, @@ -33,7 +33,7 @@ function(this) { unit: 'none', sources: { prometheus: { - expr: 'sum(increase(tomcat_session_rejectedsessions_total{%(queriesSelector)s}[$__interval:] offset -$__interval)) by (job, instance)', + expr: 'sum(increase(tomcat_session_rejectedsessions_total{%(queriesSelector)s, host=~"$host", context=~"$context"}[$__interval:] offset -$__interval)) by (job, instance)', legendCustomTemplate: legendCustomTemplate + ' - rejected sessions', }, }, @@ -47,7 +47,7 @@ function(this) { unit: 'none', sources: { prometheus: { - expr: 'sum(increase(tomcat_session_expiredsessions_total{%(queriesSelector)s}[$__interval:] offset -$__interval)) by (job, instance)', + expr: 'sum(increase(tomcat_session_expiredsessions_total{%(queriesSelector)s, host=~"$host", context=~"$context"}[$__interval:] offset -$__interval)) by (job, instance)', legendCustomTemplate: legendCustomTemplate + ' - expired sessions', }, }, @@ -61,7 +61,7 @@ function(this) { unit: 'none', sources: { prometheus: { - expr: 'tomcat_session_sessioncounter_total{%(queriesSelector)s}', + expr: 'tomcat_session_sessioncounter_total{%(queriesSelector)s, host=~"$host", context=~"$context"}', rangeFunction: 'increase', legendCustomTemplate: legendCustomTemplate + ' - {{host}}{{context}} - sessions', }, @@ -76,7 +76,7 @@ function(this) { unit: 'none', sources: { prometheus: { - expr: 'tomcat_session_rejectedsessions_total{%(queriesSelector)s}', + expr: 'tomcat_session_rejectedsessions_total{%(queriesSelector)s, host=~"$host", context=~"$context"}', rangeFunction: 'increase', legendCustomTemplate: legendCustomTemplate + ' - {{host}}{{context}} - rejected', }, @@ -91,7 +91,7 @@ function(this) { unit: 'none', sources: { prometheus: { - expr: 'tomcat_session_expiredsessions_total{%(queriesSelector)s}', + expr: 'tomcat_session_expiredsessions_total{%(queriesSelector)s, host=~"$host", context=~"$context"}', rangeFunction: 'increase', legendCustomTemplate: legendCustomTemplate + ' - {{host}}{{context}} - expired', }, @@ -106,7 +106,7 @@ function(this) { unit: 'ms', sources: { prometheus: { - expr: 'sum(increase(tomcat_session_processingtime_total{%(queriesSelector)s}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{%(queriesSelector)s}[$__interval:] offset -$__interval), 1)) by (job, instance)', + expr: 'sum(increase(tomcat_session_processingtime_total{%(queriesSelector)s, host=~"$host", context=~"$context"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{%(queriesSelector)s, host=~"$host", context=~"$context"}[$__interval:] offset -$__interval), 1)) by (job, instance)', legendCustomTemplate: legendCustomTemplate + ' - total', }, }, @@ -120,7 +120,7 @@ function(this) { unit: 'ms', sources: { prometheus: { - expr: 'increase(tomcat_session_processingtime_total{%(queriesSelector)s}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{%(queriesSelector)s}[$__interval:] offset -$__interval), 1)', + expr: 'increase(tomcat_session_processingtime_total{%(queriesSelector)s, host=~"$host", context=~"$context"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_session_sessioncounter_total{%(queriesSelector)s, host=~"$host", context=~"$context"}[$__interval:] offset -$__interval), 1)', legendCustomTemplate: legendCustomTemplate + ' - {{host}}{{context}}', }, }, @@ -134,7 +134,7 @@ function(this) { unit: 'r/s', sources: { prometheus: { - expr: 'sum(rate(tomcat_servlet_requestcount_total{%(queriesSelector)s}[$__rate_interval])) by (job, instance)', + expr: 'sum(rate(tomcat_servlet_requestcount_total{%(queriesSelector)s, module=~"$host$context", servlet=~"$servlet"}[$__rate_interval])) by (job, instance)', legendCustomTemplate: legendCustomTemplate + ' - total requests', }, }, @@ -149,7 +149,7 @@ function(this) { unit: 'r/s', sources: { prometheus: { - expr: 'sum(rate(tomcat_servlet_errorcount_total{%(queriesSelector)s}[$__rate_interval])) by (job, instance)', + expr: 'sum(rate(tomcat_servlet_errorcount_total{%(queriesSelector)s, module=~"$host$context", servlet=~"$servlet"}[$__rate_interval])) by (job, instance)', legendCustomTemplate: legendCustomTemplate + ' - total errors', }, }, @@ -163,8 +163,8 @@ function(this) { unit: 'r/s', sources: { prometheus: { - expr: 'tomcat_servlet_requestcount_total{%(queriesSelector)s}', - legendCustomTemplate: legendCustomTemplate + ' - {{host}}{{servlet}} - requests', + expr: 'tomcat_servlet_requestcount_total{%(queriesSelector)s, module=~"$host$context", servlet=~"$servlet"}', + legendCustomTemplate: legendCustomTemplate + ' - {{module}}{{servlet}} - requests', }, }, }, @@ -177,8 +177,8 @@ function(this) { unit: 'r/s', sources: { prometheus: { - expr: 'tomcat_servlet_errorcount_total{%(queriesSelector)s}', - legendCustomTemplate: legendCustomTemplate + ' - {{host}}{{context}} - errors', + expr: 'tomcat_servlet_errorcount_total{%(queriesSelector)s, module=~"$host$context", servlet=~"$servlet"}', + legendCustomTemplate: legendCustomTemplate + ' - {{module}}{{servlet}} - errors', }, }, }, @@ -191,7 +191,7 @@ function(this) { unit: 'ms', sources: { prometheus: { - expr: 'sum(increase(tomcat_servlet_processingtime_total{%(queriesSelector)s}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{%(queriesSelector)s}[$__interval:] offset -$__interval), 1)) by (job, instance)', + expr: 'sum(increase(tomcat_servlet_processingtime_total{%(queriesSelector)s, module=~"$host$context", servlet=~"$servlet"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{%(queriesSelector)s, module=~"$host$context", servlet=~"$servlet"}[$__interval:] offset -$__interval), 1)) by (job, instance)', legendCustomTemplate: legendCustomTemplate + ' - total', }, }, @@ -205,8 +205,8 @@ function(this) { unit: 'ms', sources: { prometheus: { - expr: 'increase(tomcat_servlet_processingtime_total{%(queriesSelector)s}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{%(queriesSelector)s}[$__interval:] offset -$__interval), 1)', - legendCustomTemplate: legendCustomTemplate + ' - {{host}}{{servlet}}', + expr: 'increase(tomcat_servlet_processingtime_total{%(queriesSelector)s, module=~"$host$context", servlet=~"$servlet"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_servlet_requestcount_total{%(queriesSelector)s, module=~"$host$context", servlet=~"$servlet"}[$__interval:] offset -$__interval), 1)', + legendCustomTemplate: legendCustomTemplate + ' - {{module}}{{servlet}}', }, }, }, diff --git a/apache-tomcat-mixin/signals/overview.libsonnet b/apache-tomcat-mixin/signals/overview.libsonnet index 138fdc249..e761f99a6 100644 --- a/apache-tomcat-mixin/signals/overview.libsonnet +++ b/apache-tomcat-mixin/signals/overview.libsonnet @@ -47,7 +47,7 @@ function(this) { unit: 'Bps', sources: { prometheus: { - expr: 'sum(rate(tomcat_bytessent_total{%(queriesSelector)s}[$__rate_interval])) by (job, instance)', + expr: 'sum(rate(tomcat_bytessent_total{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}[$__rate_interval])) by (job, instance)', legendCustomTemplate: legendCustomTemplate + ' - total', }, }, @@ -61,7 +61,7 @@ function(this) { unit: 'Bps', sources: { prometheus: { - expr: 'tomcat_bytessent_total{%(queriesSelector)s}', + expr: 'tomcat_bytessent_total{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}', legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}}', }, }, @@ -75,7 +75,7 @@ function(this) { unit: 'Bps', sources: { prometheus: { - expr: 'sum(rate(tomcat_bytesreceived_total{%(queriesSelector)s}[$__rate_interval])) by (job, instance)', + expr: 'sum(rate(tomcat_bytesreceived_total{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}[$__rate_interval])) by (job, instance)', legendCustomTemplate: legendCustomTemplate + ' - total', }, }, @@ -89,7 +89,7 @@ function(this) { unit: 'Bps', sources: { prometheus: { - expr: 'tomcat_bytesreceived_total{%(queriesSelector)s}', + expr: 'tomcat_bytesreceived_total{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}', legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}}', }, }, @@ -104,7 +104,7 @@ function(this) { unit: 'r/s', sources: { prometheus: { - expr: 'sum(rate(tomcat_requestcount_total{%(queriesSelector)s}[$__rate_interval])) by (job, instance)', + expr: 'sum(rate(tomcat_requestcount_total{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}[$__rate_interval])) by (job, instance)', legendCustomTemplate: legendCustomTemplate + ' - total requests', }, }, @@ -118,7 +118,7 @@ function(this) { unit: 'r/s', sources: { prometheus: { - expr: 'sum(rate(tomcat_errorcount_total{%(queriesSelector)s}[$__rate_interval])) by (job, instance)', + expr: 'sum(rate(tomcat_errorcount_total{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}[$__rate_interval])) by (job, instance)', legendCustomTemplate: legendCustomTemplate + ' - total errors', }, }, @@ -132,7 +132,7 @@ function(this) { unit: 'r/s', sources: { prometheus: { - expr: 'tomcat_requestcount_total{%(queriesSelector)s}', + expr: 'tomcat_requestcount_total{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}', legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}} - requests', }, }, @@ -146,7 +146,7 @@ function(this) { unit: 'r/s', sources: { prometheus: { - expr: 'tomcat_errorcount_total{%(queriesSelector)s}', + expr: 'tomcat_errorcount_total{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}', legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}} - errors', }, }, @@ -160,7 +160,7 @@ function(this) { unit: 'ms', sources: { prometheus: { - expr: 'sum(increase(tomcat_processingtime_total{%(queriesSelector)s}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_requestcount_total{%(queriesSelector)s}[$__interval:] offset -$__interval), 1)) by (job, instance)', + expr: 'sum(increase(tomcat_processingtime_total{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_requestcount_total{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}[$__interval:] offset -$__interval), 1)) by (job, instance)', legendCustomTemplate: legendCustomTemplate + ' - total', }, }, @@ -174,7 +174,7 @@ function(this) { unit: 'ms', sources: { prometheus: { - expr: 'increase(tomcat_processingtime_total{%(queriesSelector)s}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_requestcount_total{%(queriesSelector)s}[$__interval:] offset -$__interval), 1)', + expr: 'increase(tomcat_processingtime_total{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}[$__interval:] offset -$__interval) / clamp_min(increase(tomcat_requestcount_total{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}[$__interval:] offset -$__interval), 1)', legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}}', }, }, @@ -188,7 +188,7 @@ function(this) { unit: 'short', sources: { prometheus: { - expr: 'sum(tomcat_threadpool_connectioncount{%(queriesSelector)s}) by (job, instance)', + expr: 'sum(tomcat_threadpool_connectioncount{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}) by (job, instance)', legendCustomTemplate: legendCustomTemplate + ' - total connections', }, }, @@ -202,7 +202,7 @@ function(this) { unit: 'short', sources: { prometheus: { - expr: 'sum(tomcat_threadpool_pollerthreadcount{%(queriesSelector)s}) by (job, instance)', + expr: 'sum(tomcat_threadpool_pollerthreadcount{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}) by (job, instance)', legendCustomTemplate: legendCustomTemplate + ' - poller total', }, }, @@ -216,7 +216,7 @@ function(this) { unit: 'short', sources: { prometheus: { - expr: 'sum(tomcat_threadpool_keepalivecount{%(queriesSelector)s}) by (job, instance)', + expr: 'sum(tomcat_threadpool_keepalivecount{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}) by (job, instance)', legendCustomTemplate: legendCustomTemplate + ' - idle total', }, }, @@ -230,7 +230,7 @@ function(this) { unit: 'short', sources: { prometheus: { - expr: 'sum(tomcat_threadpool_currentthreadcount{%(queriesSelector)s}) by (job, instance)', + expr: 'sum(tomcat_threadpool_currentthreadcount{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}) by (job, instance)', legendCustomTemplate: legendCustomTemplate + ' - active total', }, }, @@ -244,7 +244,7 @@ function(this) { unit: 'short', sources: { prometheus: { - expr: 'tomcat_threadpool_connectioncount{%(queriesSelector)s}', + expr: 'tomcat_threadpool_connectioncount{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}', legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}} - connections', }, }, @@ -258,7 +258,7 @@ function(this) { unit: 'short', sources: { prometheus: { - expr: 'tomcat_threadpool_pollerthreadcount{%(queriesSelector)s}', + expr: 'tomcat_threadpool_pollerthreadcount{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}', legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}} - poller', }, }, @@ -272,7 +272,7 @@ function(this) { unit: 'short', sources: { prometheus: { - expr: 'tomcat_threadpool_keepalivecount{%(queriesSelector)s}', + expr: 'tomcat_threadpool_keepalivecount{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}', legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}} - idle', }, }, @@ -286,7 +286,7 @@ function(this) { unit: 'short', sources: { prometheus: { - expr: 'tomcat_threadpool_currentthreadcount{%(queriesSelector)s}', + expr: 'tomcat_threadpool_currentthreadcount{%(queriesSelector)s, protocol=~"$protocol", port=~"$port"}', legendCustomTemplate: legendCustomTemplate + ' - {{protocol}} - {{port}} - active', }, }, From 05757bce6d2d8a10cc5f247be6e46d412f77ebdd Mon Sep 17 00:00:00 2001 From: schmikei Date: Tue, 14 Oct 2025 14:18:23 -0400 Subject: [PATCH 4/9] make fmt --- apache-tomcat-mixin/dashboards.libsonnet | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apache-tomcat-mixin/dashboards.libsonnet b/apache-tomcat-mixin/dashboards.libsonnet index d0f337e0f..85ce12df3 100644 --- a/apache-tomcat-mixin/dashboards.libsonnet +++ b/apache-tomcat-mixin/dashboards.libsonnet @@ -27,12 +27,12 @@ local logslib = import 'logs-lib/logs/main.libsonnet'; ), ) + root.applyCommon( vars.multiInstance + [ - g.dashboard.variable.query.new('protocol', - query='label_values(tomcat_bytesreceived_total{%(queriesSelector)s}, protocol)' % vars) + g.dashboard.variable.custom.selectionOptions.withMulti(true) + g.dashboard.variable.query.new('protocol', + query='label_values(tomcat_bytesreceived_total{%(queriesSelector)s}, protocol)' % vars) + g.dashboard.variable.custom.selectionOptions.withMulti(true) + g.dashboard.variable.query.queryTypes.withLabelValues(label='protocol', metric='tomcat_bytesreceived_total{%(queriesSelector)s}' % vars) + g.dashboard.variable.query.withDatasourceFromVariable(variable=vars.datasources.prometheus), - g.dashboard.variable.query.new('port',query='label_values(tomcat_bytesreceived_total{%(queriesSelector)s}, port)' % vars) + g.dashboard.variable.custom.selectionOptions.withMulti(true) + g.dashboard.variable.query.new('port', query='label_values(tomcat_bytesreceived_total{%(queriesSelector)s}, port)' % vars) + g.dashboard.variable.custom.selectionOptions.withMulti(true) + g.dashboard.variable.query.queryTypes.withLabelValues(label='port', metric='tomcat_bytesreceived_total{%(queriesSelector)s}' % vars) + g.dashboard.variable.query.withDatasourceFromVariable(variable=vars.datasources.prometheus), ], From fe7295f25a64a384702d5b65a529e20ddb8d7a80 Mon Sep 17 00:00:00 2001 From: schmikei Date: Wed, 22 Oct 2025 16:39:46 -0400 Subject: [PATCH 5/9] make the dashboard a tad less cookie cutter --- apache-tomcat-mixin/dashboards.libsonnet | 13 +- .../apache-tomcat-overview.json | 528 +++++++++++++++++- apache-tomcat-mixin/panels.libsonnet | 137 ++++- apache-tomcat-mixin/rows.libsonnet | 5 + .../signals/overview.libsonnet | 41 +- 5 files changed, 692 insertions(+), 32 deletions(-) diff --git a/apache-tomcat-mixin/dashboards.libsonnet b/apache-tomcat-mixin/dashboards.libsonnet index 85ce12df3..97337d17b 100644 --- a/apache-tomcat-mixin/dashboards.libsonnet +++ b/apache-tomcat-mixin/dashboards.libsonnet @@ -27,12 +27,19 @@ local logslib = import 'logs-lib/logs/main.libsonnet'; ), ) + root.applyCommon( vars.multiInstance + [ - g.dashboard.variable.query.new('protocol', - query='label_values(tomcat_bytesreceived_total{%(queriesSelector)s}, protocol)' % vars) + g.dashboard.variable.custom.selectionOptions.withMulti(true) + g.dashboard.variable.query.new( + 'protocol', + query='label_values(tomcat_bytesreceived_total{%(queriesSelector)s}, protocol)' % vars + ) + + g.dashboard.variable.custom.selectionOptions.withMulti(true) + g.dashboard.variable.query.queryTypes.withLabelValues(label='protocol', metric='tomcat_bytesreceived_total{%(queriesSelector)s}' % vars) + g.dashboard.variable.query.withDatasourceFromVariable(variable=vars.datasources.prometheus), - g.dashboard.variable.query.new('port', query='label_values(tomcat_bytesreceived_total{%(queriesSelector)s}, port)' % vars) + g.dashboard.variable.custom.selectionOptions.withMulti(true) + g.dashboard.variable.query.new( + 'port', + query='label_values(tomcat_bytesreceived_total{%(queriesSelector)s}, port)' % vars + ) + + g.dashboard.variable.custom.selectionOptions.withMulti(true) + g.dashboard.variable.query.queryTypes.withLabelValues(label='port', metric='tomcat_bytesreceived_total{%(queriesSelector)s}' % vars) + g.dashboard.variable.query.withDatasourceFromVariable(variable=vars.datasources.prometheus), ], diff --git a/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json b/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json index d618cc0c6..b275a4b50 100644 --- a/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json +++ b/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json @@ -42,6 +42,454 @@ "title": "Overview", "type": "row" }, + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "description": "The number of Apache Tomcat clusters.", + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "text", + "mode": "fixed" + }, + "unit": "none" + } + }, + "gridPos": { + "h": 6, + "w": 6, + "x": 0, + "y": 1 + }, + "id": 2, + "options": { + "colorMode": "fixed", + "graphMode": "none", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ] + } + }, + "pluginVersion": "v11.0.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "expr": "count(count by (cassandra_cluster) (jvm_memory_usage_used_bytes{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}))", + "format": "time_series", + "instant": false, + "legendFormat": "{{instance}}: Clusters", + "refId": "Number of clusters" + } + ], + "title": "Number of clusters", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "description": "The number of Apache Tomcat nodes.", + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "text", + "mode": "fixed" + }, + "unit": "none" + } + }, + "gridPos": { + "h": 6, + "w": 6, + "x": 6, + "y": 1 + }, + "id": 3, + "options": { + "colorMode": "fixed", + "graphMode": "none", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ] + } + }, + "pluginVersion": "v11.0.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "expr": "count(count by (instance) (jvm_memory_usage_used_bytes{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}))", + "format": "time_series", + "instant": false, + "legendFormat": "{{instance}}: Nodes", + "refId": "Number of nodes" + } + ], + "title": "Number of nodes", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "description": "The CPU usage of the JVM of the instance.", + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "text", + "mode": "continuous-BlYlRd" + }, + "decimals": 1, + "max": 100, + "min": 0, + "unit": "percent" + } + }, + "gridPos": { + "h": 6, + "w": 6, + "x": 12, + "y": 1 + }, + "id": 4, + "options": { + "colorMode": "value", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ] + } + }, + "pluginVersion": "v11.0.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "expr": "jvm_process_cpu_load{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"} * 100", + "format": "time_series", + "instant": false, + "legendFormat": "{{ instance }}", + "refId": "CPU usage" + } + ], + "title": "CPU usage", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "description": "The memory utilization of the JVM of the instance.", + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "text", + "mode": "continuous-BlYlRd" + }, + "decimals": 1, + "max": 100, + "min": 0, + "unit": "percent" + } + }, + "gridPos": { + "h": 6, + "w": 6, + "x": 18, + "y": 1 + }, + "id": 5, + "options": { + "colorMode": "value", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ] + } + }, + "pluginVersion": "v11.0.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "expr": "sum(jvm_memory_usage_used_bytes{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}) by (job, instance) / clamp_min(jvm_physical_memory_bytes{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}, 1) * 100", + "format": "time_series", + "instant": false, + "legendFormat": "{{instance}}: Memory utilization", + "refId": "Memory utilization" + } + ], + "title": "Memory utilization", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "description": "Overview of Apache Tomcat instances with key metrics.", + "fieldConfig": { + "defaults": { + "noValue": "NA" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Instance" + }, + "properties": [ + { + "id": "custom.filterable", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Cluster" + }, + "properties": [ + { + "id": "custom.width", + "value": 150 + }, + { + "id": "custom.displayMode", + "value": "basic" + }, + { + "id": "custom.filterable", + "value": true + }, + { + "id": "custom.noValue", + "value": "NA" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "CPU usage" + }, + "properties": [ + { + "id": "custom.width", + "value": 120 + }, + { + "id": "custom.displayMode", + "value": "basic" + }, + { + "id": "color", + "value": { + "mode": "continuous-BlYlRd" + } + }, + { + "id": "custom.fillOpacity", + "value": 30 + }, + { + "id": "custom.gradientMode", + "value": "scheme" + }, + { + "id": "custom.lineInterpolation", + "value": "smooth" + }, + { + "id": "custom.lineWidth", + "value": 2 + }, + { + "id": "custom.showPoints", + "value": "never" + }, + { + "id": "decimals", + "value": 1 + }, + { + "id": "max", + "value": 100 + }, + { + "id": "min", + "value": 0 + }, + { + "id": "unit", + "value": "percent" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Memory utilization" + }, + "properties": [ + { + "id": "custom.width", + "value": 150 + }, + { + "id": "custom.displayMode", + "value": "basic" + }, + { + "id": "color", + "value": { + "mode": "continuous-BlYlRd" + } + }, + { + "id": "custom.fillOpacity", + "value": 30 + }, + { + "id": "custom.gradientMode", + "value": "scheme" + }, + { + "id": "custom.lineInterpolation", + "value": "smooth" + }, + { + "id": "custom.lineWidth", + "value": 2 + }, + { + "id": "custom.showPoints", + "value": "never" + }, + { + "id": "decimals", + "value": 1 + }, + { + "id": "max", + "value": 100 + }, + { + "id": "min", + "value": 0 + }, + { + "id": "unit", + "value": "percent" + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 9 + }, + "id": 6, + "options": { + "enablePagination": true + }, + "pluginVersion": "v11.0.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "expr": "jvm_process_cpu_load{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"} * 100", + "format": "table", + "instant": true, + "legendFormat": "{{ instance }}", + "refId": "cpu_usage" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "expr": "sum(jvm_memory_usage_used_bytes{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}) by (job, instance) / clamp_min(jvm_physical_memory_bytes{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}, 1) * 100", + "format": "table", + "instant": true, + "legendFormat": "{{instance}}: Memory utilization", + "refId": "memory_utilization" + } + ], + "title": "Instances", + "transformations": [ + { + "id": "joinByField", + "options": { + "byField": "instance", + "mode": "outer" + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "instance", + "job 1", + "cluster", + "Value #cpu_usage", + "Value #memory_utilization" + ] + } + } + }, + { + "id": "organize", + "options": { + "includeByName": { + "Value #cpu_usage": { }, + "Value #memory_utilization": { }, + "cluster": { }, + "instance": { }, + "job 1": { } + }, + "indexByName": { + "Value #cpu_usage": 3, + "Value #memory_utilization": 4, + "cluster": 2, + "instance": 0, + "job 1": 1 + }, + "renameByName": { + "Value #cpu_usage": "CPU usage", + "Value #memory_utilization": "Memory utilization", + "cluster": "Cluster", + "instance": "Instance", + "job 1": "Job" + } + } + } + ], + "type": "table" + }, { "datasource": { "type": "prometheus", @@ -57,16 +505,48 @@ "lineWidth": 2, "showPoints": "never" }, + "min": 0, "unit": "bytes" - } + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": ".*(T|t)otal.*" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "light-orange", + "mode": "fixed" + } + }, + { + "id": "custom.fillOpacity", + "value": 0 + }, + { + "id": "custom.lineStyle", + "value": { + "dash": [ + 10, + 10 + ], + "fill": "dash" + } + } + ] + } + ] }, "gridPos": { "h": 8, "w": 12, "x": 0, - "y": 1 + "y": 17 }, - "id": 2, + "id": 7, "options": { "legend": { "calcs": [ ], @@ -102,13 +582,19 @@ "description": "The CPU usage of the JVM process.", "fieldConfig": { "defaults": { + "color": { + "mode": "continuous-BlYlRd" + }, "custom": { "fillOpacity": 30, - "gradientMode": "opacity", + "gradientMode": "scheme", "lineInterpolation": "smooth", "lineWidth": 2, "showPoints": "never" }, + "decimals": 1, + "max": 100, + "min": 0, "unit": "percent" } }, @@ -116,9 +602,9 @@ "h": 8, "w": 12, "x": 12, - "y": 1 + "y": 17 }, - "id": 3, + "id": 8, "options": { "legend": { "calcs": [ ], @@ -136,7 +622,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "jvm_process_cpu_load{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}", + "expr": "jvm_process_cpu_load{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"} * 100", "format": "time_series", "instant": false, "legendFormat": "{{ instance }}", @@ -161,16 +647,18 @@ "lineWidth": 2, "showPoints": "never" }, - "unit": "Bps" + "decimals": 1, + "noValue": "No traffic", + "unit": "bps" } }, "gridPos": { "h": 8, "w": 12, "x": 0, - "y": 9 + "y": 25 }, - "id": 4, + "id": 9, "options": { "legend": { "asTable": true, @@ -228,16 +716,18 @@ "lineWidth": 2, "showPoints": "never" }, - "unit": "Bps" + "decimals": 1, + "noValue": "No traffic", + "unit": "bps" } }, "gridPos": { "h": 8, "w": 12, "x": 12, - "y": 9 + "y": 25 }, - "id": 5, + "id": 10, "options": { "legend": { "asTable": true, @@ -302,9 +792,9 @@ "h": 8, "w": 12, "x": 0, - "y": 17 + "y": 33 }, - "id": 6, + "id": 11, "options": { "legend": { "asTable": true, @@ -393,9 +883,9 @@ "h": 8, "w": 12, "x": 12, - "y": 17 + "y": 33 }, - "id": 7, + "id": 12, "options": { "legend": { "asTable": true, @@ -459,9 +949,9 @@ "h": 8, "w": 24, "x": 0, - "y": 25 + "y": 41 }, - "id": 8, + "id": 13, "options": { "legend": { "asTable": true, diff --git a/apache-tomcat-mixin/panels.libsonnet b/apache-tomcat-mixin/panels.libsonnet index 57998abe1..589a76098 100644 --- a/apache-tomcat-mixin/panels.libsonnet +++ b/apache-tomcat-mixin/panels.libsonnet @@ -8,50 +8,169 @@ local commonlib = import 'common-lib/common/main.libsonnet'; // Overview Panels + overviewNumberOfClustersPanel: + commonlib.panels.generic.stat.info.new( + 'Number of clusters', + targets=[signals.overview.numberOfClusters.asTarget()] + ) + + g.panel.stat.standardOptions.withUnit('none') + + g.panel.stat.panelOptions.withDescription('The number of Apache Tomcat clusters.'), + + overviewNumberOfNodesPanel: + commonlib.panels.generic.stat.info.new( + 'Number of nodes', + targets=[signals.overview.numberOfNodes.asTarget()] + ) + + g.panel.stat.standardOptions.withUnit('none') + + g.panel.stat.panelOptions.withDescription('The number of Apache Tomcat nodes.'), + + overviewCPUUsageStatPanel: + commonlib.panels.cpu.stat.usage.new( + 'CPU usage', + targets=[signals.overview.cpuUsage.asTarget()] + ) + + g.panel.stat.panelOptions.withDescription('The CPU usage of the JVM of the instance.'), + + overviewMemoryUtilizationStatPanel: + commonlib.panels.memory.stat.usage.new( + 'Memory utilization', + targets=[signals.overview.memoryUtilization.asTarget()] + ) + + g.panel.stat.panelOptions.withDescription('The memory utilization of the JVM of the instance.'), + + overviewInstancesTablePanel: + commonlib.panels.generic.table.base.new( + 'Instances', + targets=[ + signals.overview.cpuUsage.asTableTarget() + + g.query.prometheus.withInstant(true) + + g.query.prometheus.withRefId('cpu_usage'), + signals.overview.memoryUtilization.asTableTarget() + + g.query.prometheus.withInstant(true) + + g.query.prometheus.withRefId('memory_utilization'), + ], + ) + { + options+: { + enablePagination: true, + }, + } + + g.panel.table.panelOptions.withDescription('Overview of Apache Tomcat instances with key metrics.') + + g.panel.table.standardOptions.withNoValue('NA') + + g.panel.table.queryOptions.withTransformationsMixin([ + { + id: 'joinByField', + options: { + byField: 'instance', + mode: 'outer', + }, + }, + { + id: 'filterFieldsByName', + options: { + include: { + names: [ + 'instance', + 'job 1', + 'cluster', + 'Value #cpu_usage', + 'Value #memory_utilization', + ], + }, + }, + }, + { + id: 'organize', + options: { + includeByName: { + instance: {}, + 'job 1': {}, + cluster: {}, + 'Value #cpu_usage': {}, + 'Value #memory_utilization': {}, + }, + indexByName: { + instance: 0, + 'job 1': 1, + cluster: 2, + 'Value #cpu_usage': 3, + 'Value #memory_utilization': 4, + }, + renameByName: { + instance: 'Instance', + 'job 1': 'Job', + cluster: 'Cluster', + 'Value #cpu_usage': 'CPU usage', + 'Value #memory_utilization': 'Memory utilization', + }, + }, + }, + ]) + + g.panel.table.standardOptions.withOverridesMixin([ + g.panel.table.fieldOverride.byName.new('Instance') + + g.panel.table.fieldOverride.byName.withProperty('custom.filterable', true), + + g.panel.table.fieldOverride.byName.new('Cluster') + + g.panel.table.fieldOverride.byName.withProperty('custom.width', 150) + + g.panel.table.fieldOverride.byName.withProperty('custom.displayMode', 'basic') + + g.panel.table.fieldOverride.byName.withProperty('custom.filterable', true) + + g.panel.table.fieldOverride.byName.withProperty('custom.noValue', 'NA'), + + + g.panel.table.fieldOverride.byName.new('CPU usage') + + g.panel.table.fieldOverride.byName.withProperty('custom.width', 120) + + g.panel.table.fieldOverride.byName.withProperty('custom.displayMode', 'basic') + + g.panel.table.fieldOverride.byName.withPropertiesFromOptions( + commonlib.panels.cpu.timeSeries.utilization.stylize() + ), + + g.panel.table.fieldOverride.byName.new('Memory utilization') + + g.panel.table.fieldOverride.byName.withProperty('custom.width', 150) + + g.panel.table.fieldOverride.byName.withProperty('custom.displayMode', 'basic') + + g.panel.table.fieldOverride.byName.withPropertiesFromOptions( + commonlib.panels.memory.timeSeries.usagePercent.stylize() + ), + ]), overviewMemoryUsagePanel: - commonlib.panels.generic.timeSeries.base.new( + commonlib.panels.memory.timeSeries.usageBytes.new( 'Memory usage', targets=[signals.overview.memoryUsage.asTarget()] ) - + g.panel.timeSeries.standardOptions.withUnit('bytes') + g.panel.timeSeries.panelOptions.withDescription('The memory usage of the JVM of the instance.'), overviewCPUUsagePanel: - commonlib.panels.generic.timeSeries.base.new( + commonlib.panels.cpu.timeSeries.utilization.new( 'CPU usage', targets=[signals.overview.cpuUsage.asTarget()] ) - + g.panel.timeSeries.standardOptions.withUnit('percent') + g.panel.timeSeries.panelOptions.withDescription('The CPU usage of the JVM process.'), overviewTrafficSentPanel: - commonlib.panels.generic.timeSeries.base.new( + commonlib.panels.network.timeSeries.traffic.new( 'Traffic sent', targets=[ signals.overview.trafficSentTotal.asTarget() { interval: '2m' }, signals.overview.trafficSentRate.asTarget() { interval: '2m' }, ] ) - + g.panel.timeSeries.standardOptions.withUnit('Bps') + g.panel.timeSeries.panelOptions.withDescription('The traffic sent for a Tomcat connector.') + g.panel.timeSeries.options.legend.withAsTable(true) + g.panel.timeSeries.options.legend.withPlacement('right'), overviewTrafficReceivedPanel: - commonlib.panels.generic.timeSeries.base.new( + commonlib.panels.network.timeSeries.traffic.new( 'Traffic received', targets=[ signals.overview.trafficReceivedTotal.asTarget() { interval: '2m' }, signals.overview.trafficReceivedRate.asTarget() { interval: '2m' }, ] ) - + g.panel.timeSeries.standardOptions.withUnit('Bps') + g.panel.timeSeries.panelOptions.withDescription('The traffic received for a Tomcat connector.') + g.panel.timeSeries.options.legend.withAsTable(true) + g.panel.timeSeries.options.legend.withPlacement('right'), overviewRequestsPanel: - commonlib.panels.generic.timeSeries.base.new( + commonlib.panels.requests.timeSeries.base.new( 'Requests', targets=[ signals.overview.requestsTotal.asTarget() { interval: '2m' }, diff --git a/apache-tomcat-mixin/rows.libsonnet b/apache-tomcat-mixin/rows.libsonnet index a10bcdc8e..8b946eaee 100644 --- a/apache-tomcat-mixin/rows.libsonnet +++ b/apache-tomcat-mixin/rows.libsonnet @@ -10,6 +10,11 @@ local g = import './g.libsonnet'; overview: g.panel.row.new('Overview') + g.panel.row.withCollapsed(value=false) + g.panel.row.withPanels([ + panels.overviewNumberOfClustersPanel { gridPos+: { w: 6, h: 6 } }, + panels.overviewNumberOfNodesPanel { gridPos+: { w: 6, h: 6 } }, + panels.overviewCPUUsageStatPanel { gridPos+: { w: 6, h: 6 } }, + panels.overviewMemoryUtilizationStatPanel { gridPos+: { w: 6, h: 6 } }, + panels.overviewInstancesTablePanel { gridPos+: { w: 24 } }, panels.overviewMemoryUsagePanel { gridPos+: { w: 12 } }, panels.overviewCPUUsagePanel { gridPos+: { w: 12 } }, panels.overviewTrafficSentPanel { gridPos+: { w: 12 } }, diff --git a/apache-tomcat-mixin/signals/overview.libsonnet b/apache-tomcat-mixin/signals/overview.libsonnet index e761f99a6..40e76b661 100644 --- a/apache-tomcat-mixin/signals/overview.libsonnet +++ b/apache-tomcat-mixin/signals/overview.libsonnet @@ -11,6 +11,45 @@ function(this) { }, signals: { + numberOfClusters: { + name: 'Number of clusters', + nameShort: 'Clusters', + type: 'raw', + description: 'The number of Apache Tomcat clusters.', + unit: 'none', + sources: { + prometheus: { + expr: 'count(count by (cassandra_cluster) (jvm_memory_usage_used_bytes{%(queriesSelector)s}))', + }, + }, + }, + + numberOfNodes: { + name: 'Number of nodes', + nameShort: 'Nodes', + type: 'raw', + description: 'The number of Apache Tomcat nodes.', + unit: 'none', + sources: { + prometheus: { + expr: 'count(count by (instance) (jvm_memory_usage_used_bytes{%(queriesSelector)s}))', + }, + }, + }, + + memoryUtilization: { + name: 'Memory utilization', + nameShort: 'Memory utilization', + type: 'raw', + description: 'The total memory utilization of the JVM of the instance.', + unit: 'percent', + sources: { + prometheus: { + expr: 'sum(jvm_memory_usage_used_bytes{%(queriesSelector)s}) by (job, instance) / clamp_min(jvm_physical_memory_bytes{%(queriesSelector)s}, 1) * 100', + }, + }, + }, + memoryUsage: { name: 'Memory usage', nameShort: 'Memory usage', @@ -33,7 +72,7 @@ function(this) { unit: 'percent', sources: { prometheus: { - expr: 'jvm_process_cpu_load{%(queriesSelector)s}', + expr: 'jvm_process_cpu_load{%(queriesSelector)s} * 100', legendCustomTemplate: legendCustomTemplate, }, }, From 092e4d46f87f45ff81d7dce4e03262a223579345 Mon Sep 17 00:00:00 2001 From: schmikei Date: Wed, 22 Oct 2025 16:47:40 -0400 Subject: [PATCH 6/9] forgot to commit latest --- .../apache-tomcat-overview.json | 128 ++++++++++++++++-- apache-tomcat-mixin/panels.libsonnet | 16 +++ apache-tomcat-mixin/rows.libsonnet | 10 +- 3 files changed, 135 insertions(+), 19 deletions(-) diff --git a/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json b/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json index b275a4b50..94a22ee33 100644 --- a/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json +++ b/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json @@ -59,7 +59,7 @@ }, "gridPos": { "h": 6, - "w": 6, + "w": 4, "x": 0, "y": 1 }, @@ -107,8 +107,8 @@ }, "gridPos": { "h": 6, - "w": 6, - "x": 6, + "w": 4, + "x": 4, "y": 1 }, "id": 3, @@ -158,8 +158,8 @@ }, "gridPos": { "h": 6, - "w": 6, - "x": 12, + "w": 4, + "x": 8, "y": 1 }, "id": 4, @@ -208,8 +208,8 @@ }, "gridPos": { "h": 6, - "w": 6, - "x": 18, + "w": 4, + "x": 12, "y": 1 }, "id": 5, @@ -238,6 +238,104 @@ "title": "Memory utilization", "type": "stat" }, + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "description": "The traffic sent for a Tomcat connector.", + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "text", + "mode": "fixed" + }, + "unit": "B/s" + } + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 16, + "y": 1 + }, + "id": 6, + "options": { + "colorMode": "fixed", + "graphMode": "none", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ] + } + }, + "pluginVersion": "v11.0.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "expr": "rate(tomcat_bytessent_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])", + "format": "time_series", + "instant": false, + "interval": "2m", + "legendFormat": "{{ instance }} - {{protocol}} - {{port}}", + "refId": "Traffic sent rate" + } + ], + "title": "Traffic sent", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "description": "The network received for a Tomcat connector", + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "text", + "mode": "fixed" + }, + "unit": "B/s" + } + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 20, + "y": 1 + }, + "id": 7, + "options": { + "colorMode": "fixed", + "graphMode": "none", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ] + } + }, + "pluginVersion": "v11.0.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "expr": "rate(tomcat_bytesreceived_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])", + "format": "time_series", + "instant": false, + "interval": "2m", + "legendFormat": "{{ instance }} - {{protocol}} - {{port}}", + "refId": "Traffic received rate" + } + ], + "title": "Traffic received", + "type": "stat" + }, { "datasource": { "type": "prometheus", @@ -409,7 +507,7 @@ "x": 0, "y": 9 }, - "id": 6, + "id": 8, "options": { "enablePagination": true }, @@ -546,7 +644,7 @@ "x": 0, "y": 17 }, - "id": 7, + "id": 9, "options": { "legend": { "calcs": [ ], @@ -604,7 +702,7 @@ "x": 12, "y": 17 }, - "id": 8, + "id": 10, "options": { "legend": { "calcs": [ ], @@ -658,7 +756,7 @@ "x": 0, "y": 25 }, - "id": 9, + "id": 11, "options": { "legend": { "asTable": true, @@ -727,7 +825,7 @@ "x": 12, "y": 25 }, - "id": 10, + "id": 12, "options": { "legend": { "asTable": true, @@ -794,7 +892,7 @@ "x": 0, "y": 33 }, - "id": 11, + "id": 13, "options": { "legend": { "asTable": true, @@ -885,7 +983,7 @@ "x": 12, "y": 33 }, - "id": 12, + "id": 14, "options": { "legend": { "asTable": true, @@ -951,7 +1049,7 @@ "x": 0, "y": 41 }, - "id": 13, + "id": 15, "options": { "legend": { "asTable": true, diff --git a/apache-tomcat-mixin/panels.libsonnet b/apache-tomcat-mixin/panels.libsonnet index 589a76098..c2b2df857 100644 --- a/apache-tomcat-mixin/panels.libsonnet +++ b/apache-tomcat-mixin/panels.libsonnet @@ -38,6 +38,22 @@ local commonlib = import 'common-lib/common/main.libsonnet'; ) + g.panel.stat.panelOptions.withDescription('The memory utilization of the JVM of the instance.'), + overviewNetworkSentStatPanel: + commonlib.panels.generic.stat.info.new( + 'Traffic sent', + targets=[signals.overview.trafficSentRate.asTarget() { interval: '2m' }] + ) + + g.panel.stat.standardOptions.withUnit('B/s') + + g.panel.stat.panelOptions.withDescription('The traffic sent for a Tomcat connector.'), + + overviewNetworkReceivedStatPanel: + commonlib.panels.generic.stat.info.new( + 'Traffic received', + targets=[signals.overview.trafficReceivedRate.asTarget() { interval: '2m' }] + ) + + g.panel.stat.standardOptions.withUnit('B/s') + + g.panel.stat.panelOptions.withDescription('The network received for a Tomcat connector'), + overviewInstancesTablePanel: commonlib.panels.generic.table.base.new( 'Instances', diff --git a/apache-tomcat-mixin/rows.libsonnet b/apache-tomcat-mixin/rows.libsonnet index 8b946eaee..d8224fbd4 100644 --- a/apache-tomcat-mixin/rows.libsonnet +++ b/apache-tomcat-mixin/rows.libsonnet @@ -10,10 +10,12 @@ local g = import './g.libsonnet'; overview: g.panel.row.new('Overview') + g.panel.row.withCollapsed(value=false) + g.panel.row.withPanels([ - panels.overviewNumberOfClustersPanel { gridPos+: { w: 6, h: 6 } }, - panels.overviewNumberOfNodesPanel { gridPos+: { w: 6, h: 6 } }, - panels.overviewCPUUsageStatPanel { gridPos+: { w: 6, h: 6 } }, - panels.overviewMemoryUtilizationStatPanel { gridPos+: { w: 6, h: 6 } }, + panels.overviewNumberOfClustersPanel { gridPos+: { w: 4, h: 6 } }, + panels.overviewNumberOfNodesPanel { gridPos+: { w: 4, h: 6 } }, + panels.overviewCPUUsageStatPanel { gridPos+: { w: 4, h: 6 } }, + panels.overviewMemoryUtilizationStatPanel { gridPos+: { w: 4, h: 6 } }, + panels.overviewNetworkSentStatPanel { gridPos+: { w: 4, h: 6 } }, + panels.overviewNetworkReceivedStatPanel { gridPos+: { w: 4, h: 6 } }, panels.overviewInstancesTablePanel { gridPos+: { w: 24 } }, panels.overviewMemoryUsagePanel { gridPos+: { w: 12 } }, panels.overviewCPUUsagePanel { gridPos+: { w: 12 } }, From da4e6832f1ca66000dc78aced8df86051bfe412b Mon Sep 17 00:00:00 2001 From: schmikei Date: Wed, 22 Oct 2025 22:11:27 -0400 Subject: [PATCH 7/9] add to the table --- .../apache-tomcat-overview.json | 149 +++++++++++++++--- apache-tomcat-mixin/panels.libsonnet | 48 ++++-- 2 files changed, 163 insertions(+), 34 deletions(-) diff --git a/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json b/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json index 94a22ee33..ba3f10cdd 100644 --- a/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json +++ b/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json @@ -243,14 +243,14 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "description": "The traffic sent for a Tomcat connector.", + "description": "The network sent for an Apache Tomcat instance.", "fieldConfig": { "defaults": { "color": { "fixedColor": "text", "mode": "fixed" }, - "unit": "B/s" + "unit": "Bps" } }, "gridPos": { @@ -284,7 +284,7 @@ "refId": "Traffic sent rate" } ], - "title": "Traffic sent", + "title": "Network sent", "type": "stat" }, { @@ -292,14 +292,14 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "description": "The network received for a Tomcat connector", + "description": "The network received for an Apache Tomcat instance.", "fieldConfig": { "defaults": { "color": { "fixedColor": "text", "mode": "fixed" }, - "unit": "B/s" + "unit": "Bps" } }, "gridPos": { @@ -333,7 +333,7 @@ "refId": "Traffic received rate" } ], - "title": "Traffic received", + "title": "Network received", "type": "stat" }, { @@ -343,9 +343,6 @@ }, "description": "Overview of Apache Tomcat instances with key metrics.", "fieldConfig": { - "defaults": { - "noValue": "NA" - }, "overrides": [ { "matcher": { @@ -365,10 +362,6 @@ "options": "Cluster" }, "properties": [ - { - "id": "custom.width", - "value": 150 - }, { "id": "custom.displayMode", "value": "basic" @@ -389,10 +382,6 @@ "options": "CPU usage" }, "properties": [ - { - "id": "custom.width", - "value": 120 - }, { "id": "custom.displayMode", "value": "basic" @@ -444,13 +433,97 @@ { "matcher": { "id": "byName", - "options": "Memory utilization" + "options": "Traffic sent rate" }, "properties": [ { - "id": "custom.width", - "value": 150 + "id": "custom.displayMode", + "value": "basic" + }, + { + "id": "custom.fillOpacity", + "value": 30 + }, + { + "id": "custom.gradientMode", + "value": "opacity" + }, + { + "id": "custom.lineInterpolation", + "value": "smooth" }, + { + "id": "custom.lineWidth", + "value": 2 + }, + { + "id": "custom.showPoints", + "value": "never" + }, + { + "id": "decimals", + "value": 1 + }, + { + "id": "noValue", + "value": "No traffic" + }, + { + "id": "unit", + "value": "bps" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Traffic received rate" + }, + "properties": [ + { + "id": "custom.displayMode", + "value": "basic" + }, + { + "id": "custom.fillOpacity", + "value": 30 + }, + { + "id": "custom.gradientMode", + "value": "opacity" + }, + { + "id": "custom.lineInterpolation", + "value": "smooth" + }, + { + "id": "custom.lineWidth", + "value": 2 + }, + { + "id": "custom.showPoints", + "value": "never" + }, + { + "id": "decimals", + "value": 1 + }, + { + "id": "noValue", + "value": "No traffic" + }, + { + "id": "unit", + "value": "bps" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Memory utilization" + }, + "properties": [ { "id": "custom.displayMode", "value": "basic" @@ -534,9 +607,33 @@ "instant": true, "legendFormat": "{{instance}}: Memory utilization", "refId": "memory_utilization" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "expr": "rate(tomcat_bytessent_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])", + "format": "table", + "instant": true, + "interval": "2m", + "legendFormat": "{{ instance }} - {{protocol}} - {{port}}", + "refId": "traffic_sent_rate" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${prometheus_datasource}" + }, + "expr": "rate(tomcat_bytesreceived_total{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\", protocol=~\"$protocol\", port=~\"$port\"}[$__rate_interval])", + "format": "table", + "instant": true, + "interval": "2m", + "legendFormat": "{{ instance }} - {{protocol}} - {{port}}", + "refId": "traffic_received_rate" } ], - "title": "Instances", + "title": "Overview instances", "transformations": [ { "id": "joinByField", @@ -554,7 +651,9 @@ "job 1", "cluster", "Value #cpu_usage", - "Value #memory_utilization" + "Value #memory_utilization", + "Value #traffic_sent_rate", + "Value #traffic_received_rate" ] } } @@ -565,6 +664,8 @@ "includeByName": { "Value #cpu_usage": { }, "Value #memory_utilization": { }, + "Value #traffic_received_rate": { }, + "Value #traffic_sent_rate": { }, "cluster": { }, "instance": { }, "job 1": { } @@ -572,6 +673,8 @@ "indexByName": { "Value #cpu_usage": 3, "Value #memory_utilization": 4, + "Value #traffic_received_rate": 6, + "Value #traffic_sent_rate": 5, "cluster": 2, "instance": 0, "job 1": 1 @@ -579,6 +682,8 @@ "renameByName": { "Value #cpu_usage": "CPU usage", "Value #memory_utilization": "Memory utilization", + "Value #traffic_received_rate": "Traffic received rate", + "Value #traffic_sent_rate": "Traffic sent rate", "cluster": "Cluster", "instance": "Instance", "job 1": "Job" diff --git a/apache-tomcat-mixin/panels.libsonnet b/apache-tomcat-mixin/panels.libsonnet index c2b2df857..4b62a6473 100644 --- a/apache-tomcat-mixin/panels.libsonnet +++ b/apache-tomcat-mixin/panels.libsonnet @@ -40,23 +40,23 @@ local commonlib = import 'common-lib/common/main.libsonnet'; overviewNetworkSentStatPanel: commonlib.panels.generic.stat.info.new( - 'Traffic sent', + 'Network sent', targets=[signals.overview.trafficSentRate.asTarget() { interval: '2m' }] ) - + g.panel.stat.standardOptions.withUnit('B/s') - + g.panel.stat.panelOptions.withDescription('The traffic sent for a Tomcat connector.'), + + g.panel.stat.standardOptions.withUnit('Bps') + + g.panel.stat.panelOptions.withDescription('The network sent for an Apache Tomcat instance.'), overviewNetworkReceivedStatPanel: commonlib.panels.generic.stat.info.new( - 'Traffic received', + 'Network received', targets=[signals.overview.trafficReceivedRate.asTarget() { interval: '2m' }] ) - + g.panel.stat.standardOptions.withUnit('B/s') - + g.panel.stat.panelOptions.withDescription('The network received for a Tomcat connector'), + + g.panel.stat.standardOptions.withUnit('Bps') + + g.panel.stat.panelOptions.withDescription('The network received for an Apache Tomcat instance.'), overviewInstancesTablePanel: commonlib.panels.generic.table.base.new( - 'Instances', + 'Overview instances', targets=[ signals.overview.cpuUsage.asTableTarget() + g.query.prometheus.withInstant(true) @@ -64,6 +64,12 @@ local commonlib = import 'common-lib/common/main.libsonnet'; signals.overview.memoryUtilization.asTableTarget() + g.query.prometheus.withInstant(true) + g.query.prometheus.withRefId('memory_utilization'), + signals.overview.trafficSentRate.asTableTarget() { interval: '2m' } + + g.query.prometheus.withInstant(true) + + g.query.prometheus.withRefId('traffic_sent_rate'), + signals.overview.trafficReceivedRate.asTableTarget() { interval: '2m' } + + g.query.prometheus.withInstant(true) + + g.query.prometheus.withRefId('traffic_received_rate'), ], ) { @@ -72,7 +78,7 @@ local commonlib = import 'common-lib/common/main.libsonnet'; }, } + g.panel.table.panelOptions.withDescription('Overview of Apache Tomcat instances with key metrics.') - + g.panel.table.standardOptions.withNoValue('NA') + // + g.panel.table.standardOptions.withNoValue('NA') + g.panel.table.queryOptions.withTransformationsMixin([ { id: 'joinByField', @@ -91,6 +97,8 @@ local commonlib = import 'common-lib/common/main.libsonnet'; 'cluster', 'Value #cpu_usage', 'Value #memory_utilization', + 'Value #traffic_sent_rate', + 'Value #traffic_received_rate', ], }, }, @@ -104,6 +112,8 @@ local commonlib = import 'common-lib/common/main.libsonnet'; cluster: {}, 'Value #cpu_usage': {}, 'Value #memory_utilization': {}, + 'Value #traffic_sent_rate': {}, + 'Value #traffic_received_rate': {}, }, indexByName: { instance: 0, @@ -111,6 +121,8 @@ local commonlib = import 'common-lib/common/main.libsonnet'; cluster: 2, 'Value #cpu_usage': 3, 'Value #memory_utilization': 4, + 'Value #traffic_sent_rate': 5, + 'Value #traffic_received_rate': 6, }, renameByName: { instance: 'Instance', @@ -118,6 +130,8 @@ local commonlib = import 'common-lib/common/main.libsonnet'; cluster: 'Cluster', 'Value #cpu_usage': 'CPU usage', 'Value #memory_utilization': 'Memory utilization', + 'Value #traffic_sent_rate': 'Traffic sent rate', + 'Value #traffic_received_rate': 'Traffic received rate', }, }, }, @@ -126,27 +140,37 @@ local commonlib = import 'common-lib/common/main.libsonnet'; g.panel.table.fieldOverride.byName.new('Instance') + g.panel.table.fieldOverride.byName.withProperty('custom.filterable', true), + g.panel.table.fieldOverride.byName.new('Cluster') - + g.panel.table.fieldOverride.byName.withProperty('custom.width', 150) + g.panel.table.fieldOverride.byName.withProperty('custom.displayMode', 'basic') + g.panel.table.fieldOverride.byName.withProperty('custom.filterable', true) + g.panel.table.fieldOverride.byName.withProperty('custom.noValue', 'NA'), - g.panel.table.fieldOverride.byName.new('CPU usage') - + g.panel.table.fieldOverride.byName.withProperty('custom.width', 120) + g.panel.table.fieldOverride.byName.withProperty('custom.displayMode', 'basic') + g.panel.table.fieldOverride.byName.withPropertiesFromOptions( commonlib.panels.cpu.timeSeries.utilization.stylize() ), + g.panel.table.fieldOverride.byName.new('Traffic sent rate') + + g.panel.table.fieldOverride.byName.withProperty('custom.displayMode', 'basic') + + g.panel.table.fieldOverride.byName.withPropertiesFromOptions( + commonlib.panels.network.timeSeries.traffic.stylize() + ), + + g.panel.table.fieldOverride.byName.new('Traffic received rate') + + g.panel.table.fieldOverride.byName.withProperty('custom.displayMode', 'basic') + + g.panel.table.fieldOverride.byName.withPropertiesFromOptions( + commonlib.panels.network.timeSeries.traffic.stylize() + ), + g.panel.table.fieldOverride.byName.new('Memory utilization') - + g.panel.table.fieldOverride.byName.withProperty('custom.width', 150) + g.panel.table.fieldOverride.byName.withProperty('custom.displayMode', 'basic') + g.panel.table.fieldOverride.byName.withPropertiesFromOptions( commonlib.panels.memory.timeSeries.usagePercent.stylize() ), ]), + overviewMemoryUsagePanel: commonlib.panels.memory.timeSeries.usageBytes.new( 'Memory usage', From 8162c161cd4aaa8659ecf99da830c99ddb967813 Mon Sep 17 00:00:00 2001 From: Keith Schmitt <32067685+schmikei@users.noreply.github.com> Date: Thu, 23 Oct 2025 10:00:47 -0400 Subject: [PATCH 8/9] Apply suggestions from code review Co-authored-by: Emily <1282515+Dasomeone@users.noreply.github.com> --- apache-tomcat-mixin/panels.libsonnet | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apache-tomcat-mixin/panels.libsonnet b/apache-tomcat-mixin/panels.libsonnet index 4b62a6473..c0099e703 100644 --- a/apache-tomcat-mixin/panels.libsonnet +++ b/apache-tomcat-mixin/panels.libsonnet @@ -56,7 +56,7 @@ local commonlib = import 'common-lib/common/main.libsonnet'; overviewInstancesTablePanel: commonlib.panels.generic.table.base.new( - 'Overview instances', + 'Instances', targets=[ signals.overview.cpuUsage.asTableTarget() + g.query.prometheus.withInstant(true) @@ -78,7 +78,6 @@ local commonlib = import 'common-lib/common/main.libsonnet'; }, } + g.panel.table.panelOptions.withDescription('Overview of Apache Tomcat instances with key metrics.') - // + g.panel.table.standardOptions.withNoValue('NA') + g.panel.table.queryOptions.withTransformationsMixin([ { id: 'joinByField', From f524a06571cd10f2404220dd4e9e386700269fef Mon Sep 17 00:00:00 2001 From: schmikei Date: Thu, 23 Oct 2025 10:05:59 -0400 Subject: [PATCH 9/9] remove cassandra_cluster label in favor of cluster label --- .../dashboards_out/apache-tomcat-overview.json | 4 ++-- apache-tomcat-mixin/signals/overview.libsonnet | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json b/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json index ba3f10cdd..d65c23fd7 100644 --- a/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json +++ b/apache-tomcat-mixin/dashboards_out/apache-tomcat-overview.json @@ -80,7 +80,7 @@ "type": "prometheus", "uid": "${prometheus_datasource}" }, - "expr": "count(count by (cassandra_cluster) (jvm_memory_usage_used_bytes{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}))", + "expr": "count(count by (cluster) (jvm_memory_usage_used_bytes{job=\"integrations/tomcat\",job=~\"$job\",cluster=~\"$cluster\",instance=~\"$instance\"}))", "format": "time_series", "instant": false, "legendFormat": "{{instance}}: Clusters", @@ -633,7 +633,7 @@ "refId": "traffic_received_rate" } ], - "title": "Overview instances", + "title": "Instances", "transformations": [ { "id": "joinByField", diff --git a/apache-tomcat-mixin/signals/overview.libsonnet b/apache-tomcat-mixin/signals/overview.libsonnet index 40e76b661..6db1d3667 100644 --- a/apache-tomcat-mixin/signals/overview.libsonnet +++ b/apache-tomcat-mixin/signals/overview.libsonnet @@ -19,7 +19,7 @@ function(this) { unit: 'none', sources: { prometheus: { - expr: 'count(count by (cassandra_cluster) (jvm_memory_usage_used_bytes{%(queriesSelector)s}))', + expr: 'count(count by (cluster) (jvm_memory_usage_used_bytes{%(queriesSelector)s}))', }, }, },