-
Notifications
You must be signed in to change notification settings - Fork 176
Modernize the apache tomcat mixin #1493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
schmikei
merged 11 commits into
grafana:master
from
schmikei:chore/tomcat-modernization
Oct 28, 2025
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
77c2d10
modernize the apache tomcat mixin
schmikei 479f607
ensure style guide is followed
schmikei 62e26d0
stylistic updates
schmikei 05757bc
make fmt
schmikei f441638
Merge branch 'master' of github.com:grafana/jsonnet-libs into chore/t…
schmikei fe7295f
make the dashboard a tad less cookie cutter
schmikei 092e4d4
forgot to commit latest
schmikei da4e683
add to the table
schmikei 8162c16
Apply suggestions from code review
schmikei f524a06
remove cassandra_cluster label in favor of cluster label
schmikei 9f8c301
Merge branch 'master' into chore/tomcat-modernization
schmikei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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), | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| 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 + [ | ||
| 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:: {} }, | ||
| 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, | ||
| this.grafana.rows.hostServlets, | ||
| ], | ||
| ), | ||
| ), | ||
| ) + root.applyCommon( | ||
| 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:: {} }, | ||
| 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 { apacheTomcatLogs:: {} }, 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)), | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm not sure if this is a linting/automatic formatting thing for a multiline bit of code, but the second line also exceeds the console width and ends up wrapped. Might be worth just folding it into one line?
Looks a bit strange in both git diff and IDEs