├── .gitignore ├── LICENSE ├── README.md ├── Vagrantfile ├── config-grafana.sh ├── grafana-dashboard.json ├── init-vault.sh ├── install-consul.sh ├── install-elasticsearch.sh ├── install-grafana.sh ├── install-kibana.sh ├── install-logstash.sh ├── install-prometheus.sh ├── install-rsyslog-client.sh ├── install-rsyslog-server.sh ├── install-telegraf.sh ├── install-vault.sh ├── test-get-vault.sh └── test-put-vault.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .vagrant 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vault Monitoring and Logging Demo 2 | 3 | The code in this demo will build a local Consul cluster with a single Vault server along with a Prometheus/Grafana server and an ELK (Elasticsearch, Logstash, Kibana) server too. The aim of all of this is to demonstrate how you could collect metrics from Vault and Consul (and which metrics are most important) and also how to collect audit logs from Vault and ship them to an ELK stack. 4 | 5 | ## Important Notes 6 | 7 | 1. **Note:** As of 2nd January 2019, there is an incompatibility between Vagrant 2.2.6 and Virtualbox 6.1.X. Until this incompatibility is fixed, it is recommended to run Vagrant with Virtualbox 6.0.14 instead. 8 | 9 | 2. **Note:** This demo aims to demonstrate how telemetry metrics and audit logs can be enabled and collected with Vault and Consul. It does **not** intend to demonstrate how to build a Vault and Consul deployment according to any recommended architecture, nor does it intend to demonstrate any form of best practice. Amongst many other things, you should always enable ACLs, configure TLS and never store your Vault unseal keys or tokens on your Vault server! 10 | 11 | ## Requirements 12 | * The VMs created by the demo will consume a total of 5GB memory. 13 | * The demo was tested using Vagrant 2.2.6 and Virtualbox 6.0.14 14 | 15 | ## What is built? 16 | 17 | The demo will build the following Virtual Machines: 18 | * **vault-server**: A single Vault server 19 | * **consul-{1-3}-server**: A cluster of 3 Consul servers within a single Datacenter 20 | * **prometheus**: A single server running Prometheus 21 | * **elasticsearch**: A single server running an ELK stack. 22 | 23 | ## Provisioning scripts 24 | The following provisioning scripts will be run by Vagrant: 25 | * config-grafana.sh: Automatically configures Prometheus as the datasource for Grafana on the prometheus VM, deploys a dashboard onto Grafana and sets that dashboard as the home dashboard. 26 | * install-consul.sh: Automatically installs and configures Consul 1.6.2 (open source) on each of the consul-{1-3}-server VMs. A flag allows it to configure a consul client on the Vault VM too. 27 | * install-elasticsearch.sh: Automatically installs and configures the latest version of elasticsearch on the elasticsearch VM. 28 | * install-grafana.sh: Automatically installs Grafana onto the prometheus VM. 29 | * install-kibana.sh: Automatically installs Kibana onto the elasticsearch VM and configures it to search on the local Elasticsearch server. 30 | * install-logstash.sh: Automatically installs Logstash onto the elasticsearch VM and configures it to output to the local Elasticsearch server. 31 | * install-prometheus.sh: Automatically installs Prometheus onto the Prometheus VM and configures it to scrape metrics from all consul and vault servers. 32 | * install-rsyslog-client.sh: Configures an rsyslog client on each of the consul and vault servers to forward to the rsyslog server (which is co-located on the elasticsearch server) 33 | * install-rsyslog-server.sh: Configures an rsyslog server on the elasticsearch server to collect logs sent from the rsyslog clients and to forward them to logstash running on the same Elasticsearch server in JSON format. 34 | * install-telegraf.sh: Installs and configures telegraf on each of the consul and vault servers. This collects system and application metrics and publishes them on an endpoint that Prometheus can scrape from. 35 | * install-vault.sh: Automatically installs and configures Vault (open source) on the Vault server. 36 | 37 | ## Additional files 38 | The following additional files are also included: 39 | * grafana-dashboard.json: Stores the grafana dashboard configuration. Used by config-grafana.sh 40 | * init-vault.sh: Needs to be run as a manual step to initialise and unseal Vault, logging in using the root token and configuring audit logging. 41 | * test-put-vault.sh: Puts 10000 unique secrets into Vault in order to demonstrate the effect of a large number of Vault writes on Vault and Consul (Should be run before test-get-vault.sh) 42 | * test-get-vault.sh: Gets 10000 secrets from Vault in order to demonstrate the effect of a large number of Vault reads on Vault and Consul (Should be run after test-put-vault.sh) 43 | 44 | ## How to get started 45 | Once Vagrant and Virtualbox are installed, to get started just run the following command within the code directory: 46 | ``` 47 | vagrant up 48 | ``` 49 | Once vagrant has completely finished, run the following to SSH onto the vault server 50 | ``` 51 | vagrant ssh vault-server 52 | ``` 53 | Once SSH'd onto vault-server, run the following commands in sequence: 54 | ``` 55 | cp /vagrant/init-vault.sh ~ ; 56 | chmod 744 init-vault.sh ; 57 | ./init-vault.sh ; 58 | chmod 744 test-{get,put}-vault.sh 59 | ``` 60 | This will create a file called vault.txt in the directory you run the script in. The file contains a single Vault unseal key and root token, in case you wish to seal or unseal vault in the future. Of course, in a real-life scenario these files should not be generated automatically and not be stored on the vault server. 61 | 62 | Once everything is built, you should be able to access the following UIs at the following addresses: 63 | 64 | * Consul UI: http://10.0.0.11:7500/ui/ 65 | * Grafana UI: http://10.0.0.14:3000 66 | * Prometheus UI: http://10.0.0.14:9090 67 | * Kibana UI: http://10.0.0.15:9601 68 | 69 | If you're having problems, then check your Virtualbox networking configurations. They should be set to the default of NAT. If problems still persist then you might be able to access the UIs via the port forwarding that has been set up- check the Vagrantfile for these ports. 70 | 71 | ## Support 72 | No support or guarantees are offered with this code. It is purely a demo. 73 | 74 | ## Future Improvements 75 | * Use Docker containers instead of VMs. 76 | * More effective load testing instead of simple bash scripts. 77 | * Other suggested future improvements very welcome. 78 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | BOX_IMAGE = "bento/ubuntu-18.04" 2 | 3 | Vagrant.configure("2") do |config| 4 | 5 | config.vm.define "vault-server" do |subconfig| 6 | subconfig.vm.box = BOX_IMAGE 7 | subconfig.vm.hostname = "vault" 8 | subconfig.vm.network "private_network", ip: "10.0.0.10" 9 | subconfig.vm.provider :virtualbox do |vb| 10 | vb.customize ['modifyvm', :id,'--memory', '512'] 11 | end 12 | subconfig.vm.provision "shell" do |s| 13 | s.path = "install-rsyslog-client.sh" 14 | s.args = ["10.0.0.15"] 15 | end 16 | subconfig.vm.provision "shell" do |s| 17 | s.path = "install-vault.sh" 18 | s.args = ["10.0.0.10"] 19 | end 20 | subconfig.vm.provision "shell" do |s| 21 | s.path = "install-consul.sh" 22 | s.args = ["10.0.0.10", '"10.0.0.10","10.0.0.11","10.0.0.12","10.0.0.13"', 'dc1', 0, "false"] 23 | end 24 | subconfig.vm.provision "shell" do |s| 25 | s.path = "install-telegraf.sh" 26 | s.args = ["dc1","vault-server"] 27 | end 28 | end 29 | 30 | config.vm.define "consul-1-server" do |subconfig| 31 | subconfig.vm.box = BOX_IMAGE 32 | subconfig.vm.hostname = "consul-1" 33 | subconfig.vm.network "private_network", ip: "10.0.0.11" 34 | subconfig.vm.provider :virtualbox do |vb| 35 | vb.customize ['modifyvm', :id,'--memory', '512'] 36 | end 37 | subconfig.vm.provision "shell" do |s| 38 | s.path = "install-consul.sh" 39 | s.args = ["10.0.0.11", '"10.0.0.10","10.0.0.11","10.0.0.12","10.0.0.13"', 'dc1', 3, "true"] 40 | end 41 | subconfig.vm.provision "shell" do |s| 42 | s.path = "install-telegraf.sh" 43 | s.args = ["dc1","consul-server"] 44 | end 45 | subconfig.vm.network "forwarded_port", guest: 7500, host: 57500 46 | end 47 | 48 | config.vm.define "consul-2-server" do |subconfig| 49 | subconfig.vm.box = BOX_IMAGE 50 | subconfig.vm.hostname = "consul-2" 51 | subconfig.vm.network "private_network", ip: "10.0.0.12" 52 | subconfig.vm.provider :virtualbox do |vb| 53 | vb.customize ['modifyvm', :id,'--memory', '512'] 54 | end 55 | subconfig.vm.provision "shell" do |s| 56 | s.path = "install-consul.sh" 57 | s.args = ["10.0.0.12", '"10.0.0.10","10.0.0.11","10.0.0.12","10.0.0.13"', 'dc1', 0, "true"] 58 | end 59 | subconfig.vm.provision "shell" do |s| 60 | s.path = "install-telegraf.sh" 61 | s.args = ["dc1","consul-server"] 62 | end 63 | end 64 | 65 | config.vm.define "consul-3-server" do |subconfig| 66 | subconfig.vm.box = BOX_IMAGE 67 | subconfig.vm.hostname = "consul-3" 68 | subconfig.vm.network "private_network", ip: "10.0.0.13" 69 | subconfig.vm.provider :virtualbox do |vb| 70 | vb.customize ['modifyvm', :id,'--memory', '512'] 71 | end 72 | subconfig.vm.provision "shell" do |s| 73 | s.path = "install-consul.sh" 74 | s.args = ["10.0.0.13", '"10.0.0.10","10.0.0.11","10.0.0.12","10.0.0.13"', 'dc1', 0, "true"] 75 | end 76 | subconfig.vm.provision "shell" do |s| 77 | s.path = "install-telegraf.sh" 78 | s.args = ["dc1","consul-server"] 79 | end 80 | end 81 | 82 | config.vm.define "prometheus" do |subconfig| 83 | subconfig.vm.box = BOX_IMAGE 84 | subconfig.vm.hostname = "prometheus" 85 | subconfig.vm.network "private_network", ip: "10.0.0.14" 86 | subconfig.vm.provider :virtualbox do |vb| 87 | vb.customize ['modifyvm', :id,'--memory', '1024'] 88 | end 89 | subconfig.vm.provision "shell" do |s| 90 | s.path = "install-prometheus.sh" 91 | s.args = ['10.0.0.14'] 92 | end 93 | subconfig.vm.provision "shell", path: "install-grafana.sh" 94 | subconfig.vm.provision "shell", path: "config-grafana.sh" 95 | subconfig.vm.network "forwarded_port", guest: 3000, host: 43000 96 | subconfig.vm.network "forwarded_port", guest: 9090, host: 49090 97 | end 98 | 99 | config.vm.define "elasticsearch" do |subconfig| 100 | subconfig.vm.box = BOX_IMAGE 101 | subconfig.vm.hostname = "elasticsearch" 102 | subconfig.vm.network "private_network", ip: "10.0.0.15" 103 | subconfig.vm.provider :virtualbox do |vb| 104 | vb.customize ['modifyvm', :id,'--memory', '2048'] 105 | end 106 | subconfig.vm.provision "shell" do |s| 107 | s.path = "install-elasticsearch.sh" 108 | s.args = ["10.0.0.15"] 109 | end 110 | subconfig.vm.provision "shell" do |s| 111 | s.path = "install-kibana.sh" 112 | s.args = ["10.0.0.15"] 113 | end 114 | subconfig.vm.provision "shell" do |s| 115 | s.path = "install-logstash.sh" 116 | s.args = ["10.0.0.15"] 117 | end 118 | subconfig.vm.provision "shell" do |s| 119 | s.path = "install-rsyslog-server.sh" 120 | s.args = ["10.0.0.15"] 121 | end 122 | end 123 | end 124 | -------------------------------------------------------------------------------- /config-grafana.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Waiting 15 seconds for Grafana to come up..." 4 | sleep 15 5 | echo "Continuing..." 6 | 7 | # Add Prometheus Datasource 8 | 9 | cat > "grafana-datasources.json" <> /var/log/config-grafana.log 2>&1 20 | 21 | # Import Grafana Dashboard 22 | sudo cp /vagrant/grafana-dashboard.json . 23 | 24 | curl -X POST -H "Content-Type: application/json" -d @grafana-dashboard.json http://admin:admin@localhost:3000/api/dashboards/db >> /var/log/config-grafana.log 2>&1 25 | 26 | # Star Dashboard and set as home 27 | 28 | cat > "grafana-preferences.json" <> /var/log/config-grafana.log 2>&1 37 | 38 | curl -X PUT -H "Content-Type: application/json" -d @grafana-preferences.json http://admin:admin@localhost:3000/api/user/preferences >> /var/log/config-grafana.log 2>&1 39 | -------------------------------------------------------------------------------- /grafana-dashboard.json: -------------------------------------------------------------------------------- 1 | { 2 | "dashboard": 3 | { 4 | "annotations": { 5 | "list": [ 6 | { 7 | "builtIn": 1, 8 | "datasource": "-- Grafana --", 9 | "enable": true, 10 | "hide": true, 11 | "iconColor": "rgba(0, 211, 255, 1)", 12 | "name": "Annotations & Alerts", 13 | "type": "dashboard" 14 | } 15 | ] 16 | }, 17 | "editable": true, 18 | "gnetId": null, 19 | "graphTooltip": 0, 20 | "id": null, 21 | "links": [], 22 | "panels": [ 23 | { 24 | "cacheTimeout": null, 25 | "columns": [], 26 | "description": "", 27 | "fontSize": "100%", 28 | "gridPos": { 29 | "h": 4, 30 | "w": 8, 31 | "x": 0, 32 | "y": 0 33 | }, 34 | "id": 78, 35 | "links": [], 36 | "options": {}, 37 | "pageSize": null, 38 | "scroll": true, 39 | "showHeader": true, 40 | "sort": { 41 | "col": 0, 42 | "desc": true 43 | }, 44 | "styles": [ 45 | { 46 | "alias": "Time", 47 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 48 | "pattern": "Time", 49 | "type": "date" 50 | }, 51 | { 52 | "alias": "Count", 53 | "colorMode": "row", 54 | "colors": [ 55 | "#73BF69", 56 | "#73BF69", 57 | "#F2495C" 58 | ], 59 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 60 | "decimals": 2, 61 | "link": false, 62 | "mappingType": 1, 63 | "pattern": "Value #A", 64 | "thresholds": [ 65 | "1.00" 66 | ], 67 | "type": "number", 68 | "unit": "short", 69 | "valueMaps": [] 70 | }, 71 | { 72 | "alias": "Count", 73 | "colorMode": "row", 74 | "colors": [ 75 | "rgba(245, 54, 54, 0.9)", 76 | "#F2495C", 77 | "#F2495C" 78 | ], 79 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 80 | "decimals": 2, 81 | "mappingType": 1, 82 | "pattern": "Value #B", 83 | "thresholds": [ 84 | "1.00" 85 | ], 86 | "type": "number", 87 | "unit": "short" 88 | } 89 | ], 90 | "targets": [ 91 | { 92 | "expr": "count(consul_health_checks_passing{check_name=\"Vault Sealed Status\",job=\"vault-server\",status=\"passing\"}) by (node,check_id,status)", 93 | "format": "table", 94 | "hide": false, 95 | "instant": true, 96 | "interval": "", 97 | "intervalFactor": 1, 98 | "legendFormat": "he", 99 | "refId": "A" 100 | }, 101 | { 102 | "expr": "count(consul_health_checks_passing{check_name=\"Vault Sealed Status\",job=\"vault-server\",status=\"critical\"}) by (node,check_id,status)", 103 | "format": "table", 104 | "instant": true, 105 | "intervalFactor": 1, 106 | "refId": "B" 107 | } 108 | ], 109 | "timeFrom": null, 110 | "timeShift": null, 111 | "title": "Vault Seal Status", 112 | "transform": "table", 113 | "type": "table" 114 | }, 115 | { 116 | "cacheTimeout": null, 117 | "colorBackground": false, 118 | "colorValue": false, 119 | "colors": [ 120 | "#299c46", 121 | "rgba(237, 129, 40, 0.89)", 122 | "#d44a3a" 123 | ], 124 | "format": "none", 125 | "gauge": { 126 | "maxValue": 100, 127 | "minValue": 0, 128 | "show": false, 129 | "thresholdLabels": false, 130 | "thresholdMarkers": true 131 | }, 132 | "gridPos": { 133 | "h": 4, 134 | "w": 4, 135 | "x": 8, 136 | "y": 0 137 | }, 138 | "id": 80, 139 | "interval": null, 140 | "links": [], 141 | "mappingType": 1, 142 | "mappingTypes": [ 143 | { 144 | "name": "value to text", 145 | "value": 1 146 | }, 147 | { 148 | "name": "range to text", 149 | "value": 2 150 | } 151 | ], 152 | "maxDataPoints": 100, 153 | "nullPointMode": "connected", 154 | "nullText": null, 155 | "options": {}, 156 | "postfix": "", 157 | "postfixFontSize": "50%", 158 | "prefix": "", 159 | "prefixFontSize": "50%", 160 | "rangeMaps": [ 161 | { 162 | "from": "null", 163 | "text": "N/A", 164 | "to": "null" 165 | } 166 | ], 167 | "sparkline": { 168 | "fillColor": "rgba(31, 118, 189, 0.18)", 169 | "full": false, 170 | "lineColor": "rgb(31, 120, 193)", 171 | "show": false 172 | }, 173 | "tableColumn": "", 174 | "targets": [ 175 | { 176 | "expr": "count(consul_rpc_request{role=\"consul-server\"})", 177 | "format": "time_series", 178 | "intervalFactor": 1, 179 | "legendFormat": "", 180 | "refId": "A" 181 | } 182 | ], 183 | "thresholds": "", 184 | "timeFrom": null, 185 | "timeShift": null, 186 | "title": "Consul Server Count", 187 | "type": "singlestat", 188 | "valueFontSize": "80%", 189 | "valueMaps": [ 190 | { 191 | "op": "=", 192 | "text": "N/A", 193 | "value": "null" 194 | } 195 | ], 196 | "valueName": "avg" 197 | }, 198 | { 199 | "cacheTimeout": null, 200 | "datasource": "Prometheus", 201 | "description": "Measures the time since the leader was last able to contact the follower nodes when checking its leader lease", 202 | "gridPos": { 203 | "h": 4, 204 | "w": 6, 205 | "x": 12, 206 | "y": 0 207 | }, 208 | "id": 50, 209 | "links": [], 210 | "options": { 211 | "fieldOptions": { 212 | "calcs": [ 213 | "last" 214 | ], 215 | "defaults": { 216 | "max": 100, 217 | "min": 0, 218 | "unit": "ms" 219 | }, 220 | "mappings": [], 221 | "override": {}, 222 | "thresholds": [ 223 | { 224 | "color": "green", 225 | "index": 0, 226 | "value": null 227 | }, 228 | { 229 | "color": "red", 230 | "index": 1, 231 | "value": 200 232 | } 233 | ], 234 | "values": false 235 | }, 236 | "orientation": "auto", 237 | "showThresholdLabels": false, 238 | "showThresholdMarkers": true 239 | }, 240 | "pluginVersion": "6.2.1", 241 | "targets": [ 242 | { 243 | "expr": "consul_raft_leader_lastContact_upper", 244 | "format": "time_series", 245 | "hide": false, 246 | "instant": true, 247 | "intervalFactor": 1, 248 | "legendFormat": "", 249 | "refId": "C" 250 | } 251 | ], 252 | "timeFrom": null, 253 | "timeShift": null, 254 | "title": "Consul Raft Leader LastContact", 255 | "type": "gauge" 256 | }, 257 | { 258 | "collapsed": true, 259 | "gridPos": { 260 | "h": 1, 261 | "w": 24, 262 | "x": 0, 263 | "y": 4 264 | }, 265 | "id": 4, 266 | "panels": [ 267 | { 268 | "content": "# CPU Utilisation\n\nEncryption can place a heavy demand on CPU. If the CPU is too busy, Vault may have trouble keeping up with the incoming request load. You may also want to monitor each CPU individually to make sure requests are evenly balanced across all CPUs.\n\nConsul is not particularly demanding of CPU time, but a spike in CPU usage might indicate too many operations taking place at once, and iowait_cpu is critical -- it means Consul is waiting for data to be written to disk, a sign that Raft might be writing snapshots to disk too often.\n", 269 | "gridPos": { 270 | "h": 4, 271 | "w": 24, 272 | "x": 0, 273 | "y": 1 274 | }, 275 | "id": 13, 276 | "links": [], 277 | "mode": "markdown", 278 | "options": {}, 279 | "timeFrom": null, 280 | "timeShift": null, 281 | "title": "CPU Utilisation", 282 | "type": "text" 283 | }, 284 | { 285 | "aliasColors": {}, 286 | "bars": false, 287 | "dashLength": 10, 288 | "dashes": false, 289 | "datasource": "Prometheus", 290 | "description": "Percentage of CPU being used by user processes on Consul servers (processes including Consul)", 291 | "fill": 1, 292 | "gridPos": { 293 | "h": 7, 294 | "w": 6, 295 | "x": 0, 296 | "y": 5 297 | }, 298 | "id": 10, 299 | "legend": { 300 | "avg": false, 301 | "current": false, 302 | "max": false, 303 | "min": false, 304 | "show": true, 305 | "total": false, 306 | "values": false 307 | }, 308 | "lines": true, 309 | "linewidth": 1, 310 | "links": [], 311 | "nullPointMode": "null", 312 | "options": {}, 313 | "percentage": false, 314 | "pointradius": 2, 315 | "points": false, 316 | "renderer": "flot", 317 | "seriesOverrides": [], 318 | "spaceLength": 10, 319 | "stack": false, 320 | "steppedLine": false, 321 | "targets": [ 322 | { 323 | "expr": "cpu_usage_user{cpu=\"cpu-total\",job=\"consul-1-server\"}", 324 | "format": "time_series", 325 | "hide": false, 326 | "intervalFactor": 1, 327 | "legendFormat": "cpu-usage-consul-1-server", 328 | "refId": "A" 329 | }, 330 | { 331 | "expr": "cpu_usage_user{cpu=\"cpu-total\",job=\"consul-2-server\"}", 332 | "format": "time_series", 333 | "intervalFactor": 1, 334 | "legendFormat": "cpu-usage-consul-2-server", 335 | "refId": "B" 336 | }, 337 | { 338 | "expr": "cpu_usage_user{cpu=\"cpu-total\",job=\"consul-3-server\"}", 339 | "format": "time_series", 340 | "intervalFactor": 1, 341 | "legendFormat": "cpu-usage-consul-3-server", 342 | "refId": "C" 343 | } 344 | ], 345 | "thresholds": [], 346 | "timeFrom": null, 347 | "timeRegions": [], 348 | "timeShift": null, 349 | "title": "Consul User CPU Usage", 350 | "tooltip": { 351 | "shared": true, 352 | "sort": 0, 353 | "value_type": "individual" 354 | }, 355 | "type": "graph", 356 | "xaxis": { 357 | "buckets": null, 358 | "mode": "time", 359 | "name": null, 360 | "show": true, 361 | "values": [] 362 | }, 363 | "yaxes": [ 364 | { 365 | "format": "short", 366 | "label": null, 367 | "logBase": 1, 368 | "max": null, 369 | "min": null, 370 | "show": true 371 | }, 372 | { 373 | "format": "short", 374 | "label": null, 375 | "logBase": 1, 376 | "max": null, 377 | "min": null, 378 | "show": true 379 | } 380 | ], 381 | "yaxis": { 382 | "align": false, 383 | "alignLevel": null 384 | } 385 | }, 386 | { 387 | "alert": { 388 | "conditions": [ 389 | { 390 | "evaluator": { 391 | "params": [ 392 | 0.1 393 | ], 394 | "type": "gt" 395 | }, 396 | "operator": { 397 | "type": "and" 398 | }, 399 | "query": { 400 | "params": [ 401 | "A", 402 | "5m", 403 | "now" 404 | ] 405 | }, 406 | "reducer": { 407 | "params": [], 408 | "type": "avg" 409 | }, 410 | "type": "query" 411 | } 412 | ], 413 | "executionErrorState": "alerting", 414 | "for": "5m", 415 | "frequency": "1m", 416 | "handler": 1, 417 | "name": "CPU IOWait alert", 418 | "noDataState": "no_data", 419 | "notifications": [] 420 | }, 421 | "aliasColors": {}, 422 | "bars": false, 423 | "dashLength": 10, 424 | "dashes": false, 425 | "datasource": "Prometheus", 426 | "description": "Percentage of CPU time spent waiting for I/O tasks to complete. Look for iowait greater than 10%", 427 | "fill": 1, 428 | "gridPos": { 429 | "h": 7, 430 | "w": 6, 431 | "x": 6, 432 | "y": 5 433 | }, 434 | "id": 2, 435 | "legend": { 436 | "avg": false, 437 | "current": false, 438 | "max": false, 439 | "min": false, 440 | "show": true, 441 | "total": false, 442 | "values": false 443 | }, 444 | "lines": true, 445 | "linewidth": 1, 446 | "links": [], 447 | "nullPointMode": "null", 448 | "options": {}, 449 | "percentage": false, 450 | "pointradius": 2, 451 | "points": false, 452 | "renderer": "flot", 453 | "seriesOverrides": [], 454 | "spaceLength": 10, 455 | "stack": false, 456 | "steppedLine": false, 457 | "targets": [ 458 | { 459 | "expr": "cpu_usage_iowait{cpu=\"cpu-total\",job=\"consul-1-server\"}", 460 | "format": "time_series", 461 | "hide": false, 462 | "intervalFactor": 1, 463 | "legendFormat": "cpu-usage-consul-1-server", 464 | "refId": "A" 465 | }, 466 | { 467 | "expr": "cpu_usage_iowait{cpu=\"cpu-total\",job=\"consul-2-server\"}", 468 | "format": "time_series", 469 | "intervalFactor": 1, 470 | "legendFormat": "cpu-usage-consul-2-server", 471 | "refId": "B" 472 | }, 473 | { 474 | "expr": "cpu_usage_iowait{cpu=\"cpu-total\",job=\"consul-3-server\"}", 475 | "format": "time_series", 476 | "interval": "", 477 | "intervalFactor": 1, 478 | "legendFormat": "cpu-usage-consul-3-server", 479 | "refId": "C" 480 | } 481 | ], 482 | "thresholds": [ 483 | { 484 | "colorMode": "critical", 485 | "fill": true, 486 | "line": true, 487 | "op": "gt", 488 | "value": 0.1 489 | } 490 | ], 491 | "timeFrom": null, 492 | "timeRegions": [], 493 | "timeShift": null, 494 | "title": "Consul CPU IOWait", 495 | "tooltip": { 496 | "shared": true, 497 | "sort": 0, 498 | "value_type": "individual" 499 | }, 500 | "type": "graph", 501 | "xaxis": { 502 | "buckets": null, 503 | "mode": "time", 504 | "name": null, 505 | "show": true, 506 | "values": [] 507 | }, 508 | "yaxes": [ 509 | { 510 | "format": "short", 511 | "label": null, 512 | "logBase": 1, 513 | "max": null, 514 | "min": null, 515 | "show": true 516 | }, 517 | { 518 | "format": "short", 519 | "label": null, 520 | "logBase": 1, 521 | "max": null, 522 | "min": null, 523 | "show": true 524 | } 525 | ], 526 | "yaxis": { 527 | "align": false, 528 | "alignLevel": null 529 | } 530 | }, 531 | { 532 | "aliasColors": {}, 533 | "bars": false, 534 | "dashLength": 10, 535 | "dashes": false, 536 | "datasource": "Prometheus", 537 | "description": "Percentage of CPU being used by user processes on Vault server (processes including Vault)", 538 | "fill": 1, 539 | "gridPos": { 540 | "h": 7, 541 | "w": 6, 542 | "x": 12, 543 | "y": 5 544 | }, 545 | "id": 71, 546 | "legend": { 547 | "avg": false, 548 | "current": false, 549 | "max": false, 550 | "min": false, 551 | "show": true, 552 | "total": false, 553 | "values": false 554 | }, 555 | "lines": true, 556 | "linewidth": 1, 557 | "links": [], 558 | "nullPointMode": "null", 559 | "options": {}, 560 | "percentage": false, 561 | "pointradius": 2, 562 | "points": false, 563 | "renderer": "flot", 564 | "seriesOverrides": [], 565 | "spaceLength": 10, 566 | "stack": false, 567 | "steppedLine": false, 568 | "targets": [ 569 | { 570 | "expr": "cpu_usage_user{cpu=\"cpu-total\",job=\"vault-server\"}", 571 | "format": "time_series", 572 | "hide": false, 573 | "intervalFactor": 1, 574 | "legendFormat": "cpu-usage-vault-server", 575 | "refId": "A" 576 | } 577 | ], 578 | "thresholds": [], 579 | "timeFrom": null, 580 | "timeRegions": [], 581 | "timeShift": null, 582 | "title": "Vault User CPU Usage", 583 | "tooltip": { 584 | "shared": true, 585 | "sort": 0, 586 | "value_type": "individual" 587 | }, 588 | "type": "graph", 589 | "xaxis": { 590 | "buckets": null, 591 | "mode": "time", 592 | "name": null, 593 | "show": true, 594 | "values": [] 595 | }, 596 | "yaxes": [ 597 | { 598 | "format": "short", 599 | "label": null, 600 | "logBase": 1, 601 | "max": null, 602 | "min": null, 603 | "show": true 604 | }, 605 | { 606 | "format": "short", 607 | "label": null, 608 | "logBase": 1, 609 | "max": null, 610 | "min": null, 611 | "show": true 612 | } 613 | ], 614 | "yaxis": { 615 | "align": false, 616 | "alignLevel": null 617 | } 618 | }, 619 | { 620 | "aliasColors": {}, 621 | "bars": false, 622 | "dashLength": 10, 623 | "dashes": false, 624 | "datasource": "Prometheus", 625 | "description": "Percentage of CPU time spent waiting for I/O tasks to complete. Look for iowait greater than 10%", 626 | "fill": 1, 627 | "gridPos": { 628 | "h": 7, 629 | "w": 6, 630 | "x": 18, 631 | "y": 5 632 | }, 633 | "id": 72, 634 | "legend": { 635 | "avg": false, 636 | "current": false, 637 | "max": false, 638 | "min": false, 639 | "show": true, 640 | "total": false, 641 | "values": false 642 | }, 643 | "lines": true, 644 | "linewidth": 1, 645 | "links": [], 646 | "nullPointMode": "null", 647 | "options": {}, 648 | "percentage": false, 649 | "pointradius": 2, 650 | "points": false, 651 | "renderer": "flot", 652 | "seriesOverrides": [], 653 | "spaceLength": 10, 654 | "stack": false, 655 | "steppedLine": false, 656 | "targets": [ 657 | { 658 | "expr": "cpu_usage_iowait{cpu=\"cpu-total\",job=\"vault-server\"}", 659 | "format": "time_series", 660 | "hide": false, 661 | "intervalFactor": 1, 662 | "legendFormat": "cpu-usage-vault-1-server", 663 | "refId": "A" 664 | } 665 | ], 666 | "thresholds": [], 667 | "timeFrom": null, 668 | "timeRegions": [], 669 | "timeShift": null, 670 | "title": "Vault CPU IOWait", 671 | "tooltip": { 672 | "shared": true, 673 | "sort": 0, 674 | "value_type": "individual" 675 | }, 676 | "type": "graph", 677 | "xaxis": { 678 | "buckets": null, 679 | "mode": "time", 680 | "name": null, 681 | "show": true, 682 | "values": [] 683 | }, 684 | "yaxes": [ 685 | { 686 | "format": "short", 687 | "label": null, 688 | "logBase": 1, 689 | "max": null, 690 | "min": null, 691 | "show": true 692 | }, 693 | { 694 | "format": "short", 695 | "label": null, 696 | "logBase": 1, 697 | "max": null, 698 | "min": null, 699 | "show": true 700 | } 701 | ], 702 | "yaxis": { 703 | "align": false, 704 | "alignLevel": null 705 | } 706 | } 707 | ], 708 | "title": "CPU Utilisation", 709 | "type": "row" 710 | }, 711 | { 712 | "collapsed": false, 713 | "gridPos": { 714 | "h": 1, 715 | "w": 24, 716 | "x": 0, 717 | "y": 5 718 | }, 719 | "id": 62, 720 | "panels": [], 721 | "title": "Memory Usage", 722 | "type": "row" 723 | }, 724 | { 725 | "content": "# Memory Usage\n\n## Consul\nConsul keeps all of its data in memory. If Consul consumes all available memory, it will crash. You should also monitor\ntotal available RAM to make sure some RAM is available for other processes, and swap usage should remain at 0% for best performance.\n\n## Vault\nVault doesn't need as much memory as Consul, but if it does run out, it too will crash. You should also monitor total\navailable RAM to make sure some RAM is available for other processes, and swap usage should remain at 0% for best performance\n\n### What to look for\nIf sys_bytes exceeds 90% of total_bytes, if mem.used_percent is over 90%, or if swap.used_percent is greater\nthan 0.", 726 | "gridPos": { 727 | "h": 10, 728 | "w": 12, 729 | "x": 0, 730 | "y": 6 731 | }, 732 | "id": 64, 733 | "links": [], 734 | "mode": "markdown", 735 | "options": {}, 736 | "timeFrom": null, 737 | "timeShift": null, 738 | "title": "Memory Usage", 739 | "type": "text" 740 | }, 741 | { 742 | "alert": { 743 | "conditions": [ 744 | { 745 | "evaluator": { 746 | "params": [ 747 | 90 748 | ], 749 | "type": "gt" 750 | }, 751 | "operator": { 752 | "type": "and" 753 | }, 754 | "query": { 755 | "params": [ 756 | "A", 757 | "5m", 758 | "now" 759 | ] 760 | }, 761 | "reducer": { 762 | "params": [], 763 | "type": "avg" 764 | }, 765 | "type": "query" 766 | } 767 | ], 768 | "executionErrorState": "alerting", 769 | "for": "5m", 770 | "frequency": "1m", 771 | "handler": 1, 772 | "name": "Consul memory used percent alert", 773 | "noDataState": "no_data", 774 | "notifications": [] 775 | }, 776 | "aliasColors": {}, 777 | "bars": false, 778 | "dashLength": 10, 779 | "dashes": false, 780 | "description": "Percentage of physical memory in use", 781 | "fill": 1, 782 | "gridPos": { 783 | "h": 5, 784 | "w": 6, 785 | "x": 12, 786 | "y": 6 787 | }, 788 | "id": 66, 789 | "legend": { 790 | "avg": false, 791 | "current": false, 792 | "max": false, 793 | "min": false, 794 | "show": true, 795 | "total": false, 796 | "values": false 797 | }, 798 | "lines": true, 799 | "linewidth": 1, 800 | "links": [], 801 | "nullPointMode": "null", 802 | "options": {}, 803 | "percentage": false, 804 | "pointradius": 2, 805 | "points": false, 806 | "renderer": "flot", 807 | "seriesOverrides": [], 808 | "spaceLength": 10, 809 | "stack": false, 810 | "steppedLine": false, 811 | "targets": [ 812 | { 813 | "expr": "mem_used_percent{job=\"consul-1-server\"}", 814 | "format": "time_series", 815 | "hide": false, 816 | "interval": "", 817 | "intervalFactor": 1, 818 | "legendFormat": "mem-used-percent-consul-1-server", 819 | "refId": "A" 820 | }, 821 | { 822 | "expr": "mem_used_percent{job=\"consul-2-server\"}", 823 | "format": "time_series", 824 | "intervalFactor": 1, 825 | "legendFormat": "mem-used-percent-consul-2-server", 826 | "refId": "B" 827 | }, 828 | { 829 | "expr": "mem_used_percent{job=\"consul-3-server\"}", 830 | "format": "time_series", 831 | "intervalFactor": 1, 832 | "legendFormat": "mem-used-percent-consul-3-server", 833 | "refId": "C" 834 | } 835 | ], 836 | "thresholds": [ 837 | { 838 | "colorMode": "critical", 839 | "fill": true, 840 | "line": true, 841 | "op": "gt", 842 | "value": 90 843 | } 844 | ], 845 | "timeFrom": null, 846 | "timeRegions": [], 847 | "timeShift": null, 848 | "title": "Consul memory used percent", 849 | "tooltip": { 850 | "shared": true, 851 | "sort": 0, 852 | "value_type": "individual" 853 | }, 854 | "type": "graph", 855 | "xaxis": { 856 | "buckets": null, 857 | "mode": "time", 858 | "name": null, 859 | "show": true, 860 | "values": [] 861 | }, 862 | "yaxes": [ 863 | { 864 | "format": "short", 865 | "label": null, 866 | "logBase": 1, 867 | "max": null, 868 | "min": null, 869 | "show": true 870 | }, 871 | { 872 | "format": "short", 873 | "label": null, 874 | "logBase": 1, 875 | "max": null, 876 | "min": null, 877 | "show": true 878 | } 879 | ], 880 | "yaxis": { 881 | "align": false, 882 | "alignLevel": null 883 | } 884 | }, 885 | { 886 | "aliasColors": {}, 887 | "bars": false, 888 | "dashLength": 10, 889 | "dashes": false, 890 | "description": "Delta of Percentage of physical memory in use", 891 | "fill": 1, 892 | "gridPos": { 893 | "h": 5, 894 | "w": 6, 895 | "x": 18, 896 | "y": 6 897 | }, 898 | "id": 81, 899 | "legend": { 900 | "avg": false, 901 | "current": false, 902 | "max": false, 903 | "min": false, 904 | "show": true, 905 | "total": false, 906 | "values": false 907 | }, 908 | "lines": true, 909 | "linewidth": 1, 910 | "links": [], 911 | "nullPointMode": "null", 912 | "options": {}, 913 | "percentage": false, 914 | "pointradius": 2, 915 | "points": false, 916 | "renderer": "flot", 917 | "seriesOverrides": [], 918 | "spaceLength": 10, 919 | "stack": false, 920 | "steppedLine": false, 921 | "targets": [ 922 | { 923 | "expr": "delta(mem_used_percent{job=\"consul-1-server\"}[5m])", 924 | "format": "time_series", 925 | "hide": false, 926 | "interval": "", 927 | "intervalFactor": 1, 928 | "legendFormat": "delta-consul-1-server", 929 | "refId": "A" 930 | }, 931 | { 932 | "expr": "delta(mem_used_percent{job=\"consul-2-server\"}[5m])", 933 | "format": "time_series", 934 | "intervalFactor": 1, 935 | "legendFormat": "delta-consul-2-server", 936 | "refId": "B" 937 | }, 938 | { 939 | "expr": "delta(mem_used_percent{job=\"consul-3-server\"}[5m])", 940 | "format": "time_series", 941 | "intervalFactor": 1, 942 | "legendFormat": "delta-consul-3-server", 943 | "refId": "C" 944 | } 945 | ], 946 | "thresholds": [], 947 | "timeFrom": null, 948 | "timeRegions": [], 949 | "timeShift": null, 950 | "title": "Consul memory used percent delta", 951 | "tooltip": { 952 | "shared": true, 953 | "sort": 0, 954 | "value_type": "individual" 955 | }, 956 | "type": "graph", 957 | "xaxis": { 958 | "buckets": null, 959 | "mode": "time", 960 | "name": null, 961 | "show": true, 962 | "values": [] 963 | }, 964 | "yaxes": [ 965 | { 966 | "format": "short", 967 | "label": null, 968 | "logBase": 1, 969 | "max": null, 970 | "min": null, 971 | "show": true 972 | }, 973 | { 974 | "format": "short", 975 | "label": null, 976 | "logBase": 1, 977 | "max": null, 978 | "min": null, 979 | "show": true 980 | } 981 | ], 982 | "yaxis": { 983 | "align": false, 984 | "alignLevel": null 985 | } 986 | }, 987 | { 988 | "alert": { 989 | "conditions": [ 990 | { 991 | "evaluator": { 992 | "params": [ 993 | 90 994 | ], 995 | "type": "gt" 996 | }, 997 | "operator": { 998 | "type": "and" 999 | }, 1000 | "query": { 1001 | "params": [ 1002 | "A", 1003 | "5m", 1004 | "now" 1005 | ] 1006 | }, 1007 | "reducer": { 1008 | "params": [], 1009 | "type": "avg" 1010 | }, 1011 | "type": "query" 1012 | } 1013 | ], 1014 | "executionErrorState": "alerting", 1015 | "for": "5m", 1016 | "frequency": "1m", 1017 | "handler": 1, 1018 | "name": "Vault memory used percent alert", 1019 | "noDataState": "no_data", 1020 | "notifications": [] 1021 | }, 1022 | "aliasColors": {}, 1023 | "bars": false, 1024 | "dashLength": 10, 1025 | "dashes": false, 1026 | "description": "Percentage of physical memory in use", 1027 | "fill": 1, 1028 | "gridPos": { 1029 | "h": 5, 1030 | "w": 6, 1031 | "x": 12, 1032 | "y": 11 1033 | }, 1034 | "id": 67, 1035 | "legend": { 1036 | "avg": false, 1037 | "current": false, 1038 | "max": false, 1039 | "min": false, 1040 | "show": true, 1041 | "total": false, 1042 | "values": false 1043 | }, 1044 | "lines": true, 1045 | "linewidth": 1, 1046 | "links": [], 1047 | "nullPointMode": "null", 1048 | "options": {}, 1049 | "percentage": false, 1050 | "pointradius": 2, 1051 | "points": false, 1052 | "renderer": "flot", 1053 | "seriesOverrides": [], 1054 | "spaceLength": 10, 1055 | "stack": false, 1056 | "steppedLine": false, 1057 | "targets": [ 1058 | { 1059 | "expr": "mem_used_percent{job=\"vault-server\"}", 1060 | "format": "time_series", 1061 | "hide": false, 1062 | "interval": "", 1063 | "intervalFactor": 1, 1064 | "legendFormat": "mem-used-percent-vault-server", 1065 | "refId": "A" 1066 | } 1067 | ], 1068 | "thresholds": [ 1069 | { 1070 | "colorMode": "critical", 1071 | "fill": true, 1072 | "line": true, 1073 | "op": "gt", 1074 | "value": 90 1075 | } 1076 | ], 1077 | "timeFrom": null, 1078 | "timeRegions": [], 1079 | "timeShift": null, 1080 | "title": "Vault memory used percent", 1081 | "tooltip": { 1082 | "shared": true, 1083 | "sort": 0, 1084 | "value_type": "individual" 1085 | }, 1086 | "type": "graph", 1087 | "xaxis": { 1088 | "buckets": null, 1089 | "mode": "time", 1090 | "name": null, 1091 | "show": true, 1092 | "values": [] 1093 | }, 1094 | "yaxes": [ 1095 | { 1096 | "format": "short", 1097 | "label": null, 1098 | "logBase": 1, 1099 | "max": null, 1100 | "min": null, 1101 | "show": true 1102 | }, 1103 | { 1104 | "format": "short", 1105 | "label": null, 1106 | "logBase": 1, 1107 | "max": null, 1108 | "min": null, 1109 | "show": true 1110 | } 1111 | ], 1112 | "yaxis": { 1113 | "align": false, 1114 | "alignLevel": null 1115 | } 1116 | }, 1117 | { 1118 | "aliasColors": {}, 1119 | "bars": false, 1120 | "dashLength": 10, 1121 | "dashes": false, 1122 | "description": "Delta of Percentage of physical memory in use", 1123 | "fill": 1, 1124 | "gridPos": { 1125 | "h": 5, 1126 | "w": 6, 1127 | "x": 18, 1128 | "y": 11 1129 | }, 1130 | "id": 82, 1131 | "legend": { 1132 | "avg": false, 1133 | "current": false, 1134 | "max": false, 1135 | "min": false, 1136 | "show": true, 1137 | "total": false, 1138 | "values": false 1139 | }, 1140 | "lines": true, 1141 | "linewidth": 1, 1142 | "links": [], 1143 | "nullPointMode": "null", 1144 | "options": {}, 1145 | "percentage": false, 1146 | "pointradius": 2, 1147 | "points": false, 1148 | "renderer": "flot", 1149 | "seriesOverrides": [], 1150 | "spaceLength": 10, 1151 | "stack": false, 1152 | "steppedLine": false, 1153 | "targets": [ 1154 | { 1155 | "expr": "delta(mem_used_percent{job=\"vault-server\"}[5m])", 1156 | "format": "time_series", 1157 | "hide": false, 1158 | "interval": "", 1159 | "intervalFactor": 1, 1160 | "legendFormat": "delta-vault-server", 1161 | "refId": "A" 1162 | } 1163 | ], 1164 | "thresholds": [], 1165 | "timeFrom": null, 1166 | "timeRegions": [], 1167 | "timeShift": null, 1168 | "title": "Vault memory used percent delta", 1169 | "tooltip": { 1170 | "shared": true, 1171 | "sort": 0, 1172 | "value_type": "individual" 1173 | }, 1174 | "type": "graph", 1175 | "xaxis": { 1176 | "buckets": null, 1177 | "mode": "time", 1178 | "name": null, 1179 | "show": true, 1180 | "values": [] 1181 | }, 1182 | "yaxes": [ 1183 | { 1184 | "format": "short", 1185 | "label": null, 1186 | "logBase": 1, 1187 | "max": null, 1188 | "min": null, 1189 | "show": true 1190 | }, 1191 | { 1192 | "format": "short", 1193 | "label": null, 1194 | "logBase": 1, 1195 | "max": null, 1196 | "min": null, 1197 | "show": true 1198 | } 1199 | ], 1200 | "yaxis": { 1201 | "align": false, 1202 | "alignLevel": null 1203 | } 1204 | }, 1205 | { 1206 | "collapsed": true, 1207 | "gridPos": { 1208 | "h": 1, 1209 | "w": 24, 1210 | "x": 0, 1211 | "y": 16 1212 | }, 1213 | "id": 15, 1214 | "panels": [ 1215 | { 1216 | "content": "# Network Utilisation\n\nA sudden spike in network traffic to Vault might be the result of a misconfigured client causing too many requests, or additional load you didn't plan for. \n\nLook for sudden large changes to the net metrics (greater than 50% deviation from baseline).", 1217 | "gridPos": { 1218 | "h": 6, 1219 | "w": 7, 1220 | "x": 0, 1221 | "y": 13 1222 | }, 1223 | "id": 16, 1224 | "links": [], 1225 | "mode": "markdown", 1226 | "options": {}, 1227 | "timeFrom": null, 1228 | "timeShift": null, 1229 | "title": "Network Utilisation", 1230 | "type": "text" 1231 | }, 1232 | { 1233 | "aliasColors": {}, 1234 | "bars": false, 1235 | "dashLength": 10, 1236 | "dashes": false, 1237 | "datasource": "Prometheus", 1238 | "description": "Bits/second sent on each network interface", 1239 | "fill": 1, 1240 | "gridPos": { 1241 | "h": 6, 1242 | "w": 5, 1243 | "x": 7, 1244 | "y": 13 1245 | }, 1246 | "id": 22, 1247 | "legend": { 1248 | "avg": false, 1249 | "current": false, 1250 | "max": false, 1251 | "min": false, 1252 | "show": true, 1253 | "total": false, 1254 | "values": false 1255 | }, 1256 | "lines": true, 1257 | "linewidth": 1, 1258 | "links": [], 1259 | "nullPointMode": "null", 1260 | "options": {}, 1261 | "percentage": false, 1262 | "pointradius": 2, 1263 | "points": false, 1264 | "renderer": "flot", 1265 | "seriesOverrides": [], 1266 | "spaceLength": 10, 1267 | "stack": false, 1268 | "steppedLine": false, 1269 | "targets": [ 1270 | { 1271 | "expr": "rate(net_bytes_sent{job=\"vault-server\"}[1m])*8", 1272 | "format": "time_series", 1273 | "intervalFactor": 1, 1274 | "legendFormat": "network-bits-sent-vault-1-server", 1275 | "refId": "A" 1276 | } 1277 | ], 1278 | "thresholds": [], 1279 | "timeFrom": null, 1280 | "timeRegions": [], 1281 | "timeShift": null, 1282 | "title": "Vault Network Traffic Sent", 1283 | "tooltip": { 1284 | "shared": true, 1285 | "sort": 0, 1286 | "value_type": "individual" 1287 | }, 1288 | "type": "graph", 1289 | "xaxis": { 1290 | "buckets": null, 1291 | "mode": "time", 1292 | "name": null, 1293 | "show": true, 1294 | "values": [] 1295 | }, 1296 | "yaxes": [ 1297 | { 1298 | "format": "short", 1299 | "label": null, 1300 | "logBase": 1, 1301 | "max": null, 1302 | "min": null, 1303 | "show": true 1304 | }, 1305 | { 1306 | "format": "short", 1307 | "label": null, 1308 | "logBase": 1, 1309 | "max": null, 1310 | "min": null, 1311 | "show": true 1312 | } 1313 | ], 1314 | "yaxis": { 1315 | "align": false, 1316 | "alignLevel": null 1317 | } 1318 | }, 1319 | { 1320 | "aliasColors": {}, 1321 | "bars": false, 1322 | "dashLength": 10, 1323 | "dashes": false, 1324 | "datasource": "Prometheus", 1325 | "description": "Network traffic received on each network interface (bits/second)", 1326 | "fill": 1, 1327 | "gridPos": { 1328 | "h": 6, 1329 | "w": 4, 1330 | "x": 12, 1331 | "y": 13 1332 | }, 1333 | "id": 21, 1334 | "legend": { 1335 | "avg": false, 1336 | "current": false, 1337 | "max": false, 1338 | "min": false, 1339 | "show": true, 1340 | "total": false, 1341 | "values": false 1342 | }, 1343 | "lines": true, 1344 | "linewidth": 1, 1345 | "links": [], 1346 | "nullPointMode": "null", 1347 | "options": {}, 1348 | "percentage": false, 1349 | "pointradius": 2, 1350 | "points": false, 1351 | "renderer": "flot", 1352 | "seriesOverrides": [], 1353 | "spaceLength": 10, 1354 | "stack": false, 1355 | "steppedLine": false, 1356 | "targets": [ 1357 | { 1358 | "expr": "rate(net_bytes_recv{job=\"vault-server\"}[1m])*8", 1359 | "format": "time_series", 1360 | "intervalFactor": 1, 1361 | "legendFormat": "network-bits-received-vault-1-server", 1362 | "refId": "A" 1363 | } 1364 | ], 1365 | "thresholds": [], 1366 | "timeFrom": null, 1367 | "timeRegions": [], 1368 | "timeShift": null, 1369 | "title": "Vault Network Received (bits/second)", 1370 | "tooltip": { 1371 | "shared": true, 1372 | "sort": 0, 1373 | "value_type": "individual" 1374 | }, 1375 | "type": "graph", 1376 | "xaxis": { 1377 | "buckets": null, 1378 | "mode": "time", 1379 | "name": null, 1380 | "show": true, 1381 | "values": [] 1382 | }, 1383 | "yaxes": [ 1384 | { 1385 | "format": "short", 1386 | "label": null, 1387 | "logBase": 1, 1388 | "max": null, 1389 | "min": null, 1390 | "show": true 1391 | }, 1392 | { 1393 | "format": "short", 1394 | "label": null, 1395 | "logBase": 1, 1396 | "max": null, 1397 | "min": null, 1398 | "show": true 1399 | } 1400 | ], 1401 | "yaxis": { 1402 | "align": false, 1403 | "alignLevel": null 1404 | } 1405 | }, 1406 | { 1407 | "aliasColors": {}, 1408 | "bars": false, 1409 | "dashLength": 10, 1410 | "dashes": false, 1411 | "datasource": "Prometheus", 1412 | "description": "Network traffic sent from each network interface (bits/second)", 1413 | "fill": 1, 1414 | "gridPos": { 1415 | "h": 6, 1416 | "w": 4, 1417 | "x": 16, 1418 | "y": 13 1419 | }, 1420 | "id": 74, 1421 | "legend": { 1422 | "avg": false, 1423 | "current": false, 1424 | "max": false, 1425 | "min": false, 1426 | "show": true, 1427 | "total": false, 1428 | "values": false 1429 | }, 1430 | "lines": true, 1431 | "linewidth": 1, 1432 | "links": [], 1433 | "nullPointMode": "null", 1434 | "options": {}, 1435 | "percentage": false, 1436 | "pointradius": 2, 1437 | "points": false, 1438 | "renderer": "flot", 1439 | "seriesOverrides": [], 1440 | "spaceLength": 10, 1441 | "stack": false, 1442 | "steppedLine": false, 1443 | "targets": [ 1444 | { 1445 | "expr": "rate(net_bytes_sent{job=\"consul-1-server\"}[1m])*8", 1446 | "format": "time_series", 1447 | "intervalFactor": 1, 1448 | "legendFormat": "network-bits-sent-consul-1-server", 1449 | "refId": "A" 1450 | }, 1451 | { 1452 | "expr": "rate(net_bytes_sent{job=\"consul-2-server\"}[1m])*8", 1453 | "format": "time_series", 1454 | "intervalFactor": 1, 1455 | "legendFormat": "network-bits-sent-consul-2-server", 1456 | "refId": "B" 1457 | }, 1458 | { 1459 | "expr": "rate(net_bytes_sent{job=\"consul-3-server\"}[1m])*8", 1460 | "format": "time_series", 1461 | "intervalFactor": 1, 1462 | "legendFormat": "network-bits-sent-consul-3-server", 1463 | "refId": "C" 1464 | } 1465 | ], 1466 | "thresholds": [], 1467 | "timeFrom": null, 1468 | "timeRegions": [], 1469 | "timeShift": null, 1470 | "title": "Consul Network Sent (bits/second)", 1471 | "tooltip": { 1472 | "shared": true, 1473 | "sort": 0, 1474 | "value_type": "individual" 1475 | }, 1476 | "type": "graph", 1477 | "xaxis": { 1478 | "buckets": null, 1479 | "mode": "time", 1480 | "name": null, 1481 | "show": true, 1482 | "values": [] 1483 | }, 1484 | "yaxes": [ 1485 | { 1486 | "format": "short", 1487 | "label": null, 1488 | "logBase": 1, 1489 | "max": null, 1490 | "min": null, 1491 | "show": true 1492 | }, 1493 | { 1494 | "format": "short", 1495 | "label": null, 1496 | "logBase": 1, 1497 | "max": null, 1498 | "min": null, 1499 | "show": true 1500 | } 1501 | ], 1502 | "yaxis": { 1503 | "align": false, 1504 | "alignLevel": null 1505 | } 1506 | }, 1507 | { 1508 | "aliasColors": {}, 1509 | "bars": false, 1510 | "dashLength": 10, 1511 | "dashes": false, 1512 | "datasource": "Prometheus", 1513 | "description": "Network traffic received on each network interface (bits/second)", 1514 | "fill": 1, 1515 | "gridPos": { 1516 | "h": 6, 1517 | "w": 4, 1518 | "x": 20, 1519 | "y": 13 1520 | }, 1521 | "id": 75, 1522 | "legend": { 1523 | "avg": false, 1524 | "current": false, 1525 | "max": false, 1526 | "min": false, 1527 | "show": true, 1528 | "total": false, 1529 | "values": false 1530 | }, 1531 | "lines": true, 1532 | "linewidth": 1, 1533 | "links": [], 1534 | "nullPointMode": "null", 1535 | "options": {}, 1536 | "percentage": false, 1537 | "pointradius": 2, 1538 | "points": false, 1539 | "renderer": "flot", 1540 | "seriesOverrides": [], 1541 | "spaceLength": 10, 1542 | "stack": false, 1543 | "steppedLine": false, 1544 | "targets": [ 1545 | { 1546 | "expr": "rate(net_bytes_recv{job=\"consul-1-server\"}[1m])*8", 1547 | "format": "time_series", 1548 | "intervalFactor": 1, 1549 | "legendFormat": "network-bits-received-consul-1-server", 1550 | "refId": "A" 1551 | }, 1552 | { 1553 | "expr": "rate(net_bytes_recv{job=\"consul-2-server\"}[1m])*8", 1554 | "format": "time_series", 1555 | "intervalFactor": 1, 1556 | "legendFormat": "network-bits-received-consul-2-server", 1557 | "refId": "B" 1558 | }, 1559 | { 1560 | "expr": "rate(net_bytes_recv{job=\"consul-3-server\"}[1m])*8", 1561 | "format": "time_series", 1562 | "intervalFactor": 1, 1563 | "legendFormat": "network-bits-received-consul-3-server", 1564 | "refId": "C" 1565 | } 1566 | ], 1567 | "thresholds": [], 1568 | "timeFrom": null, 1569 | "timeRegions": [], 1570 | "timeShift": null, 1571 | "title": "Consul Network Received (bits/second)", 1572 | "tooltip": { 1573 | "shared": true, 1574 | "sort": 0, 1575 | "value_type": "individual" 1576 | }, 1577 | "type": "graph", 1578 | "xaxis": { 1579 | "buckets": null, 1580 | "mode": "time", 1581 | "name": null, 1582 | "show": true, 1583 | "values": [] 1584 | }, 1585 | "yaxes": [ 1586 | { 1587 | "format": "short", 1588 | "label": null, 1589 | "logBase": 1, 1590 | "max": null, 1591 | "min": null, 1592 | "show": true 1593 | }, 1594 | { 1595 | "format": "short", 1596 | "label": null, 1597 | "logBase": 1, 1598 | "max": null, 1599 | "min": null, 1600 | "show": true 1601 | } 1602 | ], 1603 | "yaxis": { 1604 | "align": false, 1605 | "alignLevel": null 1606 | } 1607 | } 1608 | ], 1609 | "title": "Network Utilisation", 1610 | "type": "row" 1611 | }, 1612 | { 1613 | "collapsed": true, 1614 | "gridPos": { 1615 | "h": 1, 1616 | "w": 24, 1617 | "x": 0, 1618 | "y": 17 1619 | }, 1620 | "id": 25, 1621 | "panels": [ 1622 | { 1623 | "content": "# File Descriptor Usage\n\nHeavy utilisation of the network due to lots of connections can often cause high utilisation of file-descriptors. There are 2 metrics that should be monitored.\n\nIf the file-nr reaches 80% of the file-max then you should alert and investigate", 1624 | "gridPos": { 1625 | "h": 6, 1626 | "w": 7, 1627 | "x": 0, 1628 | "y": 14 1629 | }, 1630 | "id": 29, 1631 | "links": [], 1632 | "mode": "markdown", 1633 | "options": {}, 1634 | "timeFrom": null, 1635 | "timeShift": null, 1636 | "title": "File Descriptor Usage", 1637 | "type": "text" 1638 | }, 1639 | { 1640 | "aliasColors": {}, 1641 | "bars": false, 1642 | "dashLength": 10, 1643 | "dashes": false, 1644 | "description": "Number of file handles being used across all processes on host as a percentage of total number of available file handles", 1645 | "fill": 1, 1646 | "gridPos": { 1647 | "h": 6, 1648 | "w": 8, 1649 | "x": 7, 1650 | "y": 14 1651 | }, 1652 | "id": 27, 1653 | "legend": { 1654 | "avg": false, 1655 | "current": false, 1656 | "max": false, 1657 | "min": false, 1658 | "show": true, 1659 | "total": false, 1660 | "values": false 1661 | }, 1662 | "lines": true, 1663 | "linewidth": 1, 1664 | "links": [], 1665 | "nullPointMode": "null", 1666 | "options": {}, 1667 | "percentage": false, 1668 | "pointradius": 2, 1669 | "points": false, 1670 | "renderer": "flot", 1671 | "seriesOverrides": [], 1672 | "spaceLength": 10, 1673 | "stack": false, 1674 | "steppedLine": false, 1675 | "targets": [ 1676 | { 1677 | "expr": "linux_sysctl_fs_file_nr{job=\"vault-server\"}/linux_sysctl_fs_file_max{job=\"vault-server\"} * 100", 1678 | "format": "time_series", 1679 | "hide": false, 1680 | "intervalFactor": 1, 1681 | "legendFormat": "file-descriptor-used-percent-vault-server", 1682 | "refId": "A" 1683 | } 1684 | ], 1685 | "thresholds": [], 1686 | "timeFrom": null, 1687 | "timeRegions": [], 1688 | "timeShift": null, 1689 | "title": "Vault File Descriptor Usage Percentage", 1690 | "tooltip": { 1691 | "shared": true, 1692 | "sort": 0, 1693 | "value_type": "individual" 1694 | }, 1695 | "type": "graph", 1696 | "xaxis": { 1697 | "buckets": null, 1698 | "mode": "time", 1699 | "name": null, 1700 | "show": true, 1701 | "values": [] 1702 | }, 1703 | "yaxes": [ 1704 | { 1705 | "format": "short", 1706 | "label": null, 1707 | "logBase": 1, 1708 | "max": null, 1709 | "min": null, 1710 | "show": true 1711 | }, 1712 | { 1713 | "format": "short", 1714 | "label": null, 1715 | "logBase": 1, 1716 | "max": null, 1717 | "min": null, 1718 | "show": true 1719 | } 1720 | ], 1721 | "yaxis": { 1722 | "align": false, 1723 | "alignLevel": null 1724 | } 1725 | }, 1726 | { 1727 | "aliasColors": {}, 1728 | "bars": false, 1729 | "dashLength": 10, 1730 | "dashes": false, 1731 | "description": "Number of file handles being used across all processes on host as a percentage of total number of available file handles", 1732 | "fill": 1, 1733 | "gridPos": { 1734 | "h": 6, 1735 | "w": 9, 1736 | "x": 15, 1737 | "y": 14 1738 | }, 1739 | "id": 76, 1740 | "legend": { 1741 | "avg": false, 1742 | "current": false, 1743 | "max": false, 1744 | "min": false, 1745 | "show": true, 1746 | "total": false, 1747 | "values": false 1748 | }, 1749 | "lines": true, 1750 | "linewidth": 1, 1751 | "links": [], 1752 | "nullPointMode": "null", 1753 | "options": {}, 1754 | "percentage": false, 1755 | "pointradius": 2, 1756 | "points": false, 1757 | "renderer": "flot", 1758 | "seriesOverrides": [], 1759 | "spaceLength": 10, 1760 | "stack": false, 1761 | "steppedLine": false, 1762 | "targets": [ 1763 | { 1764 | "expr": "linux_sysctl_fs_file_nr{job=\"consul-1-server\"}/linux_sysctl_fs_file_max{job=\"consul-1-server\"} * 100", 1765 | "format": "time_series", 1766 | "hide": false, 1767 | "intervalFactor": 1, 1768 | "legendFormat": "file-descriptor-used-percent-consul-1-server", 1769 | "refId": "A" 1770 | }, 1771 | { 1772 | "expr": "linux_sysctl_fs_file_nr{job=\"consul-2-server\"}/linux_sysctl_fs_file_max{job=\"consul-2-server\"} * 100", 1773 | "format": "time_series", 1774 | "interval": "", 1775 | "intervalFactor": 1, 1776 | "legendFormat": "file-descriptor-used-percent-consul-2-server", 1777 | "refId": "B" 1778 | }, 1779 | { 1780 | "expr": "linux_sysctl_fs_file_nr{job=\"consul-3-server\"}/linux_sysctl_fs_file_max{job=\"consul-3-server\"} * 100", 1781 | "format": "time_series", 1782 | "intervalFactor": 1, 1783 | "legendFormat": "file-descriptor-used-percent-consul-3-server", 1784 | "refId": "C" 1785 | } 1786 | ], 1787 | "thresholds": [], 1788 | "timeFrom": null, 1789 | "timeRegions": [], 1790 | "timeShift": null, 1791 | "title": "Consul File Descriptor Usage Percentage", 1792 | "tooltip": { 1793 | "shared": true, 1794 | "sort": 0, 1795 | "value_type": "individual" 1796 | }, 1797 | "type": "graph", 1798 | "xaxis": { 1799 | "buckets": null, 1800 | "mode": "time", 1801 | "name": null, 1802 | "show": true, 1803 | "values": [] 1804 | }, 1805 | "yaxes": [ 1806 | { 1807 | "format": "short", 1808 | "label": null, 1809 | "logBase": 1, 1810 | "max": null, 1811 | "min": null, 1812 | "show": true 1813 | }, 1814 | { 1815 | "format": "short", 1816 | "label": null, 1817 | "logBase": 1, 1818 | "max": null, 1819 | "min": null, 1820 | "show": true 1821 | } 1822 | ], 1823 | "yaxis": { 1824 | "align": false, 1825 | "alignLevel": null 1826 | } 1827 | } 1828 | ], 1829 | "title": "File Descriptor Usage", 1830 | "type": "row" 1831 | }, 1832 | { 1833 | "collapsed": true, 1834 | "gridPos": { 1835 | "h": 1, 1836 | "w": 24, 1837 | "x": 0, 1838 | "y": 18 1839 | }, 1840 | "id": 33, 1841 | "panels": [ 1842 | { 1843 | "content": "# Slow Consul Response Time - Vault\nThese metrics indicate how long it takes for Consul to handle requests from Vault\n", 1844 | "gridPos": { 1845 | "h": 7, 1846 | "w": 5, 1847 | "x": 0, 1848 | "y": 5 1849 | }, 1850 | "id": 31, 1851 | "links": [], 1852 | "mode": "markdown", 1853 | "options": {}, 1854 | "timeFrom": null, 1855 | "timeShift": null, 1856 | "title": "Slow Consul Response Time - Vault", 1857 | "type": "text" 1858 | }, 1859 | { 1860 | "aliasColors": {}, 1861 | "bars": false, 1862 | "dashLength": 10, 1863 | "dashes": false, 1864 | "datasource": "Prometheus", 1865 | "description": "", 1866 | "fill": 1, 1867 | "gridPos": { 1868 | "h": 7, 1869 | "w": 19, 1870 | "x": 5, 1871 | "y": 5 1872 | }, 1873 | "id": 35, 1874 | "legend": { 1875 | "avg": false, 1876 | "current": false, 1877 | "max": false, 1878 | "min": false, 1879 | "show": true, 1880 | "total": false, 1881 | "values": false 1882 | }, 1883 | "lines": true, 1884 | "linewidth": 1, 1885 | "links": [], 1886 | "nullPointMode": "null", 1887 | "options": {}, 1888 | "percentage": false, 1889 | "pointradius": 2, 1890 | "points": false, 1891 | "renderer": "flot", 1892 | "seriesOverrides": [], 1893 | "spaceLength": 10, 1894 | "stack": false, 1895 | "steppedLine": false, 1896 | "targets": [ 1897 | { 1898 | "expr": "delta(consul_get_upper{job=\"vault-server\"}[5m])", 1899 | "format": "time_series", 1900 | "hide": false, 1901 | "intervalFactor": 1, 1902 | "legendFormat": "get-upper-vault-server", 1903 | "refId": "A" 1904 | } 1905 | ], 1906 | "thresholds": [], 1907 | "timeFrom": null, 1908 | "timeRegions": [], 1909 | "timeShift": null, 1910 | "title": "Upper Value of Operations against Consul Storage Backend", 1911 | "tooltip": { 1912 | "shared": true, 1913 | "sort": 0, 1914 | "value_type": "individual" 1915 | }, 1916 | "type": "graph", 1917 | "xaxis": { 1918 | "buckets": null, 1919 | "mode": "time", 1920 | "name": null, 1921 | "show": true, 1922 | "values": [] 1923 | }, 1924 | "yaxes": [ 1925 | { 1926 | "format": "short", 1927 | "label": null, 1928 | "logBase": 1, 1929 | "max": null, 1930 | "min": null, 1931 | "show": true 1932 | }, 1933 | { 1934 | "format": "short", 1935 | "label": null, 1936 | "logBase": 1, 1937 | "max": null, 1938 | "min": null, 1939 | "show": true 1940 | } 1941 | ], 1942 | "yaxis": { 1943 | "align": false, 1944 | "alignLevel": null 1945 | } 1946 | } 1947 | ], 1948 | "title": "Slow Consul Response Time - Vault", 1949 | "type": "row" 1950 | }, 1951 | { 1952 | "collapsed": true, 1953 | "gridPos": { 1954 | "h": 1, 1955 | "w": 24, 1956 | "x": 0, 1957 | "y": 19 1958 | }, 1959 | "id": 37, 1960 | "panels": [ 1961 | { 1962 | "content": "# Vault Write Ahead Logs Processing\n\nThe Vault write-ahead logs (WALs) are used to replicate Vault between clusters. Surprisingly, the WAL's are kept even if replication is not currently enabled. The WAL is purged every few seconds by a garbage collector. But if Vault is under heavy load, the WAL may start to grow, putting pressure on Consul.\n\n* vault_wal_persist: WALs Amount of time required to persist the Vault write-ahead logs (WAL) to the Consul backend.\n* vault_wal_flushReady: Amount of time required to flush the Vault write-ahead logs (WAL) to the persist queue\n\nLook for flushReady over 500ms, or vault.wal.persist is over 1000ms.", 1963 | "gridPos": { 1964 | "h": 9, 1965 | "w": 8, 1966 | "x": 0, 1967 | "y": 6 1968 | }, 1969 | "id": 41, 1970 | "links": [], 1971 | "mode": "markdown", 1972 | "options": {}, 1973 | "timeFrom": null, 1974 | "timeShift": null, 1975 | "title": "Vault WAL Processing", 1976 | "type": "text" 1977 | }, 1978 | { 1979 | "alert": { 1980 | "conditions": [ 1981 | { 1982 | "evaluator": { 1983 | "params": [ 1984 | 500 1985 | ], 1986 | "type": "gt" 1987 | }, 1988 | "operator": { 1989 | "type": "and" 1990 | }, 1991 | "query": { 1992 | "params": [ 1993 | "A", 1994 | "5m", 1995 | "now" 1996 | ] 1997 | }, 1998 | "reducer": { 1999 | "params": [], 2000 | "type": "avg" 2001 | }, 2002 | "type": "query" 2003 | } 2004 | ], 2005 | "executionErrorState": "alerting", 2006 | "for": "5m", 2007 | "frequency": "1m", 2008 | "handler": 1, 2009 | "name": "Vault WAL FlushReady alert", 2010 | "noDataState": "keep_state", 2011 | "notifications": [] 2012 | }, 2013 | "aliasColors": {}, 2014 | "bars": false, 2015 | "dashLength": 10, 2016 | "dashes": false, 2017 | "datasource": "Prometheus", 2018 | "description": "Amount of time required to flush the Vault write-ahead logs (WAL) to the persist queue", 2019 | "fill": 1, 2020 | "gridPos": { 2021 | "h": 9, 2022 | "w": 8, 2023 | "x": 8, 2024 | "y": 6 2025 | }, 2026 | "id": 39, 2027 | "legend": { 2028 | "avg": false, 2029 | "current": false, 2030 | "max": false, 2031 | "min": false, 2032 | "show": true, 2033 | "total": false, 2034 | "values": false 2035 | }, 2036 | "lines": true, 2037 | "linewidth": 1, 2038 | "links": [], 2039 | "nullPointMode": "null", 2040 | "options": {}, 2041 | "percentage": false, 2042 | "pointradius": 2, 2043 | "points": false, 2044 | "renderer": "flot", 2045 | "seriesOverrides": [], 2046 | "spaceLength": 10, 2047 | "stack": false, 2048 | "steppedLine": false, 2049 | "targets": [ 2050 | { 2051 | "expr": "vault_wal_flushReady_upper{job=\"vault-server\"}", 2052 | "format": "time_series", 2053 | "hide": false, 2054 | "interval": "", 2055 | "intervalFactor": 1, 2056 | "legendFormat": "vault-wal-flushReady-upper-vault-server", 2057 | "refId": "A" 2058 | } 2059 | ], 2060 | "thresholds": [ 2061 | { 2062 | "colorMode": "critical", 2063 | "fill": true, 2064 | "line": true, 2065 | "op": "gt", 2066 | "value": 500, 2067 | "yaxis": "left" 2068 | } 2069 | ], 2070 | "timeFrom": null, 2071 | "timeRegions": [], 2072 | "timeShift": null, 2073 | "title": "Vault WAL FlushReady", 2074 | "tooltip": { 2075 | "shared": true, 2076 | "sort": 0, 2077 | "value_type": "individual" 2078 | }, 2079 | "type": "graph", 2080 | "xaxis": { 2081 | "buckets": null, 2082 | "mode": "time", 2083 | "name": null, 2084 | "show": true, 2085 | "values": [] 2086 | }, 2087 | "yaxes": [ 2088 | { 2089 | "format": "short", 2090 | "label": "ms", 2091 | "logBase": 1, 2092 | "max": null, 2093 | "min": null, 2094 | "show": true 2095 | }, 2096 | { 2097 | "format": "short", 2098 | "label": null, 2099 | "logBase": 1, 2100 | "max": null, 2101 | "min": null, 2102 | "show": true 2103 | } 2104 | ], 2105 | "yaxis": { 2106 | "align": false, 2107 | "alignLevel": null 2108 | } 2109 | }, 2110 | { 2111 | "aliasColors": {}, 2112 | "bars": false, 2113 | "dashLength": 10, 2114 | "dashes": false, 2115 | "datasource": "Prometheus", 2116 | "description": "WALs Amount of time required to persist the Vault write-ahead logs (WAL) to the Consul backend", 2117 | "fill": 1, 2118 | "gridPos": { 2119 | "h": 9, 2120 | "w": 8, 2121 | "x": 16, 2122 | "y": 6 2123 | }, 2124 | "id": 43, 2125 | "legend": { 2126 | "avg": false, 2127 | "current": false, 2128 | "max": false, 2129 | "min": false, 2130 | "show": true, 2131 | "total": false, 2132 | "values": false 2133 | }, 2134 | "lines": true, 2135 | "linewidth": 1, 2136 | "links": [], 2137 | "nullPointMode": "null", 2138 | "options": {}, 2139 | "percentage": false, 2140 | "pointradius": 2, 2141 | "points": false, 2142 | "renderer": "flot", 2143 | "seriesOverrides": [], 2144 | "spaceLength": 10, 2145 | "stack": false, 2146 | "steppedLine": false, 2147 | "targets": [ 2148 | { 2149 | "expr": "vault_wal_persistWALs_upper{job=\"vault-server\"}", 2150 | "format": "time_series", 2151 | "intervalFactor": 1, 2152 | "legendFormat": "vault-wal-persistWals-upper-vault-server", 2153 | "refId": "A" 2154 | } 2155 | ], 2156 | "thresholds": [], 2157 | "timeFrom": null, 2158 | "timeRegions": [], 2159 | "timeShift": null, 2160 | "title": "Vault WAL Persist", 2161 | "tooltip": { 2162 | "shared": true, 2163 | "sort": 0, 2164 | "value_type": "individual" 2165 | }, 2166 | "type": "graph", 2167 | "xaxis": { 2168 | "buckets": null, 2169 | "mode": "time", 2170 | "name": null, 2171 | "show": true, 2172 | "values": [] 2173 | }, 2174 | "yaxes": [ 2175 | { 2176 | "decimals": null, 2177 | "format": "short", 2178 | "label": "ms", 2179 | "logBase": 1, 2180 | "max": null, 2181 | "min": null, 2182 | "show": true 2183 | }, 2184 | { 2185 | "format": "short", 2186 | "label": null, 2187 | "logBase": 1, 2188 | "max": null, 2189 | "min": null, 2190 | "show": true 2191 | } 2192 | ], 2193 | "yaxis": { 2194 | "align": false, 2195 | "alignLevel": null 2196 | } 2197 | } 2198 | ], 2199 | "title": "Vault WAL Processing", 2200 | "type": "row" 2201 | }, 2202 | { 2203 | "collapsed": false, 2204 | "gridPos": { 2205 | "h": 1, 2206 | "w": 24, 2207 | "x": 0, 2208 | "y": 20 2209 | }, 2210 | "id": 45, 2211 | "panels": [], 2212 | "title": "Consul Leadership Metrics", 2213 | "type": "row" 2214 | }, 2215 | { 2216 | "aliasColors": {}, 2217 | "bars": false, 2218 | "cacheTimeout": null, 2219 | "dashLength": 10, 2220 | "dashes": false, 2221 | "datasource": "Prometheus", 2222 | "description": "Increments whenever a Consul server becomes a leader", 2223 | "fill": 1, 2224 | "gridPos": { 2225 | "h": 6, 2226 | "w": 12, 2227 | "x": 0, 2228 | "y": 21 2229 | }, 2230 | "id": 49, 2231 | "legend": { 2232 | "avg": false, 2233 | "current": false, 2234 | "max": false, 2235 | "min": false, 2236 | "show": true, 2237 | "total": false, 2238 | "values": false 2239 | }, 2240 | "lines": true, 2241 | "linewidth": 1, 2242 | "links": [], 2243 | "nullPointMode": "null", 2244 | "options": {}, 2245 | "percentage": false, 2246 | "pointradius": 2, 2247 | "points": false, 2248 | "renderer": "flot", 2249 | "seriesOverrides": [], 2250 | "spaceLength": 10, 2251 | "stack": false, 2252 | "steppedLine": false, 2253 | "targets": [ 2254 | { 2255 | "expr": "consul_raft_state_leader{job=\"consul-1-server\"}", 2256 | "format": "time_series", 2257 | "hide": false, 2258 | "instant": false, 2259 | "interval": "", 2260 | "intervalFactor": 1, 2261 | "legendFormat": "consul-1-server", 2262 | "refId": "A" 2263 | }, 2264 | { 2265 | "expr": "consul_raft_state_leader{job=\"consul-2-server\"}", 2266 | "format": "time_series", 2267 | "instant": false, 2268 | "intervalFactor": 1, 2269 | "legendFormat": "consul-2-server", 2270 | "refId": "B" 2271 | }, 2272 | { 2273 | "expr": "consul_raft_state_leader{job=\"consul-3-server\"}", 2274 | "format": "time_series", 2275 | "instant": false, 2276 | "intervalFactor": 1, 2277 | "legendFormat": "consul-3-server", 2278 | "refId": "C" 2279 | } 2280 | ], 2281 | "thresholds": [], 2282 | "timeFrom": null, 2283 | "timeRegions": [], 2284 | "timeShift": null, 2285 | "title": "Consul Raft State Leader", 2286 | "tooltip": { 2287 | "shared": true, 2288 | "sort": 0, 2289 | "value_type": "individual" 2290 | }, 2291 | "type": "graph", 2292 | "xaxis": { 2293 | "buckets": null, 2294 | "mode": "time", 2295 | "name": null, 2296 | "show": true, 2297 | "values": [] 2298 | }, 2299 | "yaxes": [ 2300 | { 2301 | "format": "short", 2302 | "label": null, 2303 | "logBase": 1, 2304 | "max": null, 2305 | "min": null, 2306 | "show": true 2307 | }, 2308 | { 2309 | "format": "short", 2310 | "label": null, 2311 | "logBase": 1, 2312 | "max": null, 2313 | "min": null, 2314 | "show": true 2315 | } 2316 | ], 2317 | "yaxis": { 2318 | "align": false, 2319 | "alignLevel": null 2320 | } 2321 | }, 2322 | { 2323 | "aliasColors": {}, 2324 | "bars": false, 2325 | "dashLength": 10, 2326 | "dashes": false, 2327 | "datasource": "Prometheus", 2328 | "description": "Increments whenever a Consul server starts an election", 2329 | "fill": 1, 2330 | "gridPos": { 2331 | "h": 6, 2332 | "w": 12, 2333 | "x": 12, 2334 | "y": 21 2335 | }, 2336 | "id": 47, 2337 | "legend": { 2338 | "avg": false, 2339 | "current": false, 2340 | "max": false, 2341 | "min": false, 2342 | "show": true, 2343 | "total": false, 2344 | "values": false 2345 | }, 2346 | "lines": true, 2347 | "linewidth": 1, 2348 | "links": [], 2349 | "nullPointMode": "null", 2350 | "options": {}, 2351 | "percentage": false, 2352 | "pointradius": 2, 2353 | "points": false, 2354 | "renderer": "flot", 2355 | "seriesOverrides": [], 2356 | "spaceLength": 10, 2357 | "stack": false, 2358 | "steppedLine": false, 2359 | "targets": [ 2360 | { 2361 | "expr": "consul_raft_state_candidate{job=\"consul-1-server\"}\n", 2362 | "format": "time_series", 2363 | "hide": false, 2364 | "intervalFactor": 1, 2365 | "legendFormat": "candidate-consul-1-server", 2366 | "refId": "A" 2367 | }, 2368 | { 2369 | "expr": "consul_raft_state_candidate{job=\"consul-2-server\"}\n", 2370 | "format": "time_series", 2371 | "intervalFactor": 1, 2372 | "legendFormat": "candidate-consul-2-server", 2373 | "refId": "B" 2374 | }, 2375 | { 2376 | "expr": "consul_raft_state_candidate{job=\"consul-3-server\"}\n", 2377 | "format": "time_series", 2378 | "intervalFactor": 1, 2379 | "legendFormat": "candidate-consul-3-server", 2380 | "refId": "C" 2381 | } 2382 | ], 2383 | "thresholds": [], 2384 | "timeFrom": null, 2385 | "timeRegions": [], 2386 | "timeShift": null, 2387 | "title": "Consul Raft State Candidate", 2388 | "tooltip": { 2389 | "shared": true, 2390 | "sort": 0, 2391 | "value_type": "individual" 2392 | }, 2393 | "type": "graph", 2394 | "xaxis": { 2395 | "buckets": null, 2396 | "mode": "time", 2397 | "name": null, 2398 | "show": true, 2399 | "values": [] 2400 | }, 2401 | "yaxes": [ 2402 | { 2403 | "format": "short", 2404 | "label": null, 2405 | "logBase": 1, 2406 | "max": null, 2407 | "min": null, 2408 | "show": true 2409 | }, 2410 | { 2411 | "format": "short", 2412 | "label": null, 2413 | "logBase": 1, 2414 | "max": null, 2415 | "min": null, 2416 | "show": true 2417 | } 2418 | ], 2419 | "yaxis": { 2420 | "align": false, 2421 | "alignLevel": null 2422 | } 2423 | }, 2424 | { 2425 | "collapsed": true, 2426 | "gridPos": { 2427 | "h": 1, 2428 | "w": 24, 2429 | "x": 0, 2430 | "y": 27 2431 | }, 2432 | "id": 52, 2433 | "panels": [ 2434 | { 2435 | "aliasColors": {}, 2436 | "bars": false, 2437 | "dashLength": 10, 2438 | "dashes": false, 2439 | "datasource": "Prometheus", 2440 | "description": "Tracks the overall health of the server cluster. If all servers considered healthy by Autopilot, this will be set to 1. If any are unhealthy, this will be 0.", 2441 | "fill": 1, 2442 | "gridPos": { 2443 | "h": 5, 2444 | "w": 24, 2445 | "x": 0, 2446 | "y": 8 2447 | }, 2448 | "id": 54, 2449 | "legend": { 2450 | "avg": false, 2451 | "current": false, 2452 | "max": false, 2453 | "min": false, 2454 | "show": true, 2455 | "total": false, 2456 | "values": false 2457 | }, 2458 | "lines": true, 2459 | "linewidth": 1, 2460 | "links": [], 2461 | "nullPointMode": "null", 2462 | "options": {}, 2463 | "percentage": false, 2464 | "pointradius": 2, 2465 | "points": false, 2466 | "renderer": "flot", 2467 | "seriesOverrides": [], 2468 | "spaceLength": 10, 2469 | "stack": false, 2470 | "steppedLine": false, 2471 | "targets": [ 2472 | { 2473 | "expr": "consul_autopilot_healthy{job=\"consul-1-server\"}", 2474 | "format": "time_series", 2475 | "hide": false, 2476 | "intervalFactor": 1, 2477 | "legendFormat": "consul-autopilot-healthy-consul-1-server", 2478 | "refId": "A" 2479 | }, 2480 | { 2481 | "expr": "consul_autopilot_healthy{job=\"consul-2-server\"}", 2482 | "format": "time_series", 2483 | "intervalFactor": 1, 2484 | "legendFormat": "consul-autopilot-healthy-consul-2-server", 2485 | "refId": "B" 2486 | }, 2487 | { 2488 | "expr": "consul_autopilot_healthy{job=\"consul-3-server\"}", 2489 | "format": "time_series", 2490 | "intervalFactor": 1, 2491 | "legendFormat": "consul-autopilot-healthy-consul-3-server", 2492 | "refId": "C" 2493 | } 2494 | ], 2495 | "thresholds": [], 2496 | "timeFrom": null, 2497 | "timeRegions": [], 2498 | "timeShift": null, 2499 | "title": "Consul Autopilot Healthy", 2500 | "tooltip": { 2501 | "shared": true, 2502 | "sort": 0, 2503 | "value_type": "individual" 2504 | }, 2505 | "type": "graph", 2506 | "xaxis": { 2507 | "buckets": null, 2508 | "mode": "time", 2509 | "name": null, 2510 | "show": true, 2511 | "values": [] 2512 | }, 2513 | "yaxes": [ 2514 | { 2515 | "format": "short", 2516 | "label": null, 2517 | "logBase": 1, 2518 | "max": null, 2519 | "min": null, 2520 | "show": true 2521 | }, 2522 | { 2523 | "format": "short", 2524 | "label": null, 2525 | "logBase": 1, 2526 | "max": null, 2527 | "min": null, 2528 | "show": true 2529 | } 2530 | ], 2531 | "yaxis": { 2532 | "align": false, 2533 | "alignLevel": null 2534 | } 2535 | } 2536 | ], 2537 | "title": "Consul Cluster Health", 2538 | "type": "row" 2539 | }, 2540 | { 2541 | "collapsed": false, 2542 | "gridPos": { 2543 | "h": 1, 2544 | "w": 24, 2545 | "x": 0, 2546 | "y": 28 2547 | }, 2548 | "id": 56, 2549 | "panels": [], 2550 | "title": "Consul Garbage Collection", 2551 | "type": "row" 2552 | }, 2553 | { 2554 | "content": "\n# Consul Gabarge Collection\n\nGC pause is a \"stop-the-world\" event, meaning that all runtime threads are blocked until GC completes. Normally these pauses last only a few nanoseconds. But if memory usage is high, the Go runtime may GC so frequently that it starts to slow down Consul.\n\n\n\n", 2555 | "gridPos": { 2556 | "h": 6, 2557 | "w": 7, 2558 | "x": 0, 2559 | "y": 29 2560 | }, 2561 | "id": 58, 2562 | "links": [], 2563 | "mode": "markdown", 2564 | "options": {}, 2565 | "timeFrom": null, 2566 | "timeShift": null, 2567 | "title": "Consul Garbage Collection", 2568 | "type": "text" 2569 | }, 2570 | { 2571 | "alert": { 2572 | "conditions": [ 2573 | { 2574 | "evaluator": { 2575 | "params": [ 2576 | 5 2577 | ], 2578 | "type": "gt" 2579 | }, 2580 | "operator": { 2581 | "type": "and" 2582 | }, 2583 | "query": { 2584 | "params": [ 2585 | "A", 2586 | "5m", 2587 | "now" 2588 | ] 2589 | }, 2590 | "reducer": { 2591 | "params": [], 2592 | "type": "avg" 2593 | }, 2594 | "type": "query" 2595 | } 2596 | ], 2597 | "executionErrorState": "alerting", 2598 | "for": "5m", 2599 | "frequency": "1m", 2600 | "handler": 1, 2601 | "name": "Consul Garbage Collection alert", 2602 | "noDataState": "no_data", 2603 | "notifications": [] 2604 | }, 2605 | "aliasColors": {}, 2606 | "bars": false, 2607 | "dashLength": 10, 2608 | "dashes": false, 2609 | "datasource": "Prometheus", 2610 | "description": "Number of nanoseconds consumed by stop-the-world garbage collection (GC) pauses since Consul started", 2611 | "fill": 1, 2612 | "gridPos": { 2613 | "h": 6, 2614 | "w": 16, 2615 | "x": 7, 2616 | "y": 29 2617 | }, 2618 | "id": 60, 2619 | "legend": { 2620 | "avg": false, 2621 | "current": false, 2622 | "max": false, 2623 | "min": false, 2624 | "show": true, 2625 | "total": false, 2626 | "values": false 2627 | }, 2628 | "lines": true, 2629 | "linewidth": 1, 2630 | "links": [], 2631 | "nullPointMode": "null", 2632 | "options": {}, 2633 | "percentage": false, 2634 | "pointradius": 2, 2635 | "points": false, 2636 | "renderer": "flot", 2637 | "seriesOverrides": [], 2638 | "spaceLength": 10, 2639 | "stack": false, 2640 | "steppedLine": false, 2641 | "targets": [ 2642 | { 2643 | "expr": "rate(consul_runtime_total_gc_pause_ns{job=\"consul-1-server\"}[1m])/1000000000", 2644 | "format": "time_series", 2645 | "interval": "", 2646 | "intervalFactor": 1, 2647 | "legendFormat": "consul-runtime-total-gc-pause-ns-consul-1-server", 2648 | "refId": "A" 2649 | }, 2650 | { 2651 | "expr": "rate(consul_runtime_total_gc_pause_ns{job=\"consul-2-server\"}[1m])/1000000000", 2652 | "format": "time_series", 2653 | "intervalFactor": 1, 2654 | "legendFormat": "consul-runtime-total-gc-pause-ns-consul-2-server", 2655 | "refId": "B" 2656 | }, 2657 | { 2658 | "expr": "rate(consul_runtime_total_gc_pause_ns{job=\"consul-3-server\"}[1m])/1000000000", 2659 | "format": "time_series", 2660 | "intervalFactor": 1, 2661 | "legendFormat": "consul-runtime-total-gc-pause-ns-consul-3-server", 2662 | "refId": "C" 2663 | } 2664 | ], 2665 | "thresholds": [ 2666 | { 2667 | "colorMode": "critical", 2668 | "fill": true, 2669 | "line": true, 2670 | "op": "gt", 2671 | "value": 5 2672 | } 2673 | ], 2674 | "timeFrom": null, 2675 | "timeRegions": [], 2676 | "timeShift": null, 2677 | "title": "Consul Garbage Collection", 2678 | "tooltip": { 2679 | "shared": true, 2680 | "sort": 0, 2681 | "value_type": "individual" 2682 | }, 2683 | "type": "graph", 2684 | "xaxis": { 2685 | "buckets": null, 2686 | "mode": "time", 2687 | "name": null, 2688 | "show": true, 2689 | "values": [] 2690 | }, 2691 | "yaxes": [ 2692 | { 2693 | "decimals": null, 2694 | "format": "short", 2695 | "label": "seconds", 2696 | "logBase": 1, 2697 | "max": null, 2698 | "min": null, 2699 | "show": true 2700 | }, 2701 | { 2702 | "format": "short", 2703 | "label": null, 2704 | "logBase": 1, 2705 | "max": null, 2706 | "min": null, 2707 | "show": true 2708 | } 2709 | ], 2710 | "yaxis": { 2711 | "align": false, 2712 | "alignLevel": null 2713 | } 2714 | } 2715 | ], 2716 | "refresh": false, 2717 | "schemaVersion": 18, 2718 | "style": "dark", 2719 | "tags": [], 2720 | "templating": { 2721 | "list": [] 2722 | }, 2723 | "time": { 2724 | "from": "now-15m", 2725 | "to": "now" 2726 | }, 2727 | "timepicker": { 2728 | "refresh_intervals": [ 2729 | "5s", 2730 | "10s", 2731 | "30s", 2732 | "1m", 2733 | "5m", 2734 | "15m", 2735 | "30m", 2736 | "1h", 2737 | "2h", 2738 | "1d" 2739 | ], 2740 | "time_options": [ 2741 | "5m", 2742 | "15m", 2743 | "1h", 2744 | "6h", 2745 | "12h", 2746 | "24h", 2747 | "2d", 2748 | "7d", 2749 | "30d" 2750 | ] 2751 | }, 2752 | "timezone": "", 2753 | "title": "Vault Consul Dashboard", 2754 | "uid": "9VIZSOfZz", 2755 | "version": 1 2756 | } 2757 | } 2758 | -------------------------------------------------------------------------------- /init-vault.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Initialise Vault. Store keys locally FOR DEMO PURPOSES ONLY 4 | 5 | vault operator init -key-shares=1 -key-threshold=1 > init-output.txt 2>&1 6 | 7 | echo "Unseal: "$(grep Unseal init-output.txt | cut -d' ' -f4) >> vault.txt 8 | echo "Token: "$(grep Token init-output.txt | cut -d' ' -f4) >> vault.txt 9 | rm init-output.txt 10 | 11 | # Unseal Vault 12 | vault operator unseal $(cat vault.txt | grep Unseal | cut -f2 -d' ') 13 | 14 | # Login to Vault 15 | vault login $(cat vault.txt | grep Token | cut -f2 -d' ') 16 | 17 | # Configure rsyslog audit device 18 | 19 | vault audit enable syslog 20 | 21 | # Configure secret backend 22 | 23 | vault secrets enable -path=secret/ kv 24 | 25 | # Copy over Vault testing scripts to demonstrate storage backend under heavy reads/writes 26 | 27 | cp /vagrant/test-put-vault.sh . 28 | cp /vagrant/test-get-vault.sh . 29 | -------------------------------------------------------------------------------- /install-consul.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script can be used to install Consul as per the deployment guide: 3 | # https://learn.hashicorp.com/consul/datacenter-deploy/deployment-guide 4 | 5 | readonly DEFAULT_INSTALL_PATH="/usr/local/bin/consul" 6 | readonly DEFAULT_CONSUL_USER="consul" 7 | readonly DEFAULT_CONSUL_PATH="/etc/consul.d" 8 | readonly DEFAULT_CONSUL_AGENT_CONFIG="consul.hcl" 9 | readonly DEFAULT_CONSUL_SERVER_CONFIG="server.hcl" 10 | readonly DEFAULT_CONSUL_SERVICE_NAME="consul" 11 | readonly DEFAULT_CONSUL_DATA_DIR="/opt/consul" 12 | readonly CONSUL_BIN="consul" 13 | readonly DEFAULT_CONSUL_SERVICE="/etc/systemd/system/consul.service" 14 | readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 15 | readonly TMP_DIR="/tmp/install" 16 | readonly SCRIPT_NAME="$(basename "$0")" 17 | readonly SUPPLIED_CONSUL_BIN="consul" 18 | readonly ADVERTISE_ADDRESS="${1}" 19 | readonly RETRY_JOIN="${2}" 20 | readonly DATACENTER="${3}" 21 | readonly BOOTSTRAP_EXPECT=${4} 22 | readonly IS_CONSUL_SERVER=${5} 23 | 24 | function print_usage { 25 | echo 26 | echo "Usage: install-consul [OPTIONS]" 27 | echo "Options:" 28 | echo "This script can be used to install Consul and its dependencies." 29 | echo 30 | 31 | } 32 | 33 | function log { 34 | local -r level="$1" 35 | local -r func="$2" 36 | local -r message="$3" 37 | local -r timestamp=$(date +"%Y-%m-%d %H:%M:%S") 38 | >&2 echo -e "${timestamp} [${level}] [${SCRIPT_NAME}:${func}] ${message}" 39 | } 40 | 41 | function assert_not_empty { 42 | local func="assert_not_empty" 43 | local -r arg_name="$1" 44 | local -r arg_value="$2" 45 | 46 | if [[ -z "${arg_value}" ]]; then 47 | log "ERROR" ${func} "The value for '${arg_name}' cannot be empty" 48 | print_usage 49 | exit 1 50 | fi 51 | } 52 | 53 | function has_apt_get { 54 | [ -n "$(command -v apt-get)" ] 55 | } 56 | 57 | function has_yum { 58 | [ -n "$(command -v yum)" ] 59 | } 60 | 61 | function install_dependencies { 62 | local func="install_dependencies" 63 | log "INFO" ${func} "Installing dependencies" 64 | 65 | if has_apt_get; then 66 | sudo apt-get update -y 67 | sudo apt-get install -y curl unzip jq 68 | elif has_yum; then 69 | sudo yum update -y 70 | sudo yum install -y curl unzip jq 71 | else 72 | log "ERROR" ${func} "Could not find apt-get or yum. Cannot install dependencies on this OS." 73 | exit 1 74 | fi 75 | } 76 | 77 | function user_exists { 78 | local -r username="$1" 79 | id "${username}" >/dev/null 2>&1 80 | } 81 | 82 | function create_user { 83 | local func="create_consul_user" 84 | local -r username="$1" 85 | 86 | if user_exists "${username}"; then 87 | log "INFO" ${func} "User ${username} already exists. Will not create again." 88 | else 89 | log "INFO" ${func} "Creating user named ${username}" 90 | sudo useradd --system --home /etc/consul.d --shell /bin/false "${username}" 91 | fi 92 | } 93 | 94 | function install_consul { 95 | local func="install_consul" 96 | local -r install_bin="$1" 97 | local -r tmp="$2" 98 | local -r bin="$3" 99 | 100 | log "INFO" ${func} "Installing Consul" 101 | 102 | curl -s -o consul.zip https://releases.hashicorp.com/consul/1.6.2/consul_1.6.2_linux_amd64.zip 103 | unzip consul.zip 104 | 105 | sudo chown root:root ${bin} 106 | sudo mv $bin "${install_bin}" 107 | sudo setcap cap_ipc_lock=+ep "${install_bin}" 108 | rm consul.zip 109 | } 110 | 111 | function create_consul_install_paths { 112 | local func="create_consul_install_paths" 113 | local -r path="$1" 114 | local -r username="$2" 115 | local -r client_config="$3" 116 | local -r server_config="$4" 117 | local adv_adr="${5}" 118 | local rtj=${6} 119 | local dc="${7}" 120 | local data_dir="${8}" 121 | local bs_expect=${9} 122 | local is_consul_server=${10} 123 | 124 | log "INFO" ${func} "Creating install dirs for consul at ${path}" 125 | log "INFO" ${func} "username = ${username}, config = ${client_config}" 126 | sudo mkdir -p "${path}" 127 | 128 | cat << EOF | sudo tee ${path}/${client_config} 129 | 130 | advertise_addr = "${adv_adr}" 131 | datacenter = "${dc}" 132 | data_dir = "${data_dir}" 133 | retry_join = [${rtj}] 134 | 135 | performance { 136 | raft_multiplier = 1 137 | } 138 | addresses { 139 | http = "0.0.0.0" 140 | } 141 | ports { 142 | dns = 7600 143 | http = 7500 144 | serf_lan = 7301 145 | serf_wan = 7302 146 | server = 7300 147 | } 148 | bind_addr = "0.0.0.0" 149 | 150 | telemetry { 151 | dogstatsd_addr = "localhost:8125" 152 | disable_hostname = false 153 | } 154 | 155 | EOF 156 | 157 | 158 | 159 | if [[ -n "${is_consul_server}" ]]; then 160 | sudo echo "server = ${is_consul_server}" >> ${path}/${server_config} 161 | sudo echo "ui = true" >> ${path}/${server_config} 162 | fi 163 | 164 | 165 | if [[ "${bs_expect}" == "3" ]]; then 166 | sudo echo "bootstrap_expect = ${bs_expect}" >> ${path}/${server_config} 167 | fi 168 | 169 | sudo chmod 640 ${path}/${server_config} 170 | log "INFO" ${func} "Changing ownership of ${path} to ${username}" 171 | sudo chown -R "${username}:${username}" "${path}" 172 | 173 | log "INFO" ${func} "Creating data dir for consul at path ${data_dir}" 174 | log "INFO" ${func} "username = ${username}" 175 | sudo mkdir -p "${data_dir}" 176 | 177 | sudo chmod 740 ${data_dir} 178 | log "INFO" ${func} "Changing ownership of ${data_dir} to ${username}" 179 | sudo chown -R "${username}:${username}" "${data_dir}" 180 | } 181 | 182 | function create_consul_service { 183 | local func="create_consul_service" 184 | local -r service="$1" 185 | 186 | log "INFO" ${func} "Creating Consul service" 187 | cat < /tmp/install/consul.service 188 | [Unit] 189 | Description="HashiCorp Consul - A service mesh solution" 190 | Documentation=https://www.consul.io/ 191 | Requires=network-online.target 192 | After=network-online.target 193 | ConditionFileNotEmpty=/etc/consul.d/consul.hcl 194 | 195 | [Service] 196 | User=consul 197 | Group=consul 198 | ExecStart=/usr/local/bin/consul agent -config-dir=/etc/consul.d/ 199 | ExecReload=/usr/local/bin/consul reload 200 | KillMode=process 201 | Restart=on-failure 202 | LimitNOFILE=65536 203 | 204 | [Install] 205 | WantedBy=multi-user.target 206 | EOF 207 | 208 | sudo cp ${TMP_DIR}/consul.service "${service}" 209 | sudo systemctl enable consul 210 | 211 | } 212 | 213 | function setup_bash_profile { 214 | cat <> /etc/bash.bashrc 215 | 216 | export CONSUL_HTTP_ADDR=http://127.0.0.1:7500 217 | EOF 218 | } 219 | 220 | function main { 221 | local func="main" 222 | 223 | if [ -e ${TMP_DIR} ]; then 224 | sudo rm -rf "${TMP_DIR}" 225 | fi 226 | sudo mkdir -p "${TMP_DIR}" 227 | log "INFO" "${func}" $(ls -l ${TMP_DIR}) 228 | log "INFO" "${func}" "Starting Consul install" 229 | install_dependencies 230 | create_user "${DEFAULT_CONSUL_USER}" 231 | install_consul "${DEFAULT_INSTALL_PATH}" "${TMP_DIR}" "${SUPPLIED_CONSUL_BIN}" 232 | create_consul_install_paths "${DEFAULT_CONSUL_PATH}" "${DEFAULT_CONSUL_USER}" "${DEFAULT_CONSUL_AGENT_CONFIG}" "${DEFAULT_CONSUL_SERVER_CONFIG}" "${ADVERTISE_ADDRESS}" "${RETRY_JOIN}" "${DATACENTER}" "${DEFAULT_CONSUL_DATA_DIR}" "${BOOTSTRAP_EXPECT}" ${IS_CONSUL_SERVER} 233 | create_consul_service "${DEFAULT_CONSUL_SERVICE}" 234 | log "INFO" "${func}" "Consul install complete!" 235 | sudo rm -rf "${TMP_DIR}" 236 | systemctl start consul 237 | setup_bash_profile 238 | } 239 | 240 | main "$@" 241 | -------------------------------------------------------------------------------- /install-elasticsearch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | BIND_ADDRESS=${1} 4 | 5 | wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - 6 | 7 | sudo apt-get install apt-transport-https 8 | 9 | echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list 10 | 11 | sudo apt-get update && sudo apt-get install elasticsearch 12 | 13 | sudo cat < /etc/elasticsearch/elasticsearch.yml 14 | path.data: /var/lib/elasticsearch 15 | path.logs: /var/log/elasticsearch 16 | network.host: "${BIND_ADDRESS}" 17 | cluster.initial_master_nodes: ["${BIND_ADDRESS}"] 18 | EOF 19 | 20 | sudo systemctl enable elasticsearch 21 | sudo systemctl start elasticsearch 22 | -------------------------------------------------------------------------------- /install-grafana.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | sudo useradd grafana --no-create-home 4 | 5 | echo "Downlaoding grafana 6.2.1..." 6 | wget -q https://dl.grafana.com/oss/release/grafana-6.2.1.linux-amd64.tar.gz 7 | tar xvfz grafana-*.tar.gz 8 | rm grafana-*.tar.gz 9 | 10 | sudo mv grafana-* /etc/grafana 11 | sudo mkdir -p /var/lib/grafana/ 12 | sudo chown -R grafana:grafana /etc/grafana 13 | sudo chown -R grafana:grafana /var/lib/grafana 14 | 15 | cat > "/etc/systemd/system/grafana.service" < /etc/kibana/kibana.yml 8 | server.host: "${ELASTICSEARCH_IP}" 9 | elasticsearch.hosts: ["http://${ELASTICSEARCH_IP}:9200"] 10 | EOF 11 | 12 | service kibana enable 13 | service kibana restart 14 | -------------------------------------------------------------------------------- /install-logstash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | LOGSTASH_SERVER_IP=${1} 4 | 5 | # Install Java 6 | 7 | sudo apt-get --assume-yes install openjdk-11-jre 8 | 9 | sudo echo 'JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64/bin/java"' >> /etc/environment 10 | 11 | JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64/bin/java" 12 | 13 | # Install Logstash 14 | 15 | wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - 16 | echo "deb http://packages.elastic.co/logstash/2.3/debian stable main" | sudo tee -a /etc/apt/sources.list 17 | 18 | sudo apt-get --assume-yes update 19 | 20 | sudo apt-get --assume-yes install logstash 21 | 22 | sudo mkdir -p /etc/logstash/conf.d 23 | 24 | sudo cat < /etc/logstash/conf.d/logstash.conf 25 | input { 26 | udp { 27 | host => "${LOGSTASH_SERVER_IP}" 28 | port => 10514 29 | codec => "json" 30 | type => "rsyslog" 31 | } 32 | } 33 | 34 | # This is an empty filter block. You can later add other filters here to further process 35 | # your log lines 36 | 37 | filter { } 38 | 39 | # This output block will send all events of type "rsyslog" to Elasticsearch at the configured 40 | # host and port into daily indices of the pattern, "rsyslog-YYYY.MM.DD" 41 | 42 | output { 43 | if [type] == "rsyslog" { 44 | elasticsearch { 45 | hosts => [ "${LOGSTASH_SERVER_IP}:9200" ] 46 | } 47 | } 48 | } 49 | EOF 50 | 51 | sudo service logstash start 52 | sudo service rsyslog restart 53 | -------------------------------------------------------------------------------- /install-prometheus.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x 3 | 4 | IP_ADDRESS=${1} 5 | 6 | sudo useradd prometheus --no-create-home 7 | 8 | wget https://github.com/prometheus/prometheus/releases/download/v2.14.0/prometheus-2.14.0.linux-amd64.tar.gz 9 | tar xvfz prometheus-*.tar.gz 10 | rm prometheus-*.tar.gz 11 | 12 | sudo mkdir -p /etc/prometheus 13 | sudo mkdir -p /var/lib/prometheus/ 14 | sudo chown -R prometheus:prometheus /etc/prometheus 15 | sudo chown -R prometheus:prometheus /var/lib/prometheus 16 | 17 | sudo mv prometheus*/* /etc/prometheus/ 18 | 19 | sudo mv /etc/prometheus/prometheus /usr/local/bin/ 20 | 21 | cat > "/etc/prometheus/prometheus.yml" <` to any timeseries scraped from this config. 44 | - job_name: 'prometheus' 45 | 46 | # metrics_path defaults to '/metrics' 47 | # scheme defaults to 'http'. 48 | 49 | static_configs: 50 | - targets: ['localhost:9090'] 51 | 52 | - job_name: 'vault-server' 53 | static_configs: 54 | - targets: ['10.0.0.10:9273'] 55 | scheme: "http" 56 | tls_config: 57 | insecure_skip_verify: true 58 | metrics_path: "/metrics" 59 | params: 60 | format: ['prometheus'] 61 | 62 | - job_name: 'consul-1-server' 63 | static_configs: 64 | - targets: ['10.0.0.11:9273'] 65 | scheme: "http" 66 | tls_config: 67 | insecure_skip_verify: true 68 | metrics_path: "/metrics" 69 | params: 70 | format: ['prometheus'] 71 | 72 | - job_name: 'consul-2-server' 73 | static_configs: 74 | - targets: ['10.0.0.12:9273'] 75 | scheme: "http" 76 | tls_config: 77 | insecure_skip_verify: true 78 | metrics_path: "/metrics" 79 | params: 80 | format: ['prometheus'] 81 | 82 | - job_name: 'consul-3-server' 83 | static_configs: 84 | - targets: ['10.0.0.13:9273'] 85 | scheme: "http" 86 | tls_config: 87 | insecure_skip_verify: true 88 | metrics_path: "/metrics" 89 | params: 90 | format: ['prometheus'] 91 | 92 | EOF 93 | 94 | 95 | cat > "/etc/systemd/system/prometheus.service" < temp && mv temp /etc/rsyslog.d/50-default.conf 4 | 5 | sudo service rsyslog restart 6 | -------------------------------------------------------------------------------- /install-rsyslog-server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | RSYSLOG_SERVER_IP=${1} 4 | 5 | # Configure rsyslog server 6 | 7 | sudo cat << 'EOF' > /etc/rsyslog.conf 8 | # /etc/rsyslog.conf Configuration file for rsyslog. 9 | # 10 | # For more information see 11 | # /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html 12 | # 13 | # Default logging rules can be found in /etc/rsyslog.d/50-default.conf 14 | 15 | 16 | ################# 17 | #### MODULES #### 18 | ################# 19 | 20 | module(load="imuxsock") # provides support for local system logging 21 | #module(load="immark") # provides --MARK-- message capability 22 | 23 | # provides UDP syslog reception 24 | module(load="imudp") 25 | input(type="imudp" port="514") 26 | 27 | # provides TCP syslog reception 28 | module(load="imtcp") 29 | input(type="imtcp" port="514") 30 | 31 | # provides kernel logging support and enable non-kernel klog messages 32 | module(load="imklog" permitnonkernelfacility="on") 33 | 34 | ########################### 35 | #### GLOBAL DIRECTIVES #### 36 | ########################### 37 | 38 | # 39 | # Use traditional timestamp format. 40 | # To enable high precision timestamps, comment out the following line. 41 | # 42 | $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat 43 | 44 | # Filter duplicated messages 45 | $RepeatedMsgReduction on 46 | 47 | # 48 | # Set the default permissions for all log files. 49 | # 50 | $FileOwner syslog 51 | $FileGroup adm 52 | $FileCreateMode 0640 53 | $DirCreateMode 0755 54 | $Umask 0022 55 | $PrivDropToUser syslog 56 | $PrivDropToGroup syslog 57 | 58 | # 59 | # Where to place spool and state files 60 | # 61 | $WorkDirectory /var/spool/rsyslog 62 | 63 | # 64 | # Include all config files in /etc/rsyslog.d/ 65 | # 66 | $IncludeConfig /etc/rsyslog.d/*.conf 67 | 68 | EOF 69 | 70 | # Restart rsyslog server 71 | 72 | sudo cat<<'EOF' > /etc/rsyslog.d/01-json-template.conf 73 | template(name="json-template" 74 | type="list") { 75 | constant(value="{") 76 | constant(value="\"@timestamp\":\"") property(name="timereported" dateFormat="rfc3339") 77 | constant(value="\",\"@version\":\"1") 78 | constant(value="\",\"message\":\"") property(name="msg" format="json") 79 | constant(value="\",\"sysloghost\":\"") property(name="hostname") 80 | constant(value="\",\"severity\":\"") property(name="syslogseverity-text") 81 | constant(value="\",\"facility\":\"") property(name="syslogfacility-text") 82 | constant(value="\",\"programname\":\"") property(name="programname") 83 | constant(value="\",\"procid\":\"") property(name="procid") 84 | constant(value="\"}\n") 85 | } 86 | EOF 87 | 88 | sudo cat< /etc/rsyslog.d/60-output.conf 89 | *.* @${RSYSLOG_SERVER_IP}:10514;json-template 90 | EOF 91 | 92 | sudo service rsyslog restart 93 | -------------------------------------------------------------------------------- /install-telegraf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DATACENTER=${1} 4 | ROLE=${2} 5 | 6 | # Add the influxdata signing key 7 | curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add - 8 | 9 | # Configure a package repo 10 | source /etc/lsb-release 11 | echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list 12 | 13 | # Install Telegraf 14 | sudo apt-get update && sudo apt-get install telegraf 15 | 16 | # Configure Telegraf 17 | cat > "/etc/telegraf/telegraf.conf" <&2 echo -e "${timestamp} [${level}] [${SCRIPT_NAME}:${func}] ${message}" 36 | } 37 | 38 | function assert_not_empty { 39 | local func="assert_not_empty" 40 | local -r arg_name="$1" 41 | local -r arg_value="$2" 42 | 43 | if [[ -z "${arg_value}" ]]; then 44 | log "ERROR" ${func} "The value for '${arg_name}' cannot be empty" 45 | print_usage 46 | exit 1 47 | fi 48 | } 49 | 50 | function has_apt_get { 51 | [ -n "$(command -v apt-get)" ] 52 | } 53 | 54 | function has_setcap { 55 | [ -n "$(command -v setcap)" ] 56 | } 57 | 58 | function install_dependencies { 59 | local func="install_dependencies" 60 | log "INFO" ${func} "Installing dependencies" 61 | 62 | if has_apt_get; then 63 | sudo apt-get update -y 64 | sudo apt-get install -y curl unzip jq libcap2-bin 65 | else 66 | log "ERROR" ${func} "Could not find apt-get or yum. Cannot install dependencies on this OS." 67 | exit 1 68 | fi 69 | } 70 | 71 | function user_exists { 72 | local -r username="$1" 73 | id "${username}" >/dev/null 2>&1 74 | } 75 | 76 | function create_vault_user { 77 | local func="create_vault_user" 78 | local -r username="$1" 79 | 80 | if user_exists "${username}"; then 81 | log "INFO" ${func} "User ${username} already exists. Will not create again." 82 | else 83 | log "INFO" ${func} "Creating user named ${username}" 84 | sudo useradd --system --home /etc/vault.d --shell /bin/false "${username}" 85 | fi 86 | } 87 | 88 | function install_vault { 89 | local func="install_vault" 90 | local -r install_bin="$1" 91 | local -r tmp="$2" 92 | local -r bin="$3" 93 | 94 | 95 | log "INFO" ${func} "Installing Vault" 96 | 97 | curl -s -o vault.zip https://releases.hashicorp.com/vault/1.3.0/vault_1.3.0_linux_amd64.zip 98 | 99 | unzip vault.zip 100 | sudo chown root:root ${bin} 101 | sudo mv $bin "${install_bin}" 102 | if has_setcap; then 103 | sudo setcap cap_ipc_lock=+ep "${install_bin}" 104 | else 105 | log "ERROR" ${func} "Could not find setcap. Please resolve this dependency before continuing" 106 | exit 1 107 | fi 108 | rm vault.zip 109 | } 110 | 111 | function create_vault_install_paths { 112 | local func="create_vault_install_paths" 113 | local -r path="$1" 114 | local -r username="$2" 115 | local -r config="$3" 116 | local -r ip_addr=${4} 117 | 118 | log "INFO" ${func} "Creating install dirs for Vault at ${path}" 119 | log "INFO" ${func} "username = ${username}, config = ${config}" 120 | sudo mkdir -p "${path}" 121 | cat << EOF | sudo tee ${TMP_DIR}/outy 122 | listener "tcp" { 123 | address = "127.0.0.1:8200" 124 | cluster_address = "127.0.0.1:8201" 125 | tls_disable = "true" 126 | } 127 | storage "consul" { 128 | address = "127.0.0.1:7500" 129 | path = "vault/" 130 | service = "vault" 131 | } 132 | ui = true 133 | telemetry { 134 | dogstatsd_addr = "localhost:8125" 135 | disable_hostname = true 136 | } 137 | api_addr = "http://${ip_addr}:8200" 138 | cluster_addr = "https://${ip_addr}:8201" 139 | EOF 140 | 141 | sudo cp ${TMP_DIR}/outy ${path}${config} 142 | sudo chmod 640 ${path}${config} 143 | log "INFO" ${func} "Changing ownership of ${path} to ${username}" 144 | sudo chown -R "${username}:${username}" "${path}" 145 | } 146 | 147 | function create_vault_service { 148 | local func="create_vault_service" 149 | local -r service="$1" 150 | 151 | log "INFO" ${func} "Creating Vault service" 152 | cat < /tmp/outy 153 | [Unit] 154 | Description="HashiCorp Vault - A tool for managing secrets" 155 | Documentation=https://www.vaultproject.io/docs/ 156 | Requires=network-online.target 157 | After=network-online.target 158 | ConditionFileNotEmpty=/etc/vault.d/vault.hcl 159 | [Service] 160 | User=vault 161 | Group=vault 162 | ProtectSystem=full 163 | ProtectHome=read-only 164 | PrivateTmp=yes 165 | PrivateDevices=yes 166 | SecureBits=keep-caps 167 | AmbientCapabilities=CAP_IPC_LOCK 168 | Capabilities=CAP_IPC_LOCK+ep 169 | CapabilityBoundingSet=CAP_SYSLOG CAP_IPC_LOCK 170 | NoNewPrivileges=yes 171 | ExecStart=/usr/local/bin/vault server -config=/etc/vault.d/vault.hcl 172 | ExecReload=/bin/kill --signal HUP \$MAINPID 173 | KillMode=process 174 | KillSignal=SIGINT 175 | Restart=on-failure 176 | RestartSec=5 177 | TimeoutStopSec=30 178 | StartLimitIntervalSec=60 179 | StartLimitBurst=3 180 | [Install] 181 | WantedBy=multi-user.target 182 | EOF 183 | 184 | sudo cp /tmp/outy "${service}" 185 | sudo systemctl enable vault 186 | 187 | } 188 | 189 | function setup_bash_profile { 190 | cat <> /etc/bash.bashrc 191 | export VAULT_ADDR=http://127.0.0.1:8200 192 | EOF 193 | } 194 | 195 | function main { 196 | local func="main" 197 | if [ -e ${TMP_DIR} ]; then 198 | rm -rf "${TMP_DIR}" 199 | fi 200 | mkdir "${TMP_DIR}" 201 | 202 | log "INFO" "${func}" "Starting Vault install" 203 | install_dependencies 204 | create_vault_user "${DEFAULT_VAULT_USER}" 205 | install_vault "${DEFAULT_INSTALL_PATH}" "${TMP_DIR}" "$SUPPLIED_VAULT_BIN" 206 | create_vault_install_paths "${DEFAULT_VAULT_PATH}" "${DEFAULT_VAULT_USER}" "${DEFAULT_VAULT_CONFIG}" "${HOST_IP_ADDRESS}" 207 | create_vault_service "${DEFAULT_VAULT_SERVICE}" 208 | log "INFO" "${func}" "Vault install complete!" 209 | sudo rm -rf "${TMP_DIR}" 210 | sudo systemctl start vault 211 | setup_bash_profile 212 | } 213 | 214 | main "$@" 215 | -------------------------------------------------------------------------------- /test-get-vault.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SECONDS=0 4 | START=$(date) 5 | for i in {1..10000};do 6 | vault kv get secret/hello${i} 7 | done 8 | END=$(date) 9 | 10 | echo "Started: ${START} - Ended: ${END} - Secs: ${SECONDS}" 11 | -------------------------------------------------------------------------------- /test-put-vault.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SECONDS=0 4 | START=$(date) 5 | for i in {1..10000};do 6 | vault kv put secret/hello${i} value=12345 7 | done 8 | END=$(date) 9 | 10 | echo "Started: ${START} - Ended: ${END} - Secs: ${SECONDS}" 11 | --------------------------------------------------------------------------------