Skip to content
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

Monitoring dashboards auto detection #360

Closed
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
8 changes: 8 additions & 0 deletions ansible-scylla-monitoring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ Role Variables

Please check under `defaults/main.yml`, the variables are heavily commented

Inventory
---------
Must include the following section:
* [scylla]: Scylla nodes

Optional section:
* [scylla-manager]: Scylla Manager host


Example Playbook
----------------
Expand Down
16 changes: 10 additions & 6 deletions ansible-scylla-monitoring/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ scylla_monitoring_config_path: "{{ scylla_monitoring_deploy_path }}/config"
scylla_monitoring_prom_rules_path: "{{ scylla_monitoring_config_path }}/prom_rules"
scylla_monitoring_alertdata_path: "{{ scylla_monitoring_deploy_path }}/alertdata"

# If set to True, the role will generate scylla_servers.yml based on the output of nodetool status
# If set to True, the role will generate scylla_servers.yml based on the output of 'nodetool status' executed on the
# first node from the 'scylla' inventory section.
# If set to False, the dc variable must be defined in the inventory for each one of the nodes and the role
# will use the information from the inventory to generate scylla_servers.yml.
# will use the information from the inventory 'scylla' section to generate scylla_servers.yml.
use_nodetool_status_with_genconfig: false

# List of monitoring dashboards to enable
scylla_monitoring_dashboards_versions:
- '2021.1'
# List of monitoring dashboards to enable. If empty or not set the Role will auto-select the one that corresponds to a
# Scylla version installed on the first host from the 'scylla' inventory section.
#scylla_monitoring_dashboards_versions:
# - '2021.1'

# Username which will be used for the cql plugin if auth is enabled on scylla-server side
# scylla_monitoring_cql_default_user: 'scylla_cql_monitor'
Expand Down Expand Up @@ -72,7 +74,9 @@ rule_config_yml_path: rule_config.yml
# Example: "1000h" will keep data to 1000 hours
scylla_monitoring_retention: "14d"

# Other scylla monitoring parameters used with start-all.sh
# Other scylla monitoring parameters used with start-all.sh.
# If '-M <Scylla Manager version>' is not explicitly specified and if inventory has a 'scylla-manager' section, a Scylla Manager
# dashboard version will be auto-selected according to a version installed on the first host from the 'scylla-manager' inventory section.
# scylla_monitoring_params: '-M 2.1 -a P@ssw0rd123'

### The following settings are only relevant for non-dockerized setup
Expand Down
2 changes: 2 additions & 0 deletions ansible-scylla-monitoring/molecule/shared/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
- name: Include ansible-scylla-monitoring
include_role:
name: ansible-scylla-monitoring
vars:
scylla_monitoring_dashboards_versions: ['2022.2']
46 changes: 46 additions & 0 deletions ansible-scylla-monitoring/tasks/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,49 @@
dest: "{{ scylla_monitoring_config_path }}/rule_config.yml"
mode: '0644'
when: rule_config_stat.stat.exists|bool == false

- name: Set _scylla_monitoring_params to scylla_monitoring_params
set_fact:
_scylla_monitoring_params: "{{ scylla_monitoring_params | default('') }}"

- name: Auto detect Scylla Manager version
block:
- name: Get Scylla Manager version from "{{ groups['scylla-manager'][0] }}"
shell: |
sctool version | grep ^Server | tr -d ' ' | cut -d':' -f2- | cut -d'.' -f1,2
delegate_to: "{{ groups['scylla-manager'][0] }}"
register: _sm_version_out

- name: Adding Scylla Manager dashboard option if getting a Manager version was successful
set_fact:
_scylla_monitoring_params: "{{ _scylla_monitoring_params }} -M {{ _sm_version_out.stdout }}"
when: _sm_version_out.stdout != ''

- name: Error out if failed to get Scylla Manager version
fail:
msg: "Can't auto-detect Scylla Manager dashboard version. Either specify it explicitly or install Scylla Manager Server on the Scylla Manager host."
when: _sm_version_out.stdout == ''
when: _scylla_monitoring_params is not search("-M\s+") and 'scylla-manager' in groups and (groups['scylla-manager']|length > 0)

- name: Set _scylla_monitoring_dashboards_versions to scylla_monitoring_dashboards_versions
set_fact:
_scylla_monitoring_dashboards_versions: "{{ scylla_monitoring_dashboards_versions | default([]) }}"

- name: Auto detect Scylla version if dashboard versions were not explicitly specified
block:
- name: Get Scylla version from "{{ groups['scylla'][0] }}"
shell: |
scylla --version | cut -d'.' -f1,2
delegate_to: "{{ groups['scylla'][0] }}"
register: _scylla_version_out

