Skip to content

Commit c1db44c

Browse files
committed
MB-55715 Add support for configuring history_size_warning alert
Change-Id: Id6832c5d4bea70170b4342746d8c33ab42969dd3 Reviewed-on: https://review.couchbase.org/c/couchbase-cli/+/187497 Well-Formed: Restriction Checker Tested-by: Build Bot <build@couchbase.com> Reviewed-by: James Lee <james.lee@couchbase.com>
1 parent 9593657 commit c1db44c

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

cbmgr.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2323,12 +2323,14 @@ def __init__(self):
23232323
help="Alert when the disk analyzer gets stuck")
23242324
group.add_argument("--alert-memory-threshold", dest="alert_memory_threshold",
23252325
action="store_true", help="Alert when system memory usage exceeds threshold")
2326+
group.add_argument("--alert-bucket-history-size", dest="alert_bucket_history_size",
2327+
action="store_true", help="Alert when history size for a bucket reaches 90%%")
23262328

23272329
@rest_initialiser(cluster_init_check=True, version_check=True)
23282330
def execute(self, opts):
23292331
if opts.enabled == "1":
23302332
if opts.email_recipients is None:
2331-
_exit_if_errors(["--email-recipient must be set when email alerts are enabled"])
2333+
_exit_if_errors(["--email-recipients must be set when email alerts are enabled"])
23322334
if opts.email_sender is None:
23332335
_exit_if_errors(["--email-sender must be set when email alerts are enabled"])
23342336
if opts.email_host is None:
@@ -2371,6 +2373,8 @@ def execute(self, opts):
23712373
alerts.append('disk_usage_analyzer_stuck')
23722374
if opts.alert_memory_threshold:
23732375
alerts.append('memory_threshold')
2376+
if opts.alert_bucket_history_size:
2377+
alerts.append('history_size_warning')
23742378

23752379
enabled = "true"
23762380
if opts.enabled == "0":

docs/modules/cli/pages/cbcli/couchbase-cli-setting-alert.adoc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ _couchbase-cli setting-alert_ [--cluster <url>] [--username <user>] [--password
2424
[--alert-meta-overhead] [--alert-meta-oom] [--alert-write-failed]
2525
[--alert-audit-msg-dropped] [--alert-indexer-max-ram]
2626
[--alert-timestamp-drift-exceeded] [--alert-node-time] [--alert-disk-analyzer]
27-
[--alert-memory-threshold]
27+
[--alert-memory-threshold] [--alert-bucket-history-size]
2828

2929
== DESCRIPTION
3030

@@ -140,7 +140,11 @@ include::{partialsdir}/cbcli/part-common-options.adoc[]
140140

141141
--alert-memory-threshold::
142142
Specifies that an email alert should be sent when any node's system memory
143-
usage exceeds a threshold
143+
usage exceeds a threshold.
144+
145+
--alert-bucket-history-size::
146+
Specifies that an email alert should be sent when the size of history for a
147+
bucket reaches 90% of the maximum history size.
144148

145149
include::{partialsdir}/cbcli/part-host-formats.adoc[]
146150

@@ -172,7 +176,8 @@ following command below:
172176
--alert-ip-changed --alert-disk-space --alert-meta-overhead \
173177
--alert-meta-oom --alert-write-failed --alert-audit-msg-dropped \
174178
--alert-indexer-max-ram --alert-timestamp-drift-exceeded \
175-
--alert-node-time --alert-disk-analyzer --alert-memory-threshold
179+
--alert-node-time --alert-disk-analyzer --alert-memory-threshold \
180+
--alert-bucket-history-size
176181

177182
To disable email alerts run the following command:
178183

test/test_cli.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,8 @@ def setUp(self):
10991099
'--alert-auto-failover-disable', '--alert-ip-changed', '--alert-disk-space',
11001100
'--alert-meta-overhead', '--alert-meta-oom', '--alert-write-failed',
11011101
'--alert-audit-msg-dropped', '--alert-indexer-max-ram', '--alert-timestamp-drift-exceeded',
1102-
'--alert-communication-issue', '--alert-node-time', '--alert-disk-analyzer']
1102+
'--alert-communication-issue', '--alert-node-time', '--alert-disk-analyzer',
1103+
'--alert-bucket-history-size']
11031104
self.server_args = {'enterprise': True, 'init': True, 'is_admin': True}
11041105
super(TestSettingAlert, self).setUp()
11051106

@@ -1109,7 +1110,8 @@ def test_set_all_alerts(self):
11091110
'_nodes_down%2Cauto_failover_cluster_too_small%2Cauto_failover_disabled%2Cip%2Cdisk%2' +
11101111
'Coverhead%2Cep_oom_errors%2Cep_item_commit_failed%2Caudit_dropped_events%2Cindexer_ram_' +
11111112
'max_usage%2Cep_clock_cas_drift_threshold_exceeded%2Ccommunication_issue' +
1112-
'%2Ctime_out_of_sync%2Cdisk_usage_analyzer_stuck', 'enabled=false', 'emailEncrypt=false']
1113+
'%2Ctime_out_of_sync%2Cdisk_usage_analyzer_stuck%2Chistory_size_warning', 'enabled=false',
1114+
'emailEncrypt=false']
11131115

11141116
self.assertIn('POST:/settings/alerts', self.server.trace)
11151117
self.rest_parameter_match(expected_params)
@@ -1120,7 +1122,7 @@ def test_set_all_alerts_and_email(self):
11201122
'_nodes_down%2Cauto_failover_cluster_too_small%2Cauto_failover_disabled%2Cip%2Cdisk%2' +
11211123
'Coverhead%2Cep_oom_errors%2Cep_item_commit_failed%2Caudit_dropped_events%2Cindexer_ram_' +
11221124
'max_usage%2Cep_clock_cas_drift_threshold_exceeded%2Ccommunication_issue' +
1123-
'%2Ctime_out_of_sync%2Cdisk_usage_analyzer_stuck', 'enabled=true',
1125+
'%2Ctime_out_of_sync%2Cdisk_usage_analyzer_stuck%2Chistory_size_warning', 'enabled=true',
11241126
'emailEncrypt=true', 'sender=email2', 'recipients=email1', 'emailUser=emailuser',
11251127
'emailPass=emailpwd', 'emailHost=emailhost', 'emailPort=3000']
11261128

0 commit comments

Comments
 (0)