Skip to content

feat: Update Apache ActiveMQ mixin to use modern libraries #1471

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apache-activemq-mixin/.lint
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ exclusions:
target-promql-rule:
reason: "Linter does not support selector variable value as a scalar in top-k PromQL queries."
template-label-promql-rule:
reason: "Defining a selector for the value of top-k requires a predefined label that the linter considers invalid."
reason: "Defining a selector for the value of top-k requires a predefined label that the linter considers invalid."
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
prometheusAlerts+:: {
groups+: [
new(this): {
groups: [
{
name: 'apache-activemq-alerts',
rules: [
{
alert: 'ApacheActiveMQHighTopicMemoryUsage',
expr: |||
sum without (destination) (activemq_topic_memory_percent_usage{destination!~"ActiveMQ.Advisory.*"}) > %(alertsHighTopicMemoryUsage)s
||| % $._config,
sum without (destination) (activemq_topic_memory_percent_usage) > %(alertsHighTopicMemoryUsage)s
||| % this.config,
'for': '5m',
labels: {
severity: 'warning',
Expand All @@ -19,14 +19,14 @@
(
'{{ printf "%%.0f" $value }} percent of memory used by topics on {{$labels.instance}} in cluster {{$labels.activemq_cluster}}, ' +
'which is above the threshold of %(alertsHighTopicMemoryUsage)s percent.'
) % $._config,
) % this.config,
},
},
{
alert: 'ApacheActiveMQHighQueueMemoryUsage',
expr: |||
sum without (destination) (activemq_queue_memory_percent_usage) > %(alertsHighQueueMemoryUsage)s
||| % $._config,
||| % this.config,
'for': '5m',
labels: {
severity: 'warning',
Expand All @@ -37,14 +37,14 @@
(
'{{ printf "%%.0f" $value }} percent of memory used by queues on {{$labels.instance}} in cluster {{$labels.activemq_cluster}}, ' +
'which is above the threshold of %(alertsHighQueueMemoryUsage)s percent.'
) % $._config,
) % this.config,
},
},
{
alert: 'ApacheActiveMQHighStoreMemoryUsage',
expr: |||
activemq_store_usage_ratio > %(alertsHighStoreMemoryUsage)s
||| % $._config,
||| % this.config,
'for': '5m',
labels: {
severity: 'warning',
Expand All @@ -55,14 +55,14 @@
(
'{{ printf "%%.0f" $value }} percent of store memory used on {{$labels.instance}} in cluster {{$labels.activemq_cluster}}, ' +
'which is above the threshold of %(alertsHighStoreMemoryUsage)s percent.'
) % $._config,
) % this.config,
},
},
{
alert: 'ApacheActiveMQHighTemporaryMemoryUsage',
expr: |||
activemq_temp_usage_ratio > %(alertsHighTemporaryMemoryUsage)s
||| % $._config,
||| % this.config,
'for': '5m',
labels: {
severity: 'warning',
Expand All @@ -73,7 +73,7 @@
(
'{{ printf "%%.0f" $value }} percent of temporary memory used on {{$labels.instance}} in cluster {{$labels.activemq_cluster}}, ' +
'which is above the threshold of %(alertsHighTemporaryMemoryUsage)s percent.'
) % $._config,
) % this.config,
},
},
],
Expand Down
51 changes: 33 additions & 18 deletions apache-activemq-mixin/config.libsonnet
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
{
_config+:: {
enableMultiCluster: false,
activemqSelector: if self.enableMultiCluster then 'job=~"$job", cluster=~"$cluster"' else 'job=~"$job"',
activemqAlertsSelector: if self.enableMultiCluster then 'job=~"${job:regex}", cluster=~"${cluster:regex}"' else 'job=~"${job:regex}"',
dashboardTags: ['apache-activemq-mixin'],
dashboardPeriod: 'now-30m',
dashboardTimezone: 'default',
dashboardRefresh: '1m',
grafanaDashboardIDs: {
'apache-activemq-logs-overview.json': 'apache-activemq-logs',
},
local this = self,
enableMultiCluster: false,
filteringSelector: 'job=~"integrations/apache-activemq"',
groupLabels: ['job', 'cluster'],
instanceLabels: ['instance'],
activemqLabels: ['activemq_cluster'],

// alerts thresholds
alertsHighTopicMemoryUsage: 70, // %
alertsHighQueueMemoryUsage: 70, // %
alertsHighStoreMemoryUsage: 70, // %
alertsHighTemporaryMemoryUsage: 70, // %
dashboardTags: [self.uid],
legendLabels: ['instance', 'activemq_cluster'],
uid: 'apache-activemq',
dashboardNamePrefix: 'Apache ActiveMQ',

enableLokiLogs: true,
filterSelector: 'job=~"integrations/apache-activemq"',
// additional params
dashboardPeriod: 'now-30m',
dashboardTimezone: 'default',
dashboardRefresh: '1m',
metricsSource: 'prometheus',

// logs lib related
enableLokiLogs: true,
logLabels: self.groupLabels + self.instanceLabels + self.activemqLabels,
extraLogLabels: [], // Required by logs-lib
logsVolumeGroupBy: 'level',
showLogsVolume: true,

// alert thresholds
alertsHighTopicMemoryUsage: 70, // %
alertsHighQueueMemoryUsage: 70, // %
alertsHighStoreMemoryUsage: 70, // %
alertsHighTemporaryMemoryUsage: 70, // %

signals+: {
broker: (import './signals/broker.libsonnet')(this),
queues: (import './signals/queues.libsonnet')(this),
topics: (import './signals/topics.libsonnet')(this),
},
}
131 changes: 131 additions & 0 deletions apache-activemq-mixin/dashboards.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
local g = import './g.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-activemq-cluster-overview.json':
g.dashboard.new(prefix + ' overview')
+ g.dashboard.withPanels(
g.util.panel.resolveCollapsedFlagOnRows(
g.util.grid.wrapPanels(
[
this.grafana.rows.broker + g.panel.row.withCollapsed(false),
this.grafana.rows.queues + g.panel.row.withCollapsed(false),
this.grafana.rows.topics + g.panel.row.withCollapsed(false),
],
),
)
)
+ root.applyCommon(
vars.multiInstance,
uid + '_overview',
tags,
links { activemqOverview+:: {} },
annotations,
timezone,
refresh,
period
),

'apache-activemq-queue-overview.json':
g.dashboard.new(prefix + ' queues')
+ g.dashboard.withPanels(
g.util.panel.resolveCollapsedFlagOnRows(
g.util.grid.wrapPanels(
[
this.grafana.rows.queues + g.panel.row.withCollapsed(false),
]
),
)
)
+ root.applyCommon(
vars.multiInstance,
uid + '_queues',
tags,
links { activemqQueues+:: {} },
annotations,
timezone,
refresh,
period
),

'apache-activemq-topic-overview.json':
g.dashboard.new(prefix + ' topics')
+ g.dashboard.withPanels(
g.util.panel.resolveCollapsedFlagOnRows(
g.util.grid.wrapPanels(
[
this.grafana.rows.topics + g.panel.row.withCollapsed(false),
]
),
)
)
+ root.applyCommon(
vars.multiInstance,
uid + '_topics',
tags,
links { activemqTopics+:: {} },
annotations,
timezone,
refresh,
period
),

}
+
if this.config.enableLokiLogs then
{
'apache-activemq-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,
}
else {},

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)),
}
Loading
Loading