- name: Adding Scylla dashboard option if getting a Scylla version was successful
set_fact:
_scylla_monitoring_dashboards_versions: ["{{ _scylla_version_out.stdout }}"]
when: _scylla_version_out.stdout != ''

- name: Error out if failed to get Scylla version
fail:
msg: "Can't auto-detect Scylla dashboard version. Either specify it explicitly or install scylla on the first Scylla node."
when: _scylla_version_out.stdout == ''
when: (_scylla_monitoring_dashboards_versions|length == 0) and 'scylla' in groups and (groups['scylla']|length > 0)
16 changes: 8 additions & 8 deletions ansible-scylla-monitoring/tasks/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
./start-all.sh \
-d {{ scylla_monitoring_data_path }} \
-f {{ scylla_monitoring_alertdata_path }} \
-v {{ scylla_monitoring_dashboards_versions|join(',') }} \
-v {{ _scylla_monitoring_dashboards_versions|join(',') }} \
-s {{ scylla_monitoring_config_path }}/scylla_servers.yml \
-N {{ scylla_monitoring_config_path }}/scylla_manager_servers.yml \
-r {{ scylla_monitoring_config_path }}/rule_config.yml \
-R {{ scylla_monitoring_prom_rules_path }}/ \
-b --storage.tsdb.retention.time={{ scylla_monitoring_retention }} \
{{ scylla_monitoring_params | default('') }}
{{ _scylla_monitoring_params }}
ignore_errors: true

# Workaround for potential inner networking issue under docker
Expand All @@ -67,13 +67,13 @@
./start-all.sh \
-d {{ scylla_monitoring_data_path }} \
-f {{ scylla_monitoring_alertdata_path }} \
-v {{ scylla_monitoring_dashboards_versions|join(',') }} \
-v {{ _scylla_monitoring_dashboards_versions|join(',') }} \
-s {{ scylla_monitoring_config_path }}/scylla_servers.yml \
-N {{ scylla_monitoring_config_path }}/scylla_manager_servers.yml \
-r {{ scylla_monitoring_config_path }}/rule_config.yml \
-R {{ scylla_monitoring_prom_rules_path }}/ \
-b --storage.tsdb.retention.time={{ scylla_monitoring_retention }} \
{{ scylla_monitoring_params | default('') }}
{{ _scylla_monitoring_params }}
environment:
SCYLLA_USER: "{% if monitoring_cql_username is defined and monitoring_cql_password is defined %}{{ monitoring_cql_username }}{% endif %}"
SCYLLA_PSSWD: "{% if monitoring_cql_username is defined and monitoring_cql_password is defined %}{{ monitoring_cql_password }}{% endif %}"
Expand All @@ -95,13 +95,13 @@
./start-all.sh \
-d {{ scylla_monitoring_data_path }} \
-f {{ scylla_monitoring_alertdata_path }} \
-v {{ scylla_monitoring_dashboards_versions|join(',') }} \
-v {{ _scylla_monitoring_dashboards_versions|join(',') }} \
-s {{ scylla_monitoring_config_path }}/scylla_servers.yml \
-N {{ scylla_monitoring_config_path }}/scylla_manager_servers.yml \
-r {{ scylla_monitoring_config_path }}/rule_config.yml \
-R {{ scylla_monitoring_prom_rules_path }}/ \
-b --storage.tsdb.retention.time={{ scylla_monitoring_retention }} \
{{ scylla_monitoring_params | default('') }}
{{ _scylla_monitoring_params }}
ignore_errors: true
become: true

Expand All @@ -124,13 +124,13 @@
./start-all.sh \
-d {{ scylla_monitoring_data_path }} \
-f {{ scylla_monitoring_alertdata_path }} \
-v {{ scylla_monitoring_dashboards_versions|join(',') }} \
-v {{ _scylla_monitoring_dashboards_versions|join(',') }} \
-s {{ scylla_monitoring_config_path }}/scylla_servers.yml \
-N {{ scylla_monitoring_config_path }}/scylla_manager_servers.yml \
-r {{ scylla_monitoring_config_path }}/rule_config.yml \
-R {{ scylla_monitoring_prom_rules_path }}/ \
-b --storage.tsdb.retention.time={{ scylla_monitoring_retention }} \
{{ scylla_monitoring_params | default('') }}
{{ _scylla_monitoring_params }}
become: true
environment:
SCYLLA_USER: "{% if monitoring_cql_username is defined and monitoring_cql_password is defined %}{{ monitoring_cql_username }}{% endif %}"
Expand Down
Loading