diff --git a/ansible/install/grafana-dashboards.yml b/ansible/install/grafana-dashboards.yml index b422b67e0..293eef93c 100644 --- a/ansible/install/grafana-dashboards.yml +++ b/ansible/install/grafana-dashboards.yml @@ -1,31 +1,32 @@ --- # -# Uploads and Builds Dashboards for Browbeat analysis of System Performance Metrics +# Builds and Uploads Dashboards for Browbeat analysis of System Performance Metrics # -# You can upload just the Static and Generated General Dashboards with: -# ansible-playbook -i hosts install/grafana-dashboards.yml -e 'cloud_dashboards=false' +# Three types of Grafana Dashboards: +# * Static Dashboards (Ex. cloud_system_performance_comparsion.json) +# * Generated General Dashboards (Ex. OpenStack General System Performance) +# * Generated Cloud Specific Dashboards ("Cloud01" CPU Graphs (for a specific cloud)) # +# The Cloud Specific Dashboards are the only ones that require a cloud's inventory be defined. +# +# If you have a cloud inventory defined, you can upload all dashboards via: +# ansible-playbook -i hosts install/grafana-dashboards.yml +# +# If you just want to upload Static and Generated General Dashboards: +# ansible-playbook -i hosts install/grafana-dashboards.yml -e 'upload_cloud_specific=false' +# +# If you just want to upload your Cloud Specific Dashboards: +# ansible-playbook -i hosts install/grafana-dashboards.yml -e 'upload_general=false upload_static=false' # - hosts: localhost gather_facts: false vars: ansible_connection: local - cloud_dashboards: true + upload_cloud_specific: true + upload_general: true + upload_static: true overwrite_existing: true - static_dashboards: - - apache_request_latency - - cloud_ceph_monitoring - - cloud_gnocchi_status - - cloud_instance_count - - cloud_keystone_token_count - - cloud_rabbitmq_monitoring - - cloud_system_performance_comparsion - - cloud_total_memory_usage - - gnocchi_performance - - iostat - - three_node_performance_food_groups - - openstack_ironic_metrics cloud_specific_dashboards: - cpu - memory @@ -62,6 +63,19 @@ process_list_name: Guest - template_name: graphite process_list_name: Graphite + static_dashboards: + - apache_request_latency + - cloud_ceph_monitoring + - cloud_gnocchi_status + - cloud_instance_count + - cloud_keystone_token_count + - cloud_rabbitmq_monitoring + - cloud_system_performance_comparsion + - cloud_total_memory_usage + - gnocchi_performance + - iostat + - three_node_performance_food_groups + - openstack_ironic_metrics roles: - grafana-dashboards environment: "{{proxy_env}}" diff --git a/ansible/install/roles/grafana-dashboards/tasks/main.yml b/ansible/install/roles/grafana-dashboards/tasks/main.yml index 8e12c483d..6c1deee26 100644 --- a/ansible/install/roles/grafana-dashboards/tasks/main.yml +++ b/ansible/install/roles/grafana-dashboards/tasks/main.yml @@ -2,15 +2,6 @@ # # Generate & Upload Browbeat OpenStack Grafana Dashboards # -# Three types of Grafana Dashboards: -# * Static Dashboards (Ex. cloud_system_performance_comparsion.json) -# * Generated General Dashboards (Ex. OpenStack General System Performance) -# * Generated Cloud Specific Dashboards ("Cloud01" CPU Graphs (for a specific cloud)) -# -# The Cloud Specific Dashboards are the only ones that require a cloud's inventory be defined. -# You can deploy the Static and General Dashboards without the Cloud Specific Dashboards -# with cloud_dashboards=false -# - name: Check Cloud Name fail: @@ -18,53 +9,65 @@ when: item == dashboard_cloud_name with_items: "{{forbidden_cloud_names}}" -- name: Generate General Dashboards - template: - src: "{{role_path}}/templates/{{item.template_name}}_general_system_performance.json.j2" - dest: "{{role_path}}/files/{{item.process_list_name}}_general_system_performance.json" - with_items: "{{general_dashboards}}" - +# Cloud Specific Dashboards (Generated off Ansible inventory) - name: Generate Cloud Specific CPU/Memory/Disk/Network/Log Dashboards vars: ansible_python_interpreter: "/usr/bin/python" template: src: "cloud_specific_{{item}}.json.j2" dest: "{{role_path}}/files/cloud_specific_{{item}}.json" + when: upload_cloud_specific|bool with_items: "{{cloud_specific_dashboards}}" - when: cloud_dashboards - -- name: Remove Existing Static Dashboard(s) - command: "curl -X DELETE -H 'Content-Type: application/json' http://{{grafana_username}}:{{grafana_password}}@{{grafana_host}}:{{grafana_port}}/api/dashboards/db/{{item|replace('_', '-')}}" - when: overwrite_existing - with_items: "{{static_dashboards}}" - -- name: Remove Existing General Dashboards - command: "curl -X DELETE -H 'Content-Type: application/json' http://{{grafana_username}}:{{grafana_password}}@{{grafana_host}}:{{grafana_port}}/api/dashboards/db/{{item.process_list_name|lower}}-general-system-performance" - when: overwrite_existing - with_items: "{{general_dashboards}}" - name: Remove Existing Cloud Specific CPU/Memory/Disk/Network/Log Dashboards command: "curl -X DELETE -H 'Content-Type: application/json' http://{{grafana_username}}:{{grafana_password}}@{{grafana_host}}:{{grafana_port}}/api/dashboards/db/{{dashboard_cloud_name}}-{{item|replace('_', '-')}}" - when: "{{overwrite_existing}} and {{cloud_dashboards}}" + when: overwrite_existing|bool and upload_cloud_specific|bool with_items: "{{cloud_specific_dashboards}}" -- name: Upload Static Dashboards to Grafana - command: "curl -X POST -H 'Content-Type: application/json' -d @{{role_path}}/files/{{item}}.json http://{{grafana_username}}:{{grafana_password}}@{{grafana_host}}:{{grafana_port}}/api/dashboards/db" - with_items: "{{static_dashboards}}" - -- name: Upload General Dashboards to Grafana - command: "curl -X POST -H 'Content-Type: application/json' -d @{{role_path}}/files/{{item.process_list_name}}_general_system_performance.json http://{{grafana_username}}:{{grafana_password}}@{{grafana_host}}:{{grafana_port}}/api/dashboards/db" - with_items: "{{general_dashboards}}" - - name: Upload Cloud Specific CPU/Memory/Disk/Network/Log Dashboards command: "curl -X POST -H 'Content-Type: application/json' -d @{{role_path}}/files/cloud_specific_{{item}}.json http://{{grafana_username}}:{{grafana_password}}@{{grafana_host}}:{{grafana_port}}/api/dashboards/db" + when: upload_cloud_specific|bool with_items: "{{cloud_specific_dashboards}}" - when: cloud_dashboards - -- name: Remove leftover json file(s) from Generated General Dashboards - file: path={{role_path}}/files/{{item.process_list_name}}_general_system_performance.json state=absent - with_items: "{{general_dashboards}}" - name: Remove leftover json file(s) from Cloud Specific CPU/Memory/Disk/Network/Log Dashboards - file: path={{role_path}}/files/cloud_specific_{{item}}.json state=absent + file: + path: "{{role_path}}/files/cloud_specific_{{item}}.json" + state: absent + when: upload_cloud_specific|bool with_items: "{{cloud_specific_dashboards}}" + +# General Performance Dashboards (Templated from Ansible vars) +- name: Generate General Dashboards + template: + src: "{{role_path}}/templates/{{item.template_name}}_general_system_performance.json.j2" + dest: "{{role_path}}/files/{{item.process_list_name}}_general_system_performance.json" + when: upload_general|bool + with_items: "{{general_dashboards}}" + +- name: Remove Existing General Dashboards + command: "curl -X DELETE -H 'Content-Type: application/json' http://{{grafana_username}}:{{grafana_password}}@{{grafana_host}}:{{grafana_port}}/api/dashboards/db/{{item.process_list_name|lower}}-general-system-performance" + when: overwrite_existing|bool and upload_general|bool + with_items: "{{general_dashboards}}" + +- name: Upload General Dashboards to Grafana + command: "curl -X POST -H 'Content-Type: application/json' -d @{{role_path}}/files/{{item.process_list_name}}_general_system_performance.json http://{{grafana_username}}:{{grafana_password}}@{{grafana_host}}:{{grafana_port}}/api/dashboards/db" + when: upload_general|bool + with_items: "{{general_dashboards}}" + +- name: Remove leftover json file(s) from Generated General Dashboards + file: + path: "{{role_path}}/files/{{item.process_list_name}}_general_system_performance.json" + state: absent + when: upload_general|bool + with_items: "{{general_dashboards}}" + +# Static Dashboards: +- name: Remove Existing Static Dashboard(s) + command: "curl -X DELETE -H 'Content-Type: application/json' http://{{grafana_username}}:{{grafana_password}}@{{grafana_host}}:{{grafana_port}}/api/dashboards/db/{{item|replace('_', '-')}}" + when: overwrite_existing|bool and upload_static|bool + with_items: "{{static_dashboards}}" + +- name: Upload Static Dashboards to Grafana + command: "curl -X POST -H 'Content-Type: application/json' -d @{{role_path}}/files/{{item}}.json http://{{grafana_username}}:{{grafana_password}}@{{grafana_host}}:{{grafana_port}}/api/dashboards/db" + when: upload_static|bool + with_items: "{{static_dashboards}}"