From f57df366af186b34d7efe0e0db2b1b24b64f21e8 Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Fri, 22 Jan 2021 16:42:25 -0500 Subject: [PATCH 01/28] Add version parsing and checking --- .../datadog_checks/aerospike/aerospike.py | 41 +++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index 37a46ebcc3164..f269d4c47f86d 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -40,6 +40,8 @@ ENABLED_VALUES = {'true', 'on', 'enable', 'enabled'} DISABLED_VALUES = {'false', 'off', 'disable', 'disabled'} +V5_3 = [5, 3, 0, 0] + def parse_namespace(data, namespace, secondary): idxs = [] @@ -151,17 +153,35 @@ def check(self, _): except Exception as e: self.log.debug("There were no datacenters found: %s", e) + version = self.collect_version() + if version is None: + self.log.warning("Could not determine version, assuming greater than Aerospike V5.3") + version = V5_3 + # https://www.aerospike.com/docs/reference/info/#throughput - self.collect_throughput(namespaces) + self.collect_throughput(namespaces, version) # https://www.aerospike.com/docs/reference/info/#latency - self.collect_latency(namespaces) - self.collect_version() + self.collect_latency(namespaces, version) self.service_check(SERVICE_CHECK_UP, self.OK, tags=self._tags) def collect_version(self): - version = self.get_info("build")[0] + raw_version = self.get_info("build")[0] + self.submit_version_metadata(raw_version) + + try: + parse_version = raw_version.split('.') + version = [int(p) for p in parse_version] + except Exception as e: + self.log.debug("Unable to parse version: %s", str(e)) + return None + + return version + + + @AgentCheck.metadata_entrypoint + def submit_version_metadata(self, version): self.set_metadata('version', version) def collect_info(self, command, metric_type, separator=';', required_keys=None, tags=None): @@ -259,8 +279,11 @@ def collect_datacenter(self, datacenter): continue self.send(DATACENTER_METRIC_TYPE, key, value, datacenter_tags) - def collect_latency(self, namespaces): - data = self.get_info('latency:') + def collect_latency(self, namespaces, version): + if version >= V5_3: + data = self.get_info('latencies:') + else: + data = self.get_info('latency:') ns = None @@ -322,7 +345,11 @@ def collect_latency(self, namespaces): for i in range(len(metric_names)): self.send(NAMESPACE_LATENCY_METRIC_TYPE, metric_names[i], metric_values[i], namespace_tags) - def collect_throughput(self, namespaces): + def collect_throughput(self, namespaces, version): + if version >= V5_3: + self.log.debug("`throughput` is deprecated for Aerospike > v5.3, skipping metrics") + return + data = self.get_info('throughput:') while data: From 8d60458608162fd355acc9c2d7c06929e5fae037 Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Thu, 28 Jan 2021 17:04:06 -0500 Subject: [PATCH 02/28] Add 5.3 --- aerospike/tox.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aerospike/tox.ini b/aerospike/tox.ini index cec9f39a96eb7..77878eab4ca5e 100644 --- a/aerospike/tox.ini +++ b/aerospike/tox.ini @@ -3,7 +3,7 @@ minversion = 2.0 skip_missing_interpreters = true basepython = py38 envlist = - py{27,38}-{4.9,5.0} + py{27,38}-{4.9,5.0,5.3} [testenv] ensure_default_envdir = true @@ -27,3 +27,4 @@ commands = setenv = 4.9: AEROSPIKE_VERSION=4.9.0.11 5.0: AEROSPIKE_VERSION=5.0.0.10 + 5.3: AEROSPIKE_VERSION=5.3.0.6 From 254f853fe9705be9c0f399b3269db2889503c64a Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Fri, 29 Jan 2021 14:37:38 -0500 Subject: [PATCH 03/28] Refactor metric name matching --- .../datadog_checks/aerospike/aerospike.py | 85 ++++++++++++------- 1 file changed, 54 insertions(+), 31 deletions(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index f269d4c47f86d..cb855f4ed9e3a 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -40,7 +40,7 @@ ENABLED_VALUES = {'true', 'on', 'enable', 'enabled'} DISABLED_VALUES = {'false', 'off', 'disable', 'disabled'} -V5_3 = [5, 3, 0, 0] +V5_1 = [5, 1, 0, 0] def parse_namespace(data, namespace, secondary): @@ -156,13 +156,16 @@ def check(self, _): version = self.collect_version() if version is None: self.log.warning("Could not determine version, assuming greater than Aerospike V5.3") - version = V5_3 + version = V5_1 - # https://www.aerospike.com/docs/reference/info/#throughput - self.collect_throughput(namespaces, version) - - # https://www.aerospike.com/docs/reference/info/#latency - self.collect_latency(namespaces, version) + if version < V5_1: + # https://www.aerospike.com/docs/reference/info/#throughput + self.collect_throughput(namespaces) + # https://www.aerospike.com/docs/reference/info/#latency + self.collect_latency(namespaces) + else: + # https://www.aerospike.com/docs/reference/info/#latencies + self.collect_latencies(namespaces) self.service_check(SERVICE_CHECK_UP, self.OK, tags=self._tags) @@ -177,6 +180,7 @@ def collect_version(self): self.log.debug("Unable to parse version: %s", str(e)) return None + self.log.debug("Found Aerospike version: %s", version) return version @@ -279,11 +283,48 @@ def collect_datacenter(self, datacenter): continue self.send(DATACENTER_METRIC_TYPE, key, value, datacenter_tags) - def collect_latency(self, namespaces, version): - if version >= V5_3: - data = self.get_info('latencies:') + def get_metric_name(self, line): + # match only works at the beginning + # ':' or ';' are not allowed in namespace-name: https://www.aerospike.com/docs/guide/limitations.html + ns_metric_name_match = re.match(r'{([^\}:;]+)}-(\w+):', line) + if ns_metric_name_match: + ns = ns_metric_name_match.groups()[0] + return ns_metric_name_match.groups()[1] + elif line.startswith("batch-index"): + # https://www.aerospike.com/docs/operations/monitor/latency/#batch-index + ns = None + return "batch-index" else: - data = self.get_info('latency:') + self.log.warning("Invalid data. Namespace and/or metric name not found in line: `%s`", line) + # Since the data come by pair and the order matters it's safer to return right away than submitting + # possibly wrong metrics. + return + + def collect_latencies(self, namespaces): + """ + In Aerospike 5.1+, the `latencies` command is used gives the output of latencies like so: + + histogramName_0:timeUnit,ops/sec,threshOld_0,threshOld_1,...;histogramName_1:... + + Throughput is calculated by threshOld / ops/sec value. + """ + data = self.get_info('latencies:') + + ns = None + ns_latencies = defaultdict(dict) + + while data: + line = data.pop(0) + metric_names = [] + + if not data: + break + metric_name = self.get_metric_name(line) + ns_latencies[ns].setdefault("metric_names", []).extend(metric_names) + + + def collect_latency(self, namespaces): + data = self.get_info('latency:') ns = None @@ -305,21 +346,7 @@ def collect_latency(self, namespaces, version): ns_latencies[ns].setdefault("metric_values", []).extend(metric_values) continue - # match only works at the beginning - # ':' or ';' are not allowed in namespace-name: https://www.aerospike.com/docs/guide/limitations.html - ns_metric_name_match = re.match(r'{([^\}:;]+)}-(\w+):', line) - if ns_metric_name_match: - ns = ns_metric_name_match.groups()[0] - metric_name = ns_metric_name_match.groups()[1] - elif line.startswith("batch-index"): - # https://www.aerospike.com/docs/operations/monitor/latency/#batch-index - ns = None - metric_name = "batch-index" - else: - self.log.warning("Invalid data. Namespace and/or metric name not found in line: `%s`", line) - # Since the data come by pair and the order matters it's safer to return right away than submitting - # possibly wrong metrics. - return + metric_name = self.get_metric_name(line) # need search because this isn't at the beginning ops_per_sec = re.search(r'(\w+\/\w+)', line) @@ -345,11 +372,7 @@ def collect_latency(self, namespaces, version): for i in range(len(metric_names)): self.send(NAMESPACE_LATENCY_METRIC_TYPE, metric_names[i], metric_values[i], namespace_tags) - def collect_throughput(self, namespaces, version): - if version >= V5_3: - self.log.debug("`throughput` is deprecated for Aerospike > v5.3, skipping metrics") - return - + def collect_throughput(self, namespaces): data = self.get_info('throughput:') while data: From 60b4e38562c66e8d0fd1de0a5c046735a7f12fac Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Fri, 29 Jan 2021 14:43:15 -0500 Subject: [PATCH 04/28] Include ns --- .../datadog_checks/aerospike/aerospike.py | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index cb855f4ed9e3a..599c48fa07d66 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -288,17 +288,15 @@ def get_metric_name(self, line): # ':' or ';' are not allowed in namespace-name: https://www.aerospike.com/docs/guide/limitations.html ns_metric_name_match = re.match(r'{([^\}:;]+)}-(\w+):', line) if ns_metric_name_match: - ns = ns_metric_name_match.groups()[0] - return ns_metric_name_match.groups()[1] + return ns_metric_name_match.groups()[0], ns_metric_name_match.groups()[1] elif line.startswith("batch-index"): # https://www.aerospike.com/docs/operations/monitor/latency/#batch-index - ns = None - return "batch-index" + return None, "batch-index" else: self.log.warning("Invalid data. Namespace and/or metric name not found in line: `%s`", line) # Since the data come by pair and the order matters it's safer to return right away than submitting # possibly wrong metrics. - return + return None, None def collect_latencies(self, namespaces): """ @@ -309,8 +307,6 @@ def collect_latencies(self, namespaces): Throughput is calculated by threshOld / ops/sec value. """ data = self.get_info('latencies:') - - ns = None ns_latencies = defaultdict(dict) while data: @@ -319,7 +315,12 @@ def collect_latencies(self, namespaces): if not data: break - metric_name = self.get_metric_name(line) + + ns, metric_name = self.get_metric_name(line) + if metric_name is None: + return + + ns_latencies[ns].setdefault("metric_names", []).extend(metric_names) @@ -346,7 +347,9 @@ def collect_latency(self, namespaces): ns_latencies[ns].setdefault("metric_values", []).extend(metric_values) continue - metric_name = self.get_metric_name(line) + ns, metric_name = self.get_metric_name(line) + if metric_name is None: + return # need search because this isn't at the beginning ops_per_sec = re.search(r'(\w+\/\w+)', line) From c23873244b5f837b080c6e476b2da291feb50c1a Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Fri, 29 Jan 2021 16:15:11 -0500 Subject: [PATCH 05/28] Add test --- .../datadog_checks/aerospike/aerospike.py | 19 +++++++++++----- aerospike/metadata.csv | 1 + aerospike/tests/test_unit.py | 22 +++++++++++++++++++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index 599c48fa07d66..d52fb6abc3fab 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -183,7 +183,6 @@ def collect_version(self): self.log.debug("Found Aerospike version: %s", version) return version - @AgentCheck.metadata_entrypoint def submit_version_metadata(self, version): self.set_metadata('version', version) @@ -307,12 +306,9 @@ def collect_latencies(self, namespaces): Throughput is calculated by threshOld / ops/sec value. """ data = self.get_info('latencies:') - ns_latencies = defaultdict(dict) while data: line = data.pop(0) - metric_names = [] - if not data: break @@ -320,9 +316,20 @@ def collect_latencies(self, namespaces): if metric_name is None: return + namespace_tags = ['namespace:{}'.format(ns)] if ns else [] - ns_latencies[ns].setdefault("metric_names", []).extend(metric_names) - + ops_per_sec = re.search(r'\:\w+\,(\d*\.?\d*)', line) + if ops_per_sec: + ops_per_sec_val = ops_per_sec.groups()[0] + # For backwards compatibility, the ops/sec value is `latencies` is already calculated + ops_per_sec_name = metric_name + "_" + "ops_sec" + self.send(NAMESPACE_LATENCY_METRIC_TYPE, ops_per_sec_name, ops_per_sec_val, namespace_tags) + + latencies = re.search(r'', line) + if latencies and len(latencies) == 17: + for i in range(len(latencies)): + latency_name = metric_name + '_over_' + str(i) + self.send(NAMESPACE_LATENCY_METRIC_TYPE, latency_name, latencies[i], namespace_tags) def collect_latency(self, namespaces): data = self.get_info('latency:') diff --git a/aerospike/metadata.csv b/aerospike/metadata.csv index 19d8531024b7a..da27124c3fede 100644 --- a/aerospike/metadata.csv +++ b/aerospike/metadata.csv @@ -671,6 +671,7 @@ aerospike.system_total_cpu_pct,gauge,,percent,,The percentage of CPU usage by al aerospike.system_user_cpu_pct,gauge,,percent,,The percentage of CPU usage by processes running in user mode.,0,aerospike, aerospike.time_since_rebalance,gauge,,second,,"The number of seconds since the last reclustering event, either triggered via the recluster info command or by a cluster disruption (such as a node being add/removed or a network disruption).",0,aerospike, aerospike.xdr_ship_destination_permanent_error,gauge,,error,,The number of permanent errors from the remote cluster(s) while shipping records.,0,aerospike, +aerospike.xdr_ship_destination_permanent_error,gauge,,error,,The number of permanent errors from the remote cluster(s) while shipping records.,0,aerospike, aerospike.datacenter.dc_as_open_conn,gauge,,connection,,The number of open connection to the Aerospike DC.,0,aerospike, aerospike.datacenter.dc_as_size,gauge,,,,The cluster size of the destination Aerospike DC.,0,aerospike, aerospike.datacenter.dc_http_good_locations,gauge,,,,The number of URLs that are considered healthy and being used by the change notification system.,0,aerospike, diff --git a/aerospike/tests/test_unit.py b/aerospike/tests/test_unit.py index 6c79fb028de3e..8d601e96f3d3e 100644 --- a/aerospike/tests/test_unit.py +++ b/aerospike/tests/test_unit.py @@ -112,3 +112,25 @@ def test_collect_empty_data(aggregator): check._client.info_node.return_value = 'sets/test/ci ' # from real data, there is a tab after the command check.log = mock.MagicMock() assert [] == check.get_info('sets/test/ci') + + +def test_collect_latencies_parser(aggregator): + check = AerospikeCheck('aerospike', {}, [common.INSTANCE]) + check.get_info = mock.MagicMock( + return_value=[ + 'batch-index:', + '{test}-read:msec,1.5,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00', + '{test}-write:', + '{test}-udf:msec,1.7,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00', + '{test}-query:', + ] + ) + check.collect_latencies(None) + + for metric in common.LAZY_METRICS: + if "batch_index" in metric: + aggregator.assert_metric(metric, tags=['tag:value']) + else: + aggregator.assert_metric(metric, tags=['namespace:{}'.format('test'), 'tag:value']) + + aggregator.assert_all_metrics_covered() From d60f37360995f732c70ecda2a529ab2a61b21dde Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Fri, 29 Jan 2021 17:04:33 -0500 Subject: [PATCH 06/28] Get all values --- .../datadog_checks/aerospike/aerospike.py | 25 +++++++++++-------- aerospike/tests/common.py | 2 ++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index d52fb6abc3fab..9811db1dd89b7 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -309,6 +309,7 @@ def collect_latencies(self, namespaces): while data: line = data.pop(0) + if not data: break @@ -318,18 +319,22 @@ def collect_latencies(self, namespaces): namespace_tags = ['namespace:{}'.format(ns)] if ns else [] - ops_per_sec = re.search(r'\:\w+\,(\d*\.?\d*)', line) - if ops_per_sec: - ops_per_sec_val = ops_per_sec.groups()[0] + values = re.search(r'\:\w+\,(\d*\.?\d*),([,\d+.\d+]*)', line) + if values: + ops_per_sec_val = values.groups()[0] # For backwards compatibility, the ops/sec value is `latencies` is already calculated ops_per_sec_name = metric_name + "_" + "ops_sec" - self.send(NAMESPACE_LATENCY_METRIC_TYPE, ops_per_sec_name, ops_per_sec_val, namespace_tags) - - latencies = re.search(r'', line) - if latencies and len(latencies) == 17: - for i in range(len(latencies)): - latency_name = metric_name + '_over_' + str(i) - self.send(NAMESPACE_LATENCY_METRIC_TYPE, latency_name, latencies[i], namespace_tags) + self.send(NAMESPACE_LATENCY_METRIC_TYPE, ops_per_sec_name, float(ops_per_sec_val), namespace_tags) + + bucket_vals = values.groups()[1] + if bucket_vals: + latencies = bucket_vals.split(',') + if latencies and len(latencies) == 17: + for i in range(len(latencies)): + latency_name = metric_name + '_over_' + str(i) + self.send(NAMESPACE_LATENCY_METRIC_TYPE, latency_name, latencies[i], namespace_tags) + else: + self.log.debug("Got unexpected latency buckets: %s", latencies) def collect_latency(self, namespaces): data = self.get_info('latency:') diff --git a/aerospike/tests/common.py b/aerospike/tests/common.py index 2a54b0de75ee1..c1088f5a6a813 100644 --- a/aerospike/tests/common.py +++ b/aerospike/tests/common.py @@ -51,6 +51,8 @@ 'aerospike.namespace.latency.batch_index_ops_sec', ] +LATENCIES_METRICS = [] + INSTANCE = { 'host': HOST, 'port': PORT, From 554abdf9f4dd0fc92c75e6c82deb7d8476939755 Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Fri, 29 Jan 2021 17:11:17 -0500 Subject: [PATCH 07/28] Set version condition for dc command --- .../datadog_checks/aerospike/aerospike.py | 61 +++++++++++-------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index 9811db1dd89b7..d4911c56b6a3e 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -41,6 +41,7 @@ DISABLED_VALUES = {'false', 'off', 'disable', 'disabled'} V5_1 = [5, 1, 0, 0] +V5_0 = [5, 0, 0, 0] def parse_namespace(data, namespace, secondary): @@ -143,15 +144,6 @@ def check(self, _): set_tags.extend(namespace_tags) self.collect_info('sets/{}/{}'.format(ns, s), SET_METRIC_TYPE, separator=':', tags=set_tags) - # https://www.aerospike.com/docs/reference/info/#dcs - try: - datacenters = self.get_datacenters() - - for dc in datacenters: - self.collect_datacenter(dc) - - except Exception as e: - self.log.debug("There were no datacenters found: %s", e) version = self.collect_version() if version is None: @@ -163,6 +155,17 @@ def check(self, _): self.collect_throughput(namespaces) # https://www.aerospike.com/docs/reference/info/#latency self.collect_latency(namespaces) + + if version < V5_0: + # https://www.aerospike.com/docs/reference/info/#dcs + try: + datacenters = self.get_datacenters() + + for dc in datacenters: + self.collect_datacenter(dc) + + except Exception as e: + self.log.debug("There were no datacenters found: %s", e) else: # https://www.aerospike.com/docs/reference/info/#latencies self.collect_latencies(namespaces) @@ -240,24 +243,28 @@ def get_client(self): def get_info(self, command, separator=';'): # See https://www.aerospike.com/docs/reference/info/ # Example output: command\tKEY=VALUE;KEY=VALUE;... - data = self._client.info_node(command, self._host, self._info_policies) - self.log.debug( - "Get info results for command=`%s`, host=`%s`, policies=`%s`: %s", - command, - self._host, - self._info_policies, - data, - ) - - # Get rid of command and whitespace - data = data[len(command) :].strip() - - if not separator: - return data - if not data: - return [] - - return data.split(separator) + try: + data = self._client.info_node(command, self._host, self._info_policies) + self.log.debug( + "Get info results for command=`%s`, host=`%s`, policies=`%s`: %s", + command, + self._host, + self._info_policies, + data, + ) + except Exception as e: + self.log.warning("Command `%s` was unsuccessful") + return + finally: + # Get rid of command and whitespace + data = data[len(command) :].strip() + + if not separator: + return data + if not data: + return [] + + return data.split(separator) def collect_datacenter(self, datacenter): # returned information from dc/ endpoint includes a service check: From 923fc66ccbcb46725639f06447d6b97c8fd2a519 Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Fri, 29 Jan 2021 17:15:54 -0500 Subject: [PATCH 08/28] Remove duplicate metric metadata --- aerospike/metadata.csv | 1 - 1 file changed, 1 deletion(-) diff --git a/aerospike/metadata.csv b/aerospike/metadata.csv index da27124c3fede..19d8531024b7a 100644 --- a/aerospike/metadata.csv +++ b/aerospike/metadata.csv @@ -671,7 +671,6 @@ aerospike.system_total_cpu_pct,gauge,,percent,,The percentage of CPU usage by al aerospike.system_user_cpu_pct,gauge,,percent,,The percentage of CPU usage by processes running in user mode.,0,aerospike, aerospike.time_since_rebalance,gauge,,second,,"The number of seconds since the last reclustering event, either triggered via the recluster info command or by a cluster disruption (such as a node being add/removed or a network disruption).",0,aerospike, aerospike.xdr_ship_destination_permanent_error,gauge,,error,,The number of permanent errors from the remote cluster(s) while shipping records.,0,aerospike, -aerospike.xdr_ship_destination_permanent_error,gauge,,error,,The number of permanent errors from the remote cluster(s) while shipping records.,0,aerospike, aerospike.datacenter.dc_as_open_conn,gauge,,connection,,The number of open connection to the Aerospike DC.,0,aerospike, aerospike.datacenter.dc_as_size,gauge,,,,The cluster size of the destination Aerospike DC.,0,aerospike, aerospike.datacenter.dc_http_good_locations,gauge,,,,The number of URLs that are considered healthy and being used by the change notification system.,0,aerospike, From 1c19632ceed0cfc0497536f775429497ea65013d Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Fri, 29 Jan 2021 17:26:15 -0500 Subject: [PATCH 09/28] Add metric list --- .../datadog_checks/aerospike/aerospike.py | 5 +-- aerospike/tests/common.py | 39 ++++++++++++++++++- aerospike/tests/test_unit.py | 2 +- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index d4911c56b6a3e..439c254658fb0 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -144,7 +144,6 @@ def check(self, _): set_tags.extend(namespace_tags) self.collect_info('sets/{}/{}'.format(ns, s), SET_METRIC_TYPE, separator=':', tags=set_tags) - version = self.collect_version() if version is None: self.log.warning("Could not determine version, assuming greater than Aerospike V5.3") @@ -253,7 +252,7 @@ def get_info(self, command, separator=';'): data, ) except Exception as e: - self.log.warning("Command `%s` was unsuccessful") + self.log.warning("Command `{}` was unsuccessful: {}".format(command, str(e))) return finally: # Get rid of command and whitespace @@ -338,7 +337,7 @@ def collect_latencies(self, namespaces): latencies = bucket_vals.split(',') if latencies and len(latencies) == 17: for i in range(len(latencies)): - latency_name = metric_name + '_over_' + str(i) + latency_name = metric_name + '_over_{}ms'.format(str(2 ** i)) self.send(NAMESPACE_LATENCY_METRIC_TYPE, latency_name, latencies[i], namespace_tags) else: self.log.debug("Got unexpected latency buckets: %s", latencies) diff --git a/aerospike/tests/common.py b/aerospike/tests/common.py index c1088f5a6a813..aa158f796530b 100644 --- a/aerospike/tests/common.py +++ b/aerospike/tests/common.py @@ -51,7 +51,44 @@ 'aerospike.namespace.latency.batch_index_ops_sec', ] -LATENCIES_METRICS = [] +LATENCIES_METRICS = [ + 'aerospike.namespace.latency.read_over_1ms', + 'aerospike.namespace.latency.read_over_2ms', + 'aerospike.namespace.latency.read_over_4ms', + 'aerospike.namespace.latency.read_over_8ms', + 'aerospike.namespace.latency.read_over_16ms', + 'aerospike.namespace.latency.read_over_32ms', + 'aerospike.namespace.latency.read_over_64ms', + 'aerospike.namespace.latency.read_over_128ms', + 'aerospike.namespace.latency.read_over_256ms', + 'aerospike.namespace.latency.read_over_512ms', + 'aerospike.namespace.latency.read_over_1024ms', + 'aerospike.namespace.latency.read_over_2048ms', + 'aerospike.namespace.latency.read_over_4096ms', + 'aerospike.namespace.latency.read_over_8192ms', + 'aerospike.namespace.latency.read_over_16384ms', + 'aerospike.namespace.latency.read_over_32768ms', + 'aerospike.namespace.latency.read_over_65536ms', + 'aerospike.namespace.latency.read_ops_sec', + 'aerospike.namespace.latency.udf_over_1ms', + 'aerospike.namespace.latency.udf_over_2ms', + 'aerospike.namespace.latency.udf_over_4ms', + 'aerospike.namespace.latency.udf_over_8ms', + 'aerospike.namespace.latency.udf_over_16ms', + 'aerospike.namespace.latency.udf_over_32ms', + 'aerospike.namespace.latency.udf_over_64ms', + 'aerospike.namespace.latency.udf_over_128ms', + 'aerospike.namespace.latency.udf_over_256ms', + 'aerospike.namespace.latency.udf_over_512ms', + 'aerospike.namespace.latency.udf_over_1024ms', + 'aerospike.namespace.latency.udf_over_2048ms', + 'aerospike.namespace.latency.udf_over_4096ms', + 'aerospike.namespace.latency.udf_over_8192ms', + 'aerospike.namespace.latency.udf_over_16384ms', + 'aerospike.namespace.latency.udf_over_32768ms', + 'aerospike.namespace.latency.udf_over_65536ms', + 'aerospike.namespace.latency.udf_ops_sec', +] INSTANCE = { 'host': HOST, diff --git a/aerospike/tests/test_unit.py b/aerospike/tests/test_unit.py index 8d601e96f3d3e..5b898cec106f1 100644 --- a/aerospike/tests/test_unit.py +++ b/aerospike/tests/test_unit.py @@ -127,7 +127,7 @@ def test_collect_latencies_parser(aggregator): ) check.collect_latencies(None) - for metric in common.LAZY_METRICS: + for metric in common.LATENCIES_METRICS: if "batch_index" in metric: aggregator.assert_metric(metric, tags=['tag:value']) else: From 3812cf425623b7cdac255471dd74b9a98516ee47 Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Fri, 29 Jan 2021 19:23:24 -0500 Subject: [PATCH 10/28] Add aerospike test with versioning --- .../datadog_checks/aerospike/aerospike.py | 17 +++--- aerospike/tests/common.py | 59 +++++++++++++------ aerospike/tests/test_aerospike.py | 18 ++++-- aerospike/tests/test_unit.py | 13 ++-- 4 files changed, 70 insertions(+), 37 deletions(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index 439c254658fb0..b37e78d2e492d 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -146,7 +146,7 @@ def check(self, _): version = self.collect_version() if version is None: - self.log.warning("Could not determine version, assuming greater than Aerospike V5.3") + self.log.warning("Could not determine version, using Aerospike v5.1") version = V5_1 if version < V5_1: @@ -254,16 +254,15 @@ def get_info(self, command, separator=';'): except Exception as e: self.log.warning("Command `{}` was unsuccessful: {}".format(command, str(e))) return - finally: - # Get rid of command and whitespace - data = data[len(command) :].strip() + # Get rid of command and whitespace + data = data[len(command) :].strip() - if not separator: - return data - if not data: - return [] + if not separator: + return data + if not data: + return [] - return data.split(separator) + return data.split(separator) def collect_datacenter(self, datacenter): # returned information from dc/ endpoint includes a service check: diff --git a/aerospike/tests/common.py b/aerospike/tests/common.py index aa158f796530b..29202dc38a898 100644 --- a/aerospike/tests/common.py +++ b/aerospike/tests/common.py @@ -19,9 +19,12 @@ 'tombstones', 'retransmit_all_batch_sub_dup_res', 'truncate_lut', + 'ops_sub_write_success', +] + +TPS_METRICS = [ 'tps.write', 'tps.read', - 'ops_sub_write_success', ] SET_METRICS = ['tombstones', 'memory_data_bytes', 'truncate_lut', 'objects', 'stop_writes_count'] @@ -70,24 +73,42 @@ 'aerospike.namespace.latency.read_over_32768ms', 'aerospike.namespace.latency.read_over_65536ms', 'aerospike.namespace.latency.read_ops_sec', - 'aerospike.namespace.latency.udf_over_1ms', - 'aerospike.namespace.latency.udf_over_2ms', - 'aerospike.namespace.latency.udf_over_4ms', - 'aerospike.namespace.latency.udf_over_8ms', - 'aerospike.namespace.latency.udf_over_16ms', - 'aerospike.namespace.latency.udf_over_32ms', - 'aerospike.namespace.latency.udf_over_64ms', - 'aerospike.namespace.latency.udf_over_128ms', - 'aerospike.namespace.latency.udf_over_256ms', - 'aerospike.namespace.latency.udf_over_512ms', - 'aerospike.namespace.latency.udf_over_1024ms', - 'aerospike.namespace.latency.udf_over_2048ms', - 'aerospike.namespace.latency.udf_over_4096ms', - 'aerospike.namespace.latency.udf_over_8192ms', - 'aerospike.namespace.latency.udf_over_16384ms', - 'aerospike.namespace.latency.udf_over_32768ms', - 'aerospike.namespace.latency.udf_over_65536ms', - 'aerospike.namespace.latency.udf_ops_sec', + 'aerospike.namespace.latency.write_ops_sec', + 'aerospike.namespace.latency.write_over_1024ms', + 'aerospike.namespace.latency.write_over_128ms', + 'aerospike.namespace.latency.write_over_16384ms', + 'aerospike.namespace.latency.write_over_16ms', + 'aerospike.namespace.latency.write_over_1ms', + 'aerospike.namespace.latency.write_over_2048ms', + 'aerospike.namespace.latency.write_over_256ms', + 'aerospike.namespace.latency.write_over_2ms', + 'aerospike.namespace.latency.write_over_32768ms', + 'aerospike.namespace.latency.write_over_32ms', + 'aerospike.namespace.latency.write_over_4096ms', + 'aerospike.namespace.latency.write_over_4ms', + 'aerospike.namespace.latency.write_over_512ms', + 'aerospike.namespace.latency.write_over_64ms', + 'aerospike.namespace.latency.write_over_65536ms', + 'aerospike.namespace.latency.write_over_8192ms', + 'aerospike.namespace.latency.write_over_8ms', + 'aerospike.namespace.latency.batch_index_ops_sec', + 'aerospike.namespace.latency.batch_index_over_1024ms', + 'aerospike.namespace.latency.batch_index_over_128ms', + 'aerospike.namespace.latency.batch_index_over_16384ms', + 'aerospike.namespace.latency.batch_index_over_16ms', + 'aerospike.namespace.latency.batch_index_over_1ms', + 'aerospike.namespace.latency.batch_index_over_2048ms', + 'aerospike.namespace.latency.batch_index_over_256ms', + 'aerospike.namespace.latency.batch_index_over_2ms', + 'aerospike.namespace.latency.batch_index_over_32768ms', + 'aerospike.namespace.latency.batch_index_over_32ms', + 'aerospike.namespace.latency.batch_index_over_4096ms', + 'aerospike.namespace.latency.batch_index_over_4ms', + 'aerospike.namespace.latency.batch_index_over_512ms', + 'aerospike.namespace.latency.batch_index_over_64ms', + 'aerospike.namespace.latency.batch_index_over_65536ms', + 'aerospike.namespace.latency.batch_index_over_8192ms', + 'aerospike.namespace.latency.batch_index_over_8ms', ] INSTANCE = { diff --git a/aerospike/tests/test_aerospike.py b/aerospike/tests/test_aerospike.py index e573f355b4eb7..244946224063a 100644 --- a/aerospike/tests/test_aerospike.py +++ b/aerospike/tests/test_aerospike.py @@ -1,6 +1,7 @@ # (C) Datadog, Inc. 2019-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) +import os import time import mock @@ -9,7 +10,7 @@ from datadog_checks.aerospike import AerospikeCheck from datadog_checks.dev.utils import get_metadata_metrics -from .common import LAZY_METRICS, NAMESPACE_METRICS, SET_METRICS, STATS_METRICS +from .common import LATENCIES_METRICS, LAZY_METRICS, NAMESPACE_METRICS, SET_METRICS, STATS_METRICS, TPS_METRICS @pytest.mark.usefixtures('dd_environment') @@ -62,15 +63,24 @@ def _test_check(aggregator): for metric in NAMESPACE_METRICS: aggregator.assert_metric("aerospike.namespace.{}".format(metric)) + if os.environ.get('AEROSPIKE_VERSION') == '5.3.0.6': + for metric in LATENCIES_METRICS: + aggregator.assert_metric(metric) + aggregator.assert_metric('aerospike.set.device_data_bytes') + + else: + for metric in TPS_METRICS: + aggregator.assert_metric("aerospike.namespace.{}".format(metric)) + + for metric in LAZY_METRICS: + aggregator.assert_metric(metric) + for metric in STATS_METRICS: aggregator.assert_metric("aerospike.{}".format(metric)) for metric in SET_METRICS: aggregator.assert_metric("aerospike.set.{}".format(metric)) - for metric in LAZY_METRICS: - aggregator.assert_metric(metric) - aggregator.assert_all_metrics_covered() aggregator.assert_service_check('aerospike.can_connect', AerospikeCheck.OK) diff --git a/aerospike/tests/test_unit.py b/aerospike/tests/test_unit.py index 5b898cec106f1..82b50bfbdfd3a 100644 --- a/aerospike/tests/test_unit.py +++ b/aerospike/tests/test_unit.py @@ -2,6 +2,7 @@ # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) import copy +import os import mock import pytest @@ -13,6 +14,7 @@ pytestmark = pytest.mark.unit +@pytest.mark.skipif(os.getenv('AEROSPIKE_VERSION') == '5.3.0.6', reason="Datacenter metrics not supported") def test_datacenter_metrics(aggregator): check = AerospikeCheck('aerospike', {}, [common.INSTANCE]) original_get_info = check.get_info @@ -127,10 +129,11 @@ def test_collect_latencies_parser(aggregator): ) check.collect_latencies(None) - for metric in common.LATENCIES_METRICS: - if "batch_index" in metric: - aggregator.assert_metric(metric, tags=['tag:value']) - else: - aggregator.assert_metric(metric, tags=['namespace:{}'.format('test'), 'tag:value']) + for type in ['read', 'udf']: + for i in range(17): + aggregator.assert_metric( + 'aerospike.namespace.latency.{}_over_{}ms'.format(type, str(2 ** i)), + tags=['namespace:{}'.format('test')], + ) aggregator.assert_all_metrics_covered() From fd814fa447759953a050969bb73a903db4062c9b Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Fri, 29 Jan 2021 19:33:32 -0500 Subject: [PATCH 11/28] Add ops sec metric assertion --- aerospike/tests/test_unit.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aerospike/tests/test_unit.py b/aerospike/tests/test_unit.py index 82b50bfbdfd3a..bef2260b460ad 100644 --- a/aerospike/tests/test_unit.py +++ b/aerospike/tests/test_unit.py @@ -136,4 +136,7 @@ def test_collect_latencies_parser(aggregator): tags=['namespace:{}'.format('test')], ) + aggregator.assert_metric( + 'aerospike.namespace.latency.{}_ops_sec'.format(type), tags=['namespace:{}'.format('test')] + ) aggregator.assert_all_metrics_covered() From 63367dc262e3eca12ca21b7281a72d7eb65bd0aa Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Fri, 29 Jan 2021 22:27:34 -0500 Subject: [PATCH 12/28] Fix style --- aerospike/datadog_checks/aerospike/aerospike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index b37e78d2e492d..9ab1fe92c2abb 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -252,7 +252,7 @@ def get_info(self, command, separator=';'): data, ) except Exception as e: - self.log.warning("Command `{}` was unsuccessful: {}".format(command, str(e))) + self.log.warning("Command `%s` was unsuccessful: %s" (command, str(e)) return # Get rid of command and whitespace data = data[len(command) :].strip() From eb839e1ffccf3a808bee91fb3ad238686c7e4faa Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Fri, 29 Jan 2021 22:28:02 -0500 Subject: [PATCH 13/28] Fix style --- aerospike/datadog_checks/aerospike/aerospike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index 9ab1fe92c2abb..ac8327f9edc8d 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -252,7 +252,7 @@ def get_info(self, command, separator=';'): data, ) except Exception as e: - self.log.warning("Command `%s` was unsuccessful: %s" (command, str(e)) + self.log.warning("Command `%s` was unsuccessful: %s" (command, str(e))) return # Get rid of command and whitespace data = data[len(command) :].strip() From 2610143d31344e1514ddf467b2f460c49bfbcc4c Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Fri, 29 Jan 2021 22:51:51 -0500 Subject: [PATCH 14/28] Fix test version --- aerospike/datadog_checks/aerospike/aerospike.py | 2 +- aerospike/tests/common.py | 1 + aerospike/tests/test_aerospike.py | 4 ++-- aerospike/tests/test_unit.py | 13 ++++++++----- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index ac8327f9edc8d..5c4f730e86a34 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -252,7 +252,7 @@ def get_info(self, command, separator=';'): data, ) except Exception as e: - self.log.warning("Command `%s` was unsuccessful: %s" (command, str(e))) + self.log.warning("Command `%s` was unsuccessful: %s"(command, str(e))) return # Get rid of command and whitespace data = data[len(command) :].strip() diff --git a/aerospike/tests/common.py b/aerospike/tests/common.py index 29202dc38a898..e4830f962c7a8 100644 --- a/aerospike/tests/common.py +++ b/aerospike/tests/common.py @@ -10,6 +10,7 @@ HOST = get_docker_hostname() PORT = 3000 +VERSION = os.environ.get('AEROSPIKE_VERSION') NAMESPACE_METRICS = [ 'objects', diff --git a/aerospike/tests/test_aerospike.py b/aerospike/tests/test_aerospike.py index 244946224063a..0dd78639ae758 100644 --- a/aerospike/tests/test_aerospike.py +++ b/aerospike/tests/test_aerospike.py @@ -10,7 +10,7 @@ from datadog_checks.aerospike import AerospikeCheck from datadog_checks.dev.utils import get_metadata_metrics -from .common import LATENCIES_METRICS, LAZY_METRICS, NAMESPACE_METRICS, SET_METRICS, STATS_METRICS, TPS_METRICS +from .common import LATENCIES_METRICS, LAZY_METRICS, NAMESPACE_METRICS, SET_METRICS, STATS_METRICS, TPS_METRICS, VERSION @pytest.mark.usefixtures('dd_environment') @@ -63,7 +63,7 @@ def _test_check(aggregator): for metric in NAMESPACE_METRICS: aggregator.assert_metric("aerospike.namespace.{}".format(metric)) - if os.environ.get('AEROSPIKE_VERSION') == '5.3.0.6': + if VERSION == '5.3.0.6': for metric in LATENCIES_METRICS: aggregator.assert_metric(metric) aggregator.assert_metric('aerospike.set.device_data_bytes') diff --git a/aerospike/tests/test_unit.py b/aerospike/tests/test_unit.py index bef2260b460ad..09a7f8e2f5b87 100644 --- a/aerospike/tests/test_unit.py +++ b/aerospike/tests/test_unit.py @@ -14,7 +14,7 @@ pytestmark = pytest.mark.unit -@pytest.mark.skipif(os.getenv('AEROSPIKE_VERSION') == '5.3.0.6', reason="Datacenter metrics not supported") +@pytest.mark.skipif(common.VERSION == '5.3.0.6', reason="Datacenter metrics not supported") def test_datacenter_metrics(aggregator): check = AerospikeCheck('aerospike', {}, [common.INSTANCE]) original_get_info = check.get_info @@ -33,7 +33,10 @@ def mock_get_info(command, separator=";"): check.collect_info = mock.MagicMock() check.collect_throughput = mock.MagicMock() check.collect_latency = mock.MagicMock() - check.collect_version = mock.MagicMock() + if common.VERSION == '5.3.0.6': + check.collect_version = common.VERSION.split('.') + else: + check.collect_version = mock.MagicMock() check.check(None) for metric in common.DATACENTER_METRICS: aggregator.assert_metric(metric) @@ -129,14 +132,14 @@ def test_collect_latencies_parser(aggregator): ) check.collect_latencies(None) - for type in ['read', 'udf']: + for metric_type in ['read', 'udf']: for i in range(17): aggregator.assert_metric( - 'aerospike.namespace.latency.{}_over_{}ms'.format(type, str(2 ** i)), + 'aerospike.namespace.latency.{}_over_{}ms'.format(metric_type, str(2 ** i)), tags=['namespace:{}'.format('test')], ) aggregator.assert_metric( - 'aerospike.namespace.latency.{}_ops_sec'.format(type), tags=['namespace:{}'.format('test')] + 'aerospike.namespace.latency.{}_ops_sec'.format(metric_type), tags=['namespace:{}'.format('test')] ) aggregator.assert_all_metrics_covered() From 3e1cf265997d2ca9fe316c09aec490dc921b39f8 Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Mon, 1 Feb 2021 09:59:51 -0500 Subject: [PATCH 15/28] Fix version mock --- aerospike/tests/test_aerospike.py | 1 - aerospike/tests/test_unit.py | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/aerospike/tests/test_aerospike.py b/aerospike/tests/test_aerospike.py index 0dd78639ae758..0deb422fd5372 100644 --- a/aerospike/tests/test_aerospike.py +++ b/aerospike/tests/test_aerospike.py @@ -1,7 +1,6 @@ # (C) Datadog, Inc. 2019-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -import os import time import mock diff --git a/aerospike/tests/test_unit.py b/aerospike/tests/test_unit.py index 09a7f8e2f5b87..f621d688240d5 100644 --- a/aerospike/tests/test_unit.py +++ b/aerospike/tests/test_unit.py @@ -2,7 +2,6 @@ # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) import copy -import os import mock import pytest @@ -14,7 +13,6 @@ pytestmark = pytest.mark.unit -@pytest.mark.skipif(common.VERSION == '5.3.0.6', reason="Datacenter metrics not supported") def test_datacenter_metrics(aggregator): check = AerospikeCheck('aerospike', {}, [common.INSTANCE]) original_get_info = check.get_info @@ -33,10 +31,7 @@ def mock_get_info(command, separator=";"): check.collect_info = mock.MagicMock() check.collect_throughput = mock.MagicMock() check.collect_latency = mock.MagicMock() - if common.VERSION == '5.3.0.6': - check.collect_version = common.VERSION.split('.') - else: - check.collect_version = mock.MagicMock() + check.collect_version = common.VERSION.split('.') check.check(None) for metric in common.DATACENTER_METRICS: aggregator.assert_metric(metric) From c322be9913330432f9edd448cf4cdd7d9a896671 Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Mon, 1 Feb 2021 10:18:26 -0500 Subject: [PATCH 16/28] Ensure custom tags are used --- aerospike/datadog_checks/aerospike/aerospike.py | 3 +-- aerospike/tests/test_unit.py | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index 5c4f730e86a34..1238cc3514cac 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -307,8 +307,6 @@ def collect_latencies(self, namespaces): In Aerospike 5.1+, the `latencies` command is used gives the output of latencies like so: histogramName_0:timeUnit,ops/sec,threshOld_0,threshOld_1,...;histogramName_1:... - - Throughput is calculated by threshOld / ops/sec value. """ data = self.get_info('latencies:') @@ -323,6 +321,7 @@ def collect_latencies(self, namespaces): return namespace_tags = ['namespace:{}'.format(ns)] if ns else [] + namespace_tags.extend(self._tags) values = re.search(r'\:\w+\,(\d*\.?\d*),([,\d+.\d+]*)', line) if values: diff --git a/aerospike/tests/test_unit.py b/aerospike/tests/test_unit.py index f621d688240d5..8e3e4f45ac499 100644 --- a/aerospike/tests/test_unit.py +++ b/aerospike/tests/test_unit.py @@ -131,10 +131,11 @@ def test_collect_latencies_parser(aggregator): for i in range(17): aggregator.assert_metric( 'aerospike.namespace.latency.{}_over_{}ms'.format(metric_type, str(2 ** i)), - tags=['namespace:{}'.format('test')], + tags=['namespace:{}'.format('test'), 'tag:value'], ) aggregator.assert_metric( - 'aerospike.namespace.latency.{}_ops_sec'.format(metric_type), tags=['namespace:{}'.format('test')] + 'aerospike.namespace.latency.{}_ops_sec'.format(metric_type), + tags=['namespace:{}'.format('test'), 'tag:value'] ) aggregator.assert_all_metrics_covered() From 0d3c04c225771badd1b66ed0152a4d317b34453a Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Mon, 1 Feb 2021 10:49:19 -0500 Subject: [PATCH 17/28] Remove version test mock --- aerospike/tests/test_unit.py | 1 - 1 file changed, 1 deletion(-) diff --git a/aerospike/tests/test_unit.py b/aerospike/tests/test_unit.py index 8e3e4f45ac499..ead13565fbad7 100644 --- a/aerospike/tests/test_unit.py +++ b/aerospike/tests/test_unit.py @@ -31,7 +31,6 @@ def mock_get_info(command, separator=";"): check.collect_info = mock.MagicMock() check.collect_throughput = mock.MagicMock() check.collect_latency = mock.MagicMock() - check.collect_version = common.VERSION.split('.') check.check(None) for metric in common.DATACENTER_METRICS: aggregator.assert_metric(metric) From 3ff400dc27b362b5cdca69415b29b84dc17eb834 Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Mon, 1 Feb 2021 11:17:52 -0500 Subject: [PATCH 18/28] Fix style --- aerospike/tests/test_unit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aerospike/tests/test_unit.py b/aerospike/tests/test_unit.py index ead13565fbad7..1b64827edf527 100644 --- a/aerospike/tests/test_unit.py +++ b/aerospike/tests/test_unit.py @@ -135,6 +135,6 @@ def test_collect_latencies_parser(aggregator): aggregator.assert_metric( 'aerospike.namespace.latency.{}_ops_sec'.format(metric_type), - tags=['namespace:{}'.format('test'), 'tag:value'] + tags=['namespace:{}'.format('test'), 'tag:value'], ) aggregator.assert_all_metrics_covered() From 72d2e1f8dae5470debd98c7f15892bdb6621a4ac Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Mon, 1 Feb 2021 11:30:09 -0500 Subject: [PATCH 19/28] Tag new latency metrics by bucket --- .../datadog_checks/aerospike/aerospike.py | 11 ++++- aerospike/tests/common.py | 45 ++----------------- aerospike/tests/test_unit.py | 11 ++++- 3 files changed, 21 insertions(+), 46 deletions(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index 1238cc3514cac..75b1cb0a70da3 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -335,8 +335,15 @@ def collect_latencies(self, namespaces): latencies = bucket_vals.split(',') if latencies and len(latencies) == 17: for i in range(len(latencies)): - latency_name = metric_name + '_over_{}ms'.format(str(2 ** i)) - self.send(NAMESPACE_LATENCY_METRIC_TYPE, latency_name, latencies[i], namespace_tags) + bucket = 2 ** i + tags = namespace_tags + ['bucket:{}'.format(bucket)] + latency_name = metric_name + self.send(NAMESPACE_LATENCY_METRIC_TYPE, latency_name, latencies[i], tags) + + # Also submit old latency names like `aerospike.namespace.latency.read_over_64ms` + if bucket in [1, 8, 64]: + latency_name = metric_name + '_over_{}ms'.format(str(bucket)) + self.send(NAMESPACE_LATENCY_METRIC_TYPE, latency_name, latencies[i], tags) else: self.log.debug("Got unexpected latency buckets: %s", latencies) diff --git a/aerospike/tests/common.py b/aerospike/tests/common.py index e4830f962c7a8..1b2c7799dc071 100644 --- a/aerospike/tests/common.py +++ b/aerospike/tests/common.py @@ -57,58 +57,19 @@ LATENCIES_METRICS = [ 'aerospike.namespace.latency.read_over_1ms', - 'aerospike.namespace.latency.read_over_2ms', - 'aerospike.namespace.latency.read_over_4ms', 'aerospike.namespace.latency.read_over_8ms', - 'aerospike.namespace.latency.read_over_16ms', - 'aerospike.namespace.latency.read_over_32ms', 'aerospike.namespace.latency.read_over_64ms', - 'aerospike.namespace.latency.read_over_128ms', - 'aerospike.namespace.latency.read_over_256ms', - 'aerospike.namespace.latency.read_over_512ms', - 'aerospike.namespace.latency.read_over_1024ms', - 'aerospike.namespace.latency.read_over_2048ms', - 'aerospike.namespace.latency.read_over_4096ms', - 'aerospike.namespace.latency.read_over_8192ms', - 'aerospike.namespace.latency.read_over_16384ms', - 'aerospike.namespace.latency.read_over_32768ms', - 'aerospike.namespace.latency.read_over_65536ms', + 'aerospike.namespace.latency.read', 'aerospike.namespace.latency.read_ops_sec', 'aerospike.namespace.latency.write_ops_sec', - 'aerospike.namespace.latency.write_over_1024ms', - 'aerospike.namespace.latency.write_over_128ms', - 'aerospike.namespace.latency.write_over_16384ms', - 'aerospike.namespace.latency.write_over_16ms', 'aerospike.namespace.latency.write_over_1ms', - 'aerospike.namespace.latency.write_over_2048ms', - 'aerospike.namespace.latency.write_over_256ms', - 'aerospike.namespace.latency.write_over_2ms', - 'aerospike.namespace.latency.write_over_32768ms', - 'aerospike.namespace.latency.write_over_32ms', - 'aerospike.namespace.latency.write_over_4096ms', - 'aerospike.namespace.latency.write_over_4ms', - 'aerospike.namespace.latency.write_over_512ms', 'aerospike.namespace.latency.write_over_64ms', - 'aerospike.namespace.latency.write_over_65536ms', - 'aerospike.namespace.latency.write_over_8192ms', + 'aerospike.namespace.latency.write', 'aerospike.namespace.latency.write_over_8ms', 'aerospike.namespace.latency.batch_index_ops_sec', - 'aerospike.namespace.latency.batch_index_over_1024ms', - 'aerospike.namespace.latency.batch_index_over_128ms', - 'aerospike.namespace.latency.batch_index_over_16384ms', - 'aerospike.namespace.latency.batch_index_over_16ms', 'aerospike.namespace.latency.batch_index_over_1ms', - 'aerospike.namespace.latency.batch_index_over_2048ms', - 'aerospike.namespace.latency.batch_index_over_256ms', - 'aerospike.namespace.latency.batch_index_over_2ms', - 'aerospike.namespace.latency.batch_index_over_32768ms', - 'aerospike.namespace.latency.batch_index_over_32ms', - 'aerospike.namespace.latency.batch_index_over_4096ms', - 'aerospike.namespace.latency.batch_index_over_4ms', - 'aerospike.namespace.latency.batch_index_over_512ms', 'aerospike.namespace.latency.batch_index_over_64ms', - 'aerospike.namespace.latency.batch_index_over_65536ms', - 'aerospike.namespace.latency.batch_index_over_8192ms', + 'aerospike.namespace.latency.batch_index', 'aerospike.namespace.latency.batch_index_over_8ms', ] diff --git a/aerospike/tests/test_unit.py b/aerospike/tests/test_unit.py index 1b64827edf527..f791945038e10 100644 --- a/aerospike/tests/test_unit.py +++ b/aerospike/tests/test_unit.py @@ -128,9 +128,16 @@ def test_collect_latencies_parser(aggregator): for metric_type in ['read', 'udf']: for i in range(17): + bucket = 2 ** i aggregator.assert_metric( - 'aerospike.namespace.latency.{}_over_{}ms'.format(metric_type, str(2 ** i)), - tags=['namespace:{}'.format('test'), 'tag:value'], + 'aerospike.namespace.latency.{}'.format(metric_type), + tags=['namespace:{}'.format('test'), 'tag:value', 'bucket:{}'.format(str(bucket))], + ) + + for n in [1, 8, 64]: + aggregator.assert_metric( + 'aerospike.namespace.latency.{}_over_{}ms'.format(metric_type, str(n)), + tags=['namespace:{}'.format('test'), 'tag:value', 'bucket:{}'.format(str(n))], ) aggregator.assert_metric( From b69c8735bfc24d0fd44826a5e35a5d1d4d62d89e Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Mon, 1 Feb 2021 12:05:14 -0500 Subject: [PATCH 20/28] Document new and deprecated metrics --- aerospike/metadata.csv | 63 +++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/aerospike/metadata.csv b/aerospike/metadata.csv index 19d8531024b7a..8548184a86e75 100644 --- a/aerospike/metadata.csv +++ b/aerospike/metadata.csv @@ -591,6 +591,10 @@ aerospike.namespace.latency.batch_index_ops_sec,gauge,,transaction,,The batch re aerospike.namespace.latency.batch_index_over_1ms,gauge,,transaction,,The batch read latency over 1ms.,-1,aerospike,batch read latency 1ms aerospike.namespace.latency.batch_index_over_64ms,gauge,,transaction,,The batch read latency over 64ms.,-1,aerospike,batch read latency 64ms aerospike.namespace.latency.batch_index_over_8ms,gauge,,transaction,,The batch read latency over 8ms.,-1,aerospike,batch read latency 8ms +aerospike.namespace.latency.batch_index,gauge,,transaction,,The batch latency tagged by bucket (1 to 2^16).,0,aerospike, +aerospike.namespace.latency.read,gauge,,transaction,,The read latency tagged by bucket (1 to 2^16).,0,aerospike, +aerospike.namespace.latency.write,gauge,,transaction,,The write latency tagged by bucket (1 to 2^16).,0,aerospike, +aerospike.namespace.latency.udf,gauge,,transaction,,The udf latency tagged by bucket (1 to 2^16).,0,aerospike, aerospike.namespace.migrate_order,gauge,,,,The number between 1 and 10 which determines the order namespaces are to be processed when migrating.,0,aerospike, aerospike.namespace.geo2dsphere_within.strict,gauge,,,,"An additional sanity check from Aerospike to validate whether the points returned by S2 falls under the user's query region. When set to false, Aerospike does not do this additional check and send the results as it is.",0,aerospike, aerospike.namespace.geo2dsphere_within.earth_radius_meters,gauge,,,,"Earth's radius in meters, since the workspace here is the complete earth.",0,aerospike, @@ -671,38 +675,39 @@ aerospike.system_total_cpu_pct,gauge,,percent,,The percentage of CPU usage by al aerospike.system_user_cpu_pct,gauge,,percent,,The percentage of CPU usage by processes running in user mode.,0,aerospike, aerospike.time_since_rebalance,gauge,,second,,"The number of seconds since the last reclustering event, either triggered via the recluster info command or by a cluster disruption (such as a node being add/removed or a network disruption).",0,aerospike, aerospike.xdr_ship_destination_permanent_error,gauge,,error,,The number of permanent errors from the remote cluster(s) while shipping records.,0,aerospike, -aerospike.datacenter.dc_as_open_conn,gauge,,connection,,The number of open connection to the Aerospike DC.,0,aerospike, -aerospike.datacenter.dc_as_size,gauge,,,,The cluster size of the destination Aerospike DC.,0,aerospike, -aerospike.datacenter.dc_http_good_locations,gauge,,,,The number of URLs that are considered healthy and being used by the change notification system.,0,aerospike, -aerospike.datacenter.dc_http_locations,gauge,,,,The number of URLs configured for the HTTP destination.,0,aerospike, -aerospike.datacenter.dc_ship_attempts,gauge,,record,,"The number of records that have been attempted to be shipped, but could have resulted in either success or error.",0,aerospike, -aerospike.datacenter.dc_ship_bytes,gauge,,byte,,The number of bytes shipped for this DC.,0,aerospike, -aerospike.datacenter.dc_ship_delete_success,gauge,,transaction,,The number of delete transactions that have been successfully shipped.,0,aerospike, -aerospike.datacenter.dc_ship_destination_error,gauge,,error,,The number of errors from the remote cluster(s) while shipping records for this DC.,0,aerospike, -aerospike.datacenter.dc_ship_idle_avg,gauge,,millisecond,,The average number of ms of sleep for each record being shipped.,0,aerospike, -aerospike.datacenter.dc_ship_idle_avg_pct,gauge,,percent,,The representation in percent of total time spent for dc_ship_idle_avg.,0,aerospike, -aerospike.datacenter.dc_ship_inflight_objects,gauge,,record,,The number of records that are inflight (which have been shipped but for which a response from the remote DC has not yet been received).,0,aerospike, -aerospike.datacenter.dc_ship_latency_avg,gauge,,,,The moving average of shipping latency for the specific DC.,0,aerospike, -aerospike.datacenter.dc_ship_source_error,gauge,,error,,The number of client layer errors while shipping records for this DC.,0,aerospike, -aerospike.datacenter.dc_ship_success,gauge,,record,,The number of records that have been successfully shipped.,0,aerospike, -aerospike.datacenter.dc_state,gauge,,,,The state of the DC.,0,aerospike, -aerospike.datacenter.dc_timelag,gauge,,,,The time lag for this specific DC.,0,aerospike, -aerospike.datacenter.dc_deletes_shipped,gauge,,transaction,,The number of delete transactions that have been successfully shipped. Deprecated.,0,aerospike, -aerospike.datacenter.dc_err_ship_client,gauge,,error,,"The number of client layer errors while shipping records for this DC. Errors include timeout, bad network fd, etc.",0,aerospike, -aerospike.datacenter.dc_err_ship_server,gauge,,error,,"The number of errors from the remote cluster(s) while shipping records for this DC. Errors include out-of-space, key-busy, etc.",0,aerospike, -aerospike.datacenter.dc_esmt_bytes_shipped,gauge,,byte,,The number of bytes shipped for this DC. Deprecated.,0,aerospike, -aerospike.datacenter.dc_latency_avg_ship,gauge,,,,The moving average of shipping latency for the specific DC. Deprecated.,0,aerospike, -aerospike.datacenter.dc_open_conn,gauge,,connection,,"The number of open connection to the DC. If the DC accepts pipeline writes, there will be 64 connections per destination node.",0,aerospike, -aerospike.datacenter.dc_recs_inflight,gauge,,record,,The number of records that are inflight (which have been shipped but for which a response from the remote DC has not yet been received). Deprecated.,0,aerospike, -aerospike.datacenter.dc_recs_shipped,gauge,,record,,"The number of records that have been attempted to be shipped, but could have resulted in either success or error. Deprecated.",0,aerospike, -aerospike.datacenter.dc_recs_shipped_ok,gauge,,record,,The number of records that have been successfully shipped. Deprecated.,0,aerospike, -aerospike.datacenter.dc_remote_ship_avg_sleep,gauge,,millisecond,,The average number of ms of sleep for each record being shipped. Deprecated.,0,aerospike, -aerospike.datacenter.dc_size,gauge,,,,The cluster size of the destination DC.,0,aerospike, -aerospike.namespace.tps.read,gauge,,,,The throughput performace of reads,0,aerospike, -aerospike.namespace.tps.write,gauge,,,,The throughput performace of writes,0,aerospike, +aerospike.datacenter.dc_as_open_conn,gauge,,connection,,The number of open connection to the Aerospike DC. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_as_size,gauge,,,,The cluster size of the destination Aerospike DC. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_http_good_locations,gauge,,,,The number of URLs that are considered healthy and being used by the change notification system. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_http_locations,gauge,,,,The number of URLs configured for the HTTP destination. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_ship_attempts,gauge,,record,,"The number of records that have been attempted to be shipped, but could have resulted in either success or error. [Removed in 5.0.0]",0,aerospike, +aerospike.datacenter.dc_ship_bytes,gauge,,byte,,The number of bytes shipped for this DC. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_ship_delete_success,gauge,,transaction,,The number of delete transactions that have been successfully shipped. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_ship_destination_error,gauge,,error,,The number of errors from the remote cluster(s) while shipping records for this DC. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_ship_idle_avg,gauge,,millisecond,,The average number of ms of sleep for each record being shipped. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_ship_idle_avg_pct,gauge,,percent,,The representation in percent of total time spent for dc_ship_idle_avg. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_ship_inflight_objects,gauge,,record,,The number of records that are inflight (which have been shipped but for which a response from the remote DC has not yet been received). [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_ship_latency_avg,gauge,,,,The moving average of shipping latency for the specific DC. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_ship_source_error,gauge,,error,,The number of client layer errors while shipping records for this DC. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_ship_success,gauge,,record,,The number of records that have been successfully shipped. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_state,gauge,,,,The state of the DC. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_timelag,gauge,,,,The time lag for this specific DC. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_deletes_shipped,gauge,,transaction,,The number of delete transactions that have been successfully shipped. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_err_ship_client,gauge,,error,,"The number of client layer errors while shipping records for this DC. Errors include timeout [Removed in 5.0.0], bad network fd, etc.",0,aerospike, +aerospike.datacenter.dc_err_ship_server,gauge,,error,,"The number of errors from the remote cluster(s) while shipping records for this DC. Errors include out-of-space, key-busy, etc. [Removed in 5.0.0]",0,aerospike, +aerospike.datacenter.dc_esmt_bytes_shipped,gauge,,byte,,The number of bytes shipped for this DC. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_latency_avg_ship,gauge,,,,The moving average of shipping latency for the specific DC. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_open_conn,gauge,,connection,,"The number of open connection to the DC. If the DC accepts pipeline writes, there will be 64 connections per destination node. [Removed in 5.0.0]",0,aerospike, +aerospike.datacenter.dc_recs_inflight,gauge,,record,,The number of records that are inflight (which have been shipped but for which a response from the remote DC has not yet been received). [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_recs_shipped,gauge,,record,,"The number of records that have been attempted to be shipped, but could have resulted in either success or error. [Removed in 5.0.0]",0,aerospike, +aerospike.datacenter.dc_recs_shipped_ok,gauge,,record,,The number of records that have been successfully shipped. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_remote_ship_avg_sleep,gauge,,millisecond,,The average number of ms of sleep for each record being shipped. [Removed in 5.0.0],0,aerospike, +aerospike.datacenter.dc_size,gauge,,,,The cluster size of the destination DC. [Removed in 5.0.0],0,aerospike, +aerospike.namespace.tps.read,gauge,,,,The throughput performace of reads. [Removed in 5.1.0],0,aerospike, +aerospike.namespace.tps.write,gauge,,,,The throughput performace of writes. [Removed in 5.1.0],0,aerospike, aerospike.set.memory_data_bytes,gauge,,byte,,The memory used by this set for the data part (does not include index part). Value will be 0 if data is not stored in memory. ,0,aerospike, aerospike.set.objects,gauge,,record,,The total number of objects (master and all replicas) in this set on this node.,0,aerospike,Set Objects aerospike.set.stop_writes_count,gauge,,,,The total count this set has hit stop_writes,0,aerospike, +aerospike.set.device_data_bytes,gauge,,byte,,The device storage used by data (master and proles) excluding primary index.,0,aerospike, aerospike.sindex.keys,gauge,,,,The number of secondary keys for this secondary index.,0,aerospike, aerospike.sindex.entries,gauge,,,,Th number of secondary index entries for this secondary index. This is the number of records that have been indexed by this secondary index.,0,aerospike, aerospike.sindex.ibtr_memory_used,gauge,,byte,,The amount of memory the secondary index is consuming for the keys,0,aerospike,Sindex Index Memory Used From 78a0ffdae382bc9a95000081bbbbb30ca133fe3d Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Mon, 1 Feb 2021 12:17:14 -0500 Subject: [PATCH 21/28] Lower log level when version not found --- aerospike/datadog_checks/aerospike/aerospike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index 75b1cb0a70da3..81ded0d52948d 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -146,7 +146,7 @@ def check(self, _): version = self.collect_version() if version is None: - self.log.warning("Could not determine version, using Aerospike v5.1") + self.log.debug("Could not determine version, using Aerospike v5.1") version = V5_1 if version < V5_1: From 98cde01ca12e5a108bf0174ff04fa788d42ee21d Mon Sep 17 00:00:00 2001 From: Christine Chen Date: Mon, 1 Feb 2021 13:50:05 -0500 Subject: [PATCH 22/28] Update aerospike/datadog_checks/aerospike/aerospike.py Co-authored-by: Ofek Lev --- aerospike/datadog_checks/aerospike/aerospike.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index 81ded0d52948d..54d9cb4e1819b 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -40,8 +40,8 @@ ENABLED_VALUES = {'true', 'on', 'enable', 'enabled'} DISABLED_VALUES = {'false', 'off', 'disable', 'disabled'} -V5_1 = [5, 1, 0, 0] -V5_0 = [5, 0, 0, 0] +V5_1 = (5, 1, 0, 0) +V5_0 = (5, 0, 0, 0) def parse_namespace(data, namespace, secondary): From d6af6018784f94a2317d1fa188725ea709b619e1 Mon Sep 17 00:00:00 2001 From: Christine Chen Date: Mon, 1 Feb 2021 13:50:11 -0500 Subject: [PATCH 23/28] Update aerospike/datadog_checks/aerospike/aerospike.py Co-authored-by: Ofek Lev --- aerospike/datadog_checks/aerospike/aerospike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index 54d9cb4e1819b..2f4f471e046d7 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -146,7 +146,7 @@ def check(self, _): version = self.collect_version() if version is None: - self.log.debug("Could not determine version, using Aerospike v5.1") + self.log.debug("Could not determine version, assuming Aerospike v5.1") version = V5_1 if version < V5_1: From 7ba11369e28995d3c8abdf66883f96469dedf889 Mon Sep 17 00:00:00 2001 From: Christine Chen Date: Mon, 1 Feb 2021 13:50:23 -0500 Subject: [PATCH 24/28] Update aerospike/datadog_checks/aerospike/aerospike.py Co-authored-by: Ofek Lev --- aerospike/datadog_checks/aerospike/aerospike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index 2f4f471e046d7..8bd2948c7c699 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -290,7 +290,7 @@ def collect_datacenter(self, datacenter): def get_metric_name(self, line): # match only works at the beginning # ':' or ';' are not allowed in namespace-name: https://www.aerospike.com/docs/guide/limitations.html - ns_metric_name_match = re.match(r'{([^\}:;]+)}-(\w+):', line) + ns_metric_name_match = re.match(r'\{([^}:;]+)\}-(\w+):', line) if ns_metric_name_match: return ns_metric_name_match.groups()[0], ns_metric_name_match.groups()[1] elif line.startswith("batch-index"): From 1a24cd20dc3e6829936df00c18c64985698fa7d9 Mon Sep 17 00:00:00 2001 From: Christine Chen Date: Mon, 1 Feb 2021 13:50:35 -0500 Subject: [PATCH 25/28] Update aerospike/datadog_checks/aerospike/aerospike.py Co-authored-by: Ofek Lev --- aerospike/datadog_checks/aerospike/aerospike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index 8bd2948c7c699..853a51bbc0795 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -323,7 +323,7 @@ def collect_latencies(self, namespaces): namespace_tags = ['namespace:{}'.format(ns)] if ns else [] namespace_tags.extend(self._tags) - values = re.search(r'\:\w+\,(\d*\.?\d*),([,\d+.\d+]*)', line) + values = re.search(r':\w+,(\d*\.?\d*),([,\d+.\d+]*)', line) if values: ops_per_sec_val = values.groups()[0] # For backwards compatibility, the ops/sec value is `latencies` is already calculated From 777a1413c8079081bc623b2a1974cf512ea6165c Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Mon, 1 Feb 2021 13:56:49 -0500 Subject: [PATCH 26/28] Update links --- .../datadog_checks/aerospike/aerospike.py | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index 853a51bbc0795..32f6362ccdf93 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -150,13 +150,10 @@ def check(self, _): version = V5_1 if version < V5_1: - # https://www.aerospike.com/docs/reference/info/#throughput self.collect_throughput(namespaces) - # https://www.aerospike.com/docs/reference/info/#latency self.collect_latency(namespaces) if version < V5_0: - # https://www.aerospike.com/docs/reference/info/#dcs try: datacenters = self.get_datacenters() @@ -166,7 +163,6 @@ def check(self, _): except Exception as e: self.log.debug("There were no datacenters found: %s", e) else: - # https://www.aerospike.com/docs/reference/info/#latencies self.collect_latencies(namespaces) self.service_check(SERVICE_CHECK_UP, self.OK, tags=self._tags) @@ -219,6 +215,11 @@ def get_namespaces(self): return namespaces def get_datacenters(self): + """ + https://www.aerospike.com/docs/reference/info/#dcs + + Note: Deprecated in Aerospike 5.0.0 + """ datacenters = self.get_info('dcs') if self._required_datacenters: @@ -304,9 +305,9 @@ def get_metric_name(self, line): def collect_latencies(self, namespaces): """ - In Aerospike 5.1+, the `latencies` command is used gives the output of latencies like so: + The `latencies` command is introduced in Aerospike 5.1+ and replaces latency and throughput - histogramName_0:timeUnit,ops/sec,threshOld_0,threshOld_1,...;histogramName_1:... + https://www.aerospike.com/docs/reference/info/#latencies """ data = self.get_info('latencies:') @@ -348,6 +349,11 @@ def collect_latencies(self, namespaces): self.log.debug("Got unexpected latency buckets: %s", latencies) def collect_latency(self, namespaces): + """ + https://www.aerospike.com/docs/reference/info/#latency + + Note: Deprecated in Aerospike 5.2 + """ data = self.get_info('latency:') ns = None @@ -399,6 +405,11 @@ def collect_latency(self, namespaces): self.send(NAMESPACE_LATENCY_METRIC_TYPE, metric_names[i], metric_values[i], namespace_tags) def collect_throughput(self, namespaces): + """ + https://www.aerospike.com/docs/reference/info/#throughput + + Note: Deprecated in Aerospike 5.1 + """ data = self.get_info('throughput:') while data: From de1765dea80a7545cf8ac01b67b251ed7ed16312 Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Mon, 1 Feb 2021 14:20:30 -0500 Subject: [PATCH 27/28] Use tuple for version --- aerospike/datadog_checks/aerospike/aerospike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index 32f6362ccdf93..659833b160bb5 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -173,7 +173,7 @@ def collect_version(self): try: parse_version = raw_version.split('.') - version = [int(p) for p in parse_version] + version = (int(p) for p in parse_version) except Exception as e: self.log.debug("Unable to parse version: %s", str(e)) return None From e7a43bc3742b61021e0248e461018b47f6af002a Mon Sep 17 00:00:00 2001 From: ChristineTChen Date: Mon, 1 Feb 2021 14:36:21 -0500 Subject: [PATCH 28/28] Use tuple --- aerospike/datadog_checks/aerospike/aerospike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aerospike/datadog_checks/aerospike/aerospike.py b/aerospike/datadog_checks/aerospike/aerospike.py index 659833b160bb5..40b7094753583 100644 --- a/aerospike/datadog_checks/aerospike/aerospike.py +++ b/aerospike/datadog_checks/aerospike/aerospike.py @@ -173,7 +173,7 @@ def collect_version(self): try: parse_version = raw_version.split('.') - version = (int(p) for p in parse_version) + version = tuple(int(p) for p in parse_version) except Exception as e: self.log.debug("Unable to parse version: %s", str(e)) return None