soreana opened a new pull request #4438: URL: https://github.com/apache/cloudstack/pull/4438
## Description <!--- Describe your changes in detail --> In this pull request, I added new functionality to Cloudstack prometheus exporter. To see the differences please check the testing section. <!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be closed when this PR gets merged --> <!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" --> <!-- Fixes: # --> ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [x] New feature (non-breaking change which adds functionality) - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Enhancement (improves an existing feature and functionality) - [ ] Cleanup (Code refactoring and cleanup, that may add test cases) ## How Has This Been Tested? <!-- Please describe in detail how you tested your changes. --> <!-- Include details of your testing environment, and the tests you ran to --> <!-- see how your change affects other areas of the code, etc. --> This pull request contains seven commits. Except for the dfb35e5224 commit, they are all added new functionality to the Prometheus. In the subsequent sections, I will describe every commit functionality. I tested them in my test environment with three management servers, one DB node (MySQL), and two KVM hypervisor. ### 1. Export count of total/up/down hosts by tags 0dbe9e78a3660bef73451c6d56f4826509833f2b 1. Enable Prometheus. 2. Add tag to the host. 3. Run `curl http://127.0.0.1:9595/metrics | grep cloudstack_hosts_total` Output Before Changes: ``` cloudstack_hosts_total{zone="mgt122-60",filter="online"} 2 cloudstack_hosts_total{zone="mgt122-60",filter="offline"} 0 cloudstack_hosts_total{zone="mgt122-60",filter="total"} 2 ``` Output After Changes: ``` cloudstack_hosts_total{zone="mgt122-60",filter="online"} 2 cloudstack_hosts_total{zone="mgt122-60",filter="offline"} 0 cloudstack_hosts_total{zone="mgt122-60",filter="total"} 2 cloudstack_hosts_total{zone="mgt122-60",filter="total",tags="tage1"} 1 cloudstack_hosts_total{zone="mgt122-60",filter="online",tags="tage1"} 1 cloudstack_hosts_total{zone="mgt122-60",filter="offline",tags="tage1"} 0 ``` ### 2. Export count of vms by state and host tag e6a81d16d9f11db6bb4fd2b0ab38194961ce516b 1. Enable Prometheus. 2. Add tag to the host. 3. Run `curl http://127.0.0.1:9595/metrics | grep cloudstack_vms_total_by_tag` After changes, the following line added to the Prometheus output: ``` cloudstack_vms_total_by_tag{zone="mgt122-60",filter="starting",tags="tage1"} 0 cloudstack_vms_total_by_tag{zone="mgt122-60",filter="running",tags="tage1"} 0 cloudstack_vms_total_by_tag{zone="mgt122-60",filter="stopping",tags="tage1"} 0 cloudstack_vms_total_by_tag{zone="mgt122-60",filter="stopped",tags="tage1"} 0 cloudstack_vms_total_by_tag{zone="mgt122-60",filter="destroyed",tags="tage1"} 0 cloudstack_vms_total_by_tag{zone="mgt122-60",filter="expunging",tags="tage1"} 0 cloudstack_vms_total_by_tag{zone="mgt122-60",filter="migrating",tags="tage1"} 0 cloudstack_vms_total_by_tag{zone="mgt122-60",filter="error",tags="tage1"} 0 cloudstack_vms_total_by_tag{zone="mgt122-60",filter="unknown",tags="tage1"} 0 cloudstack_vms_total_by_tag{zone="mgt122-60",filter="shutdown",tags="tage1"} 0 ``` ### 3. Add host tags to host cpu/cores/memory usage in Prometheus exporter eefd9f197352653f74aff73ccfffc4dd86d56b0d 1. Enable Prometheus. 2. Add tag to the host. 3. Run following command and justify output with the expected results. `curl http://127.0.0.1:9595/metrics | grep cloudstack_host_vms_cores_total` 4. repeat step three for `cloudstack_host_cpu_usage_mhz_total` and `cloudstack_host_memory_usage_mibs_total` Output Before Changes: ``` cloudstack_host_vms_cores_total\{zone="mgt122-60",hostname="node75",ip="10.135.122.75",filter="used",dedicated="0"} 2 cloudstack_host_vms_cores_total\{zone="mgt122-60",hostname="node75",ip="10.135.122.75",filter="total",dedicated="0"} 4 cloudstack_host_vms_cores_total\{zone="mgt122-60",hostname="node74",ip="10.135.122.74",filter="used",dedicated="0"} 2 cloudstack_host_vms_cores_total\{zone="mgt122-60",hostname="node74",ip="10.135.122.74",filter="total",dedicated="0"} 4 cloudstack_host_vms_cores_total\{zone="mgt122-60",filter="allocated"} 4 cloudstack_host_vms_cores_total_by_tag\{zone="mgt122-60",filter="allocated",tags="tage1"} 0 ``` Output After Changes: ``` cloudstack_host_vms_cores_total\{zone="mgt122-60",hostname="node75",ip="10.135.122.75",filter="used",dedicated="0",tags="tage1"} 2 cloudstack_host_vms_cores_total\{zone="mgt122-60",hostname="node75",ip="10.135.122.75",filter="total",dedicated="0",tags="tage1"} 4 cloudstack_host_vms_cores_total\{zone="mgt122-60",hostname="node74",ip="10.135.122.74",filter="used",dedicated="0",tags=""} 2 cloudstack_host_vms_cores_total\{zone="mgt122-60",hostname="node74",ip="10.135.122.74",filter="total",dedicated="0",tags=""} 4 cloudstack_host_vms_cores_total\{zone="mgt122-60",filter="allocated"} 4 ``` ### 4. Cloudstack Prometheus exporter: Add allocated capacity group by host tag. a489e3c6b269279df5fbff32a708d9ed0296a40e 1. Enable Prometheus. 2. Add tag to the host. 3. Run `curl http://127.0.0.1:9595/metrics | grep cloudstack_host_vms_cores_total` Output Before Changes: ``` cloudstack_host_vms_cores_total\{zone="mgt122-60",hostname="node75",ip="10.135.122.75",filter="used",dedicated="0"} 2 cloudstack_host_vms_cores_total\{zone="mgt122-60",hostname="node75",ip="10.135.122.75",filter="total",dedicated="0"} 4 cloudstack_host_vms_cores_total\{zone="mgt122-60",hostname="node74",ip="10.135.122.74",filter="used",dedicated="0"} 2 cloudstack_host_vms_cores_total\{zone="mgt122-60",hostname="node74",ip="10.135.122.74",filter="total",dedicated="0"} 4 cloudstack_host_vms_cores_total\{zone="mgt122-60",filter="allocated"} 4 cloudstack_host_vms_cores_total_by_tag\{zone="mgt122-60",filter="allocated",tags="tage1"} 0 ``` Output After Changes: ``` cloudstack_host_vms_cores_total\{zone="mgt122-60",hostname="node75",ip="10.135.122.75",filter="used",dedicated="0",tags="tage1"} 2 cloudstack_host_vms_cores_total\{zone="mgt122-60",hostname="node75",ip="10.135.122.75",filter="total",dedicated="0",tags="tage1"} 4 cloudstack_host_vms_cores_total\{zone="mgt122-60",hostname="node74",ip="10.135.122.74",filter="used",dedicated="0",tags=""} 2 cloudstack_host_vms_cores_total\{zone="mgt122-60",hostname="node74",ip="10.135.122.74",filter="total",dedicated="0",tags=""} 4 cloudstack_host_vms_cores_total\{zone="mgt122-60",filter="allocated"} 4 cloudstack_host_vms_cores_total_by_tag\{zone="mgt122-60",filter="allocated",tags="tage1"} 0 ``` ### 5. Show count of Active domains on grafana de08479da13b7b3f3eb467fc3798c6734f0e6fb7 ============== Scenario One ============== 1. Enable Prometheus. 2. Run `curl http://127.0.0.1:9595/metrics | grep cloudstack_active_domains_total`. Output is: ``` cloudstack_active_domains_total{zone="mgt122-60"} 1 ``` 3. Create a new domain 4. Repeat step two. The output will not change. 5. Add a new account to the domain created in step three. 6. Repeat step two. The output will change to: ``` cloudstack_active_domains_total{zone="mgt122-60"} 2 ``` ============== Scenario Two ============== 1. Use previous environment 2. Disable all account in domain created in step 3 of Scenario one. 3. Repeat step two of Scenario one. The output will change to: ``` cloudstack_active_domains_total{zone="mgt122-60"} 1 ``` ### 6. Show count of Active accounts and vms by size on grafana d7aa19f0f850dfd5eea5c4f51a6529d39c2daf88 ============== Scenario One ============== 1. Enable Prometheus. 2. Run `curl http://127.0.0.1:9595/metrics | grep cloudstack_active_accounts_total`. output is: ``` cloudstack_active_accounts_total{zone="mgt122-60"} 1 ``` 3. Create a new account 4. Repeat step two. The output will change to: ``` cloudstack_active_accounts_total\{zone="mgt122-60"} 2 ``` ============== Scenario Two ============== 1. Enable Prometheus. 2. Run `curl http://127.0.0.1:9595/metrics | grep cloudstack_vms_total_by_size`. output is: ``` cloudstack_vms_total_by_size\{zone="mgt122-60",cpu="1",memory="512"} 2 ``` 3. Add new instance with different offering 4. Repeat step two. The output will change to: ``` cloudstack_vms_total_by_size{zone="mgt122-60",cpu="1",memory="512"} 2 cloudstack_vms_total_by_size\{zone="mgt122-60",cpu="1",memory="1024"} 1 ``` <!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/master/CONTRIBUTING.md) document --> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
