From 157155127a26345d14cb2c5153726e913106b0f9 Mon Sep 17 00:00:00 2001 From: Julia Simon <611228+hithwen@users.noreply.github.com> Date: Fri, 7 Aug 2020 12:41:52 +0200 Subject: [PATCH 1/2] Add config specs --- .../assets/configuration/spec.yaml | 61 +++++++++++++++++ .../cassandra_nodetool/data/conf.yaml.example | 67 +++++++++++++------ cassandra_nodetool/manifest.json | 3 + cassandra_nodetool/setup.py | 4 +- 4 files changed, 115 insertions(+), 20 deletions(-) create mode 100644 cassandra_nodetool/assets/configuration/spec.yaml diff --git a/cassandra_nodetool/assets/configuration/spec.yaml b/cassandra_nodetool/assets/configuration/spec.yaml new file mode 100644 index 0000000000000..2f0f7e191b99c --- /dev/null +++ b/cassandra_nodetool/assets/configuration/spec.yaml @@ -0,0 +1,61 @@ +name: Cassandra Nodetool +files: +- name: cassandra_nodetool.yaml + options: + - template: init_config + options: + - name: nodetool + description: | + command or path to nodetool (e.g. /usr/bin/nodetool or docker exec container nodetool) + can be overwritten on an instance + Note: Agent v6.11+ on Windows runs as an unprivileged user (`ddagentuser`). That user needs to be granted + access to the nodetool installation directory for the check to work. + The nodetool installation also sets some environment variables (e.g. `CASSANDRA_HOME` and `DSCINSTALLDIR`), + but sets them as variables only for the user doing the nodetool installation. Those environment variables should + be set as system-wide variables. + required: true + value: + type: string + example: nodetool + - template: init_config/default + - template: instances + options: + - name: keyspaces + description: | + The list of keyspaces to monitor. + An empty list results in no metrics being sent. + required: true + value: + type: array + items: + type: string + - name: host + description: Host that the Datadog Cassandra Nodetool check connects to. + value: + type: string + example: localhost + - name: port + description: The port JMX is listening to for connections. + value: + type: integer + example: 7199 + - name: username + description: | + Username from the credentials needed to connect to the host. These are the credentials for the JMX server. + For the check to work, this user must have a read/write access so that the Datadog Cassandra nodetool + check can execute the `status` command + value: + type: string + - name: password + description: | + Username from the credentials needed to connect to the host. These are the credentials for the JMX server. + For the check to work, this user must have a read/write access so that the Datadog Cassandra Nodetool + check can execute the `status` command + value: + type: string + - name: ssl + description: Whether or not to use the --ssl parameter to nodetool to initiate a connection over SSL to the JMX server. + value: + type: boolean + example: false + - template: instances/default diff --git a/cassandra_nodetool/datadog_checks/cassandra_nodetool/data/conf.yaml.example b/cassandra_nodetool/datadog_checks/cassandra_nodetool/data/conf.yaml.example index 110f5f8ea9f53..966df454b95d1 100644 --- a/cassandra_nodetool/datadog_checks/cassandra_nodetool/data/conf.yaml.example +++ b/cassandra_nodetool/datadog_checks/cassandra_nodetool/data/conf.yaml.example @@ -1,32 +1,41 @@ +## All options defined here are available to all instances. +# init_config: - ## @param nodetool - string - required - ## command or path to nodetool (e.g. /usr/bin/nodetool or docker exec container nodetool) - ## can be overwritten on an instance - ## Note: Agent v6.11+ on Windows runs as an unprivileged user (`ddagentuser`). That user needs to be granted - ## access to the nodetool installation directory for the check to work. - ## The nodetool installation also sets some environment variables (e.g. `CASSANDRA_HOME` and `DSCINSTALLDIR`), - ## but sets them as variables only for the user doing the nodetool installation. Those environment variables should - ## be set as system-wide variables. - # - # nodetool: /usr/bin/nodetool + ## @param nodetool - string - required + ## command or path to nodetool (e.g. /usr/bin/nodetool or docker exec container nodetool) + ## can be overwritten on an instance + ## Note: Agent v6.11+ on Windows runs as an unprivileged user (`ddagentuser`). That user needs to be granted + ## access to the nodetool installation directory for the check to work. + ## The nodetool installation also sets some environment variables (e.g. `CASSANDRA_HOME` and `DSCINSTALLDIR`), + ## but sets them as variables only for the user doing the nodetool installation. Those environment variables should + ## be set as system-wide variables. + # + nodetool: nodetool + + ## @param service - string - optional + ## Attach the tag `service:` to every metric, event, and service check emitted by this integration. + ## + ## Additionally, this sets the default `service` for every log source. + # + # service: +## Every instance is scheduled independent of the others. +# instances: - ## @param keyspaces - list of string - required + ## @param keyspaces - list of strings - required ## The list of keyspaces to monitor. ## An empty list results in no metrics being sent. # - - keyspaces: - - - - + - keyspaces: [] - ## @param host - string - optional + ## @param host - string - optional - default: localhost ## Host that the Datadog Cassandra Nodetool check connects to. # # host: localhost - ## @param port - integer - optional + ## @param port - integer - optional - default: 7199 ## The port JMX is listening to for connections. # # port: 7199 @@ -50,11 +59,31 @@ instances: # # ssl: false - ## @param tags - list of key:value element - optional - ## List of tags to attach to every metric, event and service check emitted by this integration. + ## @param tags - list of strings - optional + ## A list of tags to attach to every metric and service check emitted by this instance. ## - ## Learn more about tagging: https://docs.datadoghq.com/tagging/ + ## Learn more about tagging at https://docs.datadoghq.com/tagging # # tags: # - : # - : + + ## @param service - string - optional + ## Attach the tag `service:` to every metric, event, and service check emitted by this integration. + ## + ## Overrides any `service` defined in the `init_config` section. + # + # service: + + ## @param min_collection_interval - number - optional - default: 15 + ## This changes the collection interval of the check. For more information, see: + ## https://docs.datadoghq.com/developers/write_agent_check/#collection-interval + # + # min_collection_interval: 15 + + ## @param empty_default_hostname - boolean - optional - default: false + ## This forces the check to send metrics with no hostname. + ## + ## This is useful for cluster-level checks. + # + # empty_default_hostname: false diff --git a/cassandra_nodetool/manifest.json b/cassandra_nodetool/manifest.json index 9a051cf4681dd..fb3c66929d35c 100644 --- a/cassandra_nodetool/manifest.json +++ b/cassandra_nodetool/manifest.json @@ -22,6 +22,9 @@ "type": "check", "integration_id": "cassandra-nodetool", "assets": { + "configuration": { + "spec": "assets/configuration/spec.yaml" + }, "monitors": {}, "dashboards": {}, "service_checks": "assets/service_checks.json", diff --git a/cassandra_nodetool/setup.py b/cassandra_nodetool/setup.py index 92615a8ab5428..be60bfa5c5026 100644 --- a/cassandra_nodetool/setup.py +++ b/cassandra_nodetool/setup.py @@ -28,7 +28,7 @@ def get_dependencies(): return f.readlines() -CHECKS_BASE_REQ = 'datadog_checks_base' +CHECKS_BASE_REQ = 'datadog_checks_base>=11.0.0' setup( @@ -54,6 +54,8 @@ def get_dependencies(): 'License :: OSI Approved :: BSD License', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.8', ], # The package we're going to ship packages=['datadog_checks.cassandra_nodetool'], From 26925baaff0868c7a32bba61891cfda2901c727d Mon Sep 17 00:00:00 2001 From: Julia <611228+hithwen@users.noreply.github.com> Date: Tue, 18 Aug 2020 15:16:09 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Kari Halsted <12926135+kayayarai@users.noreply.github.com> --- .../assets/configuration/spec.yaml | 18 +++++++++--------- .../cassandra_nodetool/data/conf.yaml.example | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cassandra_nodetool/assets/configuration/spec.yaml b/cassandra_nodetool/assets/configuration/spec.yaml index 2f0f7e191b99c..9d6933e9d03a9 100644 --- a/cassandra_nodetool/assets/configuration/spec.yaml +++ b/cassandra_nodetool/assets/configuration/spec.yaml @@ -6,13 +6,13 @@ files: options: - name: nodetool description: | - command or path to nodetool (e.g. /usr/bin/nodetool or docker exec container nodetool) - can be overwritten on an instance + The command or path to nodetool (for example, /usr/bin/nodetool or docker exec container nodetool) + can be overwritten on an instance. Note: Agent v6.11+ on Windows runs as an unprivileged user (`ddagentuser`). That user needs to be granted access to the nodetool installation directory for the check to work. - The nodetool installation also sets some environment variables (e.g. `CASSANDRA_HOME` and `DSCINSTALLDIR`), - but sets them as variables only for the user doing the nodetool installation. Those environment variables should - be set as system-wide variables. + The nodetool installation also sets some environment variables (for example, `CASSANDRA_HOME` + and `DSCINSTALLDIR`), but sets them as variables only for the user doing the nodetool installation. + You should set those environment variables as system-wide variables. required: true value: type: string @@ -35,26 +35,26 @@ files: type: string example: localhost - name: port - description: The port JMX is listening to for connections. + description: The port JMX listens to for connections. value: type: integer example: 7199 - name: username description: | Username from the credentials needed to connect to the host. These are the credentials for the JMX server. - For the check to work, this user must have a read/write access so that the Datadog Cassandra nodetool + For the check to work, this user must have a read/write access so that the Datadog Cassandra Nodetool check can execute the `status` command value: type: string - name: password description: | - Username from the credentials needed to connect to the host. These are the credentials for the JMX server. + Password from the credentials needed to connect to the host. These are the credentials for the JMX server. For the check to work, this user must have a read/write access so that the Datadog Cassandra Nodetool check can execute the `status` command value: type: string - name: ssl - description: Whether or not to use the --ssl parameter to nodetool to initiate a connection over SSL to the JMX server. + description: Whether to use the --ssl parameter with nodetool to initiate a connection over SSL to the JMX server. value: type: boolean example: false diff --git a/cassandra_nodetool/datadog_checks/cassandra_nodetool/data/conf.yaml.example b/cassandra_nodetool/datadog_checks/cassandra_nodetool/data/conf.yaml.example index 966df454b95d1..d993b1ce0886c 100644 --- a/cassandra_nodetool/datadog_checks/cassandra_nodetool/data/conf.yaml.example +++ b/cassandra_nodetool/datadog_checks/cassandra_nodetool/data/conf.yaml.example @@ -3,13 +3,13 @@ init_config: ## @param nodetool - string - required - ## command or path to nodetool (e.g. /usr/bin/nodetool or docker exec container nodetool) - ## can be overwritten on an instance + ## The command or path to nodetool (for example, /usr/bin/nodetool or docker exec container nodetool) + ## can be overwritten on an instance. ## Note: Agent v6.11+ on Windows runs as an unprivileged user (`ddagentuser`). That user needs to be granted ## access to the nodetool installation directory for the check to work. - ## The nodetool installation also sets some environment variables (e.g. `CASSANDRA_HOME` and `DSCINSTALLDIR`), - ## but sets them as variables only for the user doing the nodetool installation. Those environment variables should - ## be set as system-wide variables. + ## The nodetool installation also sets some environment variables (for example, `CASSANDRA_HOME` + ## and `DSCINSTALLDIR`), but sets them as variables only for the user doing the nodetool installation. + ## You should set those environment variables as system-wide variables. # nodetool: nodetool @@ -36,26 +36,26 @@ instances: # host: localhost ## @param port - integer - optional - default: 7199 - ## The port JMX is listening to for connections. + ## The port JMX listens to for connections. # # port: 7199 ## @param username - string - optional ## Username from the credentials needed to connect to the host. These are the credentials for the JMX server. - ## For the check to work, this user must have a read/write access so that the Datadog Cassandra nodetool + ## For the check to work, this user must have a read/write access so that the Datadog Cassandra Nodetool ## check can execute the `status` command # # username: ## @param password - string - optional - ## Username from the credentials needed to connect to the host. These are the credentials for the JMX server. + ## Password from the credentials needed to connect to the host. These are the credentials for the JMX server. ## For the check to work, this user must have a read/write access so that the Datadog Cassandra Nodetool ## check can execute the `status` command # # password: ## @param ssl - boolean - optional - default: false - ## Whether or not to use the --ssl parameter to nodetool to initiate a connection over SSL to the JMX server. + ## Whether to use the --ssl parameter with nodetool to initiate a connection over SSL to the JMX server. # # ssl: false