vCloud Director SP 5.6.x has the ability to export VM statistics to an external database source which can then be queried via a set of new API calls. I’ve gone through a couple of different posts on how to configure the Cassandra/KairosDB data platform.
vCloud Director SP: VM Metrics Database Configuration Part 1
Installing and Configuring Cassandra and KairosDB on Ubuntu 14.04 LTS
This post finishes off the series and goes through the configuration of vCloud Director to start exporting VM metrics and then how to query the vCloud APIs to get those metrics. One thing to mention before continuing is that the vCD SP Documentation KairosDB v 0.9.1 is referenced as the version to install. Even though there are newer builds 0.9.1 is the only one tested and verified…other versions cause bugs and I have seen some strange results.
Configuring vCD SP Metric Database Connection:
Data for historic metrics is stored in a KairosDB database backed by a Cassandra cluster. Cassandra and KairosDB are configured you then use the cell-management-tool utility to connect vCloud Director to KairosDB. To create a connection from KairosDB to a vCloud Director, use a command line with the following form:
cell-management-tool configure-metrics options
1 |
./cell-management-tool configure-metrics --repository-host KDB-IP --repository-port 8080 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
[root@vcd05 ~]# service vmware-vcd stop Stopping vmware-vcd-watchdog: [ OK ] Stopping vmware-vcd-cell: [ OK ] [root@vcd05 ~]# cd /opt/vmware/vcloud-director/bin/ [root@vcd05 bin]# ./cell-management-tool configure-metrics --repository-host 172.17.0.115 --repository-port 8080 Jun 19, 2015 10:12:00 AM org.apache.tomcat.jdbc.pool.ConnectionPool init WARNING: maxActive is smaller than 1, setting maxActive to: 100 [root@vcd05 bin]# service vmware-vcd start ;tail -f /opt/vmware/vcloud-director/logs/cell.log Starting vmware-vcd-watchdog: [ OK ] Starting vmware-vcd-cell [ OK ] Bootstrap application: start All required system properties are present All required local configuration properties are present Successfully bound network port: 80 on host address: 172.17.0.34 Successfully bound network port: 443 on host address: 172.17.0.34 Successfully bound network port: 8999 on host address: 172.17.0.34 All required local configuration properties are present Successfully initialized system cryptography Successfully configured HTTP SSL Connector from certificate store: /opt/vmware/vcloud-director/etc/certificates Current locale "en" verified successfully. Bootstrap application: complete Application startup event: Waiting for subsystem 'com.vmware.vcloud.common.core' Application startup event: Waiting for subsystem 'com.vmware.vcloud.cloud-proxy-server' Application startup event: Waiting for subsystem 'com.vmware.vcloud.consoleproxy' Application startup event: Subsystem 'com.vmware.vcloud.common.core' startup initiated. Application startup begins: Subsystem 'com.vmware.vcloud.common.core' at 6/19/15 10:12 AM Successfully connected to database: jdbc:jtds:sqlserver://172.17.0.5:1433/vcloud;socketTimeout=90 Successfully initialized system cryptography Application startup event: Subsystem 'com.vmware.vcloud.cloud-proxy-server' startup initiated. Application startup begins: Subsystem 'com.vmware.vcloud.cloud-proxy-server' at 6/19/15 10:12 AM Application Initialization: 'com.vmware.vcloud.cloud-proxy-server' 33% complete. Subsystem 'com.vmware.vcloud.cloud-proxy-server' started Application Initialization: 'com.vmware.vcloud.common.core' 4% complete. Subsystem 'com.vmware.vcloud.common-util' started Application Initialization: 'com.vmware.vcloud.common.core' 9% complete. Subsystem 'com.vmware.vcloud.common-sso-patch' started Application startup event: Subsystem 'com.vmware.vcloud.consoleproxy' startup initiated. Successfully configured Console Proxy SSL Connector from certificate store: /opt/vmware/vcloud-director/etc/proxycertificates Application Initialization: 'com.vmware.vcloud.cloud-proxy-server' 66% complete. Subsystem 'com.vmware.vcloud.hybrid-networking' started Application Initialization: 'com.vmware.vcloud.cloud-proxy-server' 100% complete. Subsystem 'com.vmware.vcloud.cloud-proxy-web' started Application Initialization: 'com.vmware.vcloud.cloud-proxy-server' complete. Server is ready in 0:16 (minutes:seconds) Application Initialization: 'com.vmware.vcloud.common.core' 13% complete. Subsystem 'com.vmware.vcloud.api-framework' started Application Initialization: 'com.vmware.vcloud.common.core' 18% complete. Subsystem 'com.vmware.vcloud.common-vmomi' started Application Initialization: 'com.vmware.vcloud.common.core' 22% complete. Subsystem 'com.vmware.vcloud.jax-rs-activator' started Application Initialization: 'com.vmware.vcloud.common.core' 27% complete. Subsystem 'com.vmware.pbm.placementengine' started Application Initialization: 'com.vmware.vcloud.common.core' 31% complete. Subsystem 'com.vmware.vcloud.vim-proxy' started Application Initialization: 'com.vmware.vcloud.common.core' 36% complete. Subsystem 'com.vmware.vcloud.fabric.foundation' started Application Initialization: 'com.vmware.vcloud.common.core' 40% complete. Subsystem 'com.vmware.vcloud.imagetransfer-server' started Application Initialization: 'com.vmware.vcloud.common.core' 45% complete. Subsystem 'com.vmware.vcloud.fabric.storage' started Application Initialization: 'com.vmware.vcloud.common.core' 50% complete. Subsystem 'com.vmware.vcloud.fabric.compute' started Application Initialization: 'com.vmware.vcloud.common.core' 54% complete. Subsystem 'com.vmware.vcloud.backend-core-base' started Application Initialization: 'com.vmware.vcloud.common.core' 59% complete. Subsystem 'com.vmware.vcloud.fabric.net' started Application Initialization: 'com.vmware.vcloud.common.core' 63% complete. Subsystem 'com.vmware.vcloud.service-extensibility' started Application Initialization: 'com.vmware.vcloud.common.core' 68% complete. Subsystem 'com.vmware.vcloud.backend-core' started Application Initialization: 'com.vmware.vcloud.common.core' 72% complete. Subsystem 'com.vmware.vcloud.vapp-lifecycle' started Application Initialization: 'com.vmware.vcloud.common.core' 77% complete. Subsystem 'com.vmware.vcloud.content-library' started Application Initialization: 'com.vmware.vcloud.common.core' 81% complete. Subsystem 'com.vmware.vcloud.presentation-api-impl' started Application Initialization: 'com.vmware.vcloud.common.core' 86% complete. Subsystem 'com.vmware.vcloud.metrics-core' started Application initialization detailed status report: 86% complete com.vmware.vcloud.common-util Subsystem Status: [COMPLETE] com.vmware.vcloud.common-sso-patch Subsystem Status: [COMPLETE] com.vmware.vcloud.api-framework Subsystem Status: [COMPLETE] com.vmware.vcloud.common-vmomi Subsystem Status: [COMPLETE] com.vmware.vcloud.jax-rs-activator Subsystem Status: [COMPLETE] com.vmware.pbm.placementengine Subsystem Status: [COMPLETE] com.vmware.vcloud.vim-proxy Subsystem Status: [COMPLETE] com.vmware.vcloud.fabric.foundation Subsystem Status: [COMPLETE] com.vmware.vcloud.imagetransfer-server Subsystem Status: [COMPLETE] com.vmware.vcloud.fabric.storage Subsystem Status: [COMPLETE] com.vmware.vcloud.fabric.compute Subsystem Status: [COMPLETE] com.vmware.vcloud.backend-core-base Subsystem Status: [COMPLETE] com.vmware.vcloud.fabric.net Subsystem Status: [COMPLETE] com.vmware.vcloud.service-extensibility Subsystem Status: [COMPLETE] com.vmware.vcloud.backend-core Subsystem Status: [COMPLETE] com.vmware.vcloud.vapp-lifecycle Subsystem Status: [COMPLETE] com.vmware.vcloud.content-library Subsystem Status: [COMPLETE] com.vmware.vcloud.presentation-api-impl Subsystem Status: [COMPLETE] com.vmware.vcloud.metrics-core Subsystem Status: [COMPLETE] com.vmware.vcloud.rest-api-handlers Subsystem Status: [WAITING] com.vmware.vcloud.jax-rs-servlet Subsystem Status: [WAITING] com.vmware.vcloud.ui-vcloud-webapp Subsystem Status: [WAITING] Application Initialization: 'com.vmware.vcloud.common.core' 90% complete. Subsystem 'com.vmware.vcloud.rest-api-handlers' started Application Initialization: 'com.vmware.vcloud.common.core' 95% complete. Subsystem 'com.vmware.vcloud.jax-rs-servlet' started Application Initialization: 'com.vmware.vcloud.common.core' 100% complete. Subsystem 'com.vmware.vcloud.ui-vcloud-webapp' started Application Initialization: 'com.vmware.vcloud.common.core' complete. Server is ready in 2:15 (minutes:seconds) Successfully posted pending audit events: com/vmware/vcloud/event/cell/start Successfully verified transfer spooling area: /opt/vmware/vcloud-director/data/transfer Application startup event: Waiting for subsystem 'com.vmware.vcloud.statsfeeder-application' Application startup event: Subsystem 'com.vmware.vcloud.statsfeeder-application' startup initiated. ----------------------------- Managed entity: com.vmware.vim25.ManagedObjectReference@5a10fbf Current supported: true Refresh rate: 20 Summary supported: true ----------------------------- |
Those familiar with the vCD cell.log entries you will notice a couple new startup entries…there is a new port (8999) thats bound for KairosDB communications and the tail end of the log above appears after the config..though I’m not sure what it actually does.
Once the cell services have been restarted the VM metrics should start to be collected by KairosDB. Wait about 5-10 minutes and then enter this URL into a web browser : http://IP-KairosDD:8080/api/v1/metricnames You should see the following displayed:
You can see that the results show metrics relating to VMs…this is a good thing! Using a RestClient you will see a much prettier output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# GETTING KAIROSDB METRIC STATUS # API CALL: http://KDB-IP:8080/api/v1/metricnames # METHOD: GET #EXAMPLE JSON RESPONSE { results: [17] 0: "cpu.usage.average" 1: "cpu.usage.maximum" 2: "cpu.usagemhz.average" 3: "disk.provisioned.latest" 4: "disk.used.latest" 5: "kairosdb.datastore.queries_waiting" 6: "kairosdb.datastore.query_collisions" 7: "kairosdb.datastore.query_time" 8: "kairosdb.datastore.write_size" 9: "kairosdb.jvm.free_memory" 10: "kairosdb.jvm.max_memory" 11: "kairosdb.jvm.thread_count" 12: "kairosdb.jvm.total_memory" 13: "kairosdb.metric_counters" 14: "kairosdb.protocol.http_request_count" 15: "kairosdb.protocol.telnet_request_count" 16: "mem.usage.average" } |
API Calls to Retrieve Current and Historical Metrics:
The following API Calls are used to gather current and historical VM metrics for vCD VMs. The Machine ID required used the VM GUID as seen in vCenter. The ID can be sourced from the VM Name. The vCD Machine ID shown below in the brackets is what you are after.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# GETTING CURRENT VM METRICS # API CALL: https://NSX-MGR-IP:8080/api/vApp/vm-GUID/metrics/current # METHOD: GET # HEADER: Authorization: Basic BASE64ENCSTRING # HEADER: Accept: application/*+xml;version=5.6 https://172.17.0.34/api/vApp/vm-70064906-1834-4944-9e0c-8d1e32604ce7/metrics/current #EXAMPLE RESPONSE <?xml version="1.0" encoding="UTF-8" ?> <CurrentUsage xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://172.17.0.34/api/v1.5/schema/master.xsd"> <Link rel="up" href="https://mycloud.per.zettagrid.com/api/vApp/vm-70064906-1834-4944-9e0c-8d1e32604ce7" type="application/vnd.vmware.vcloud.vm+xml" /> <Metric name="mem.usage.average" unit="PERCENT" value="60.99" /> <Metric name="cpu.usage.average" unit="PERCENT" value="24.86" /> <Metric name="cpu.usage.maximum" unit="PERCENT" value="24.86" /> <Metric name="cpu.usagemhz.average" unit="MEGAHERTZ" value="621.0" /> <Metric name="disk.used.latest" unit="KILOBYTE" value="0.0" /> <Metric name="disk.provisioned.latest" unit="KILOBYTE" value="0.0" /> </CurrentUsage> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# GETTING HISTORIC VM METRICS # API CALL: https://NSX-MGR-IP:8080/api/vApp/vm-GUID/metrics/historic # METHOD: GET # HEADER: Authorization: Basic BASE64ENCSTRING # HEADER: Accept: application/*+xml;version=5.6 https://172.17.0.34/api/vApp/vm-70064906-1834-4944-9e0c-8d1e32604ce7/metrics/historic #EXAMPLE RESPONSE <?xml version="1.0" encoding="UTF-8" ?> <HistoricUsage xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://172.17.0.34/api/v1.5/schema/master.xsd"> <Link rel="up" href="https://mycloud.per.zettagrid.com/api/vApp/vm-70064906-1834-4944-9e0c-8d1e32604ce7" type="application/vnd.vmware.vcloud.vm+xml" /> <MetricSeries expectedInterval="1800" name="disk.used.latest" unit="KILOBYTE"> <Sample timestamp="2015-06-19T04:55:00.000Z" value="0.0" /> </MetricSeries> <MetricSeries expectedInterval="300" name="cpu.usage.average" unit="PERCENT"> <Sample timestamp="2015-06-19T05:11:20.000Z" value="8.653333455324173" /> <Sample timestamp="2015-06-19T05:13:20.000Z" value="6.577999913692475" /> <Sample timestamp="2015-06-19T05:18:20.000Z" value="0.6933333426713943" /> </MetricSeries> <MetricSeries expectedInterval="300" name="mem.usage.average" unit="PERCENT"> <Sample timestamp="2015-06-19T05:11:00.000Z" value="72.9985716683524" /> <Sample timestamp="2015-06-19T05:13:20.000Z" value="56.32533467610677" /> <Sample timestamp="2015-06-19T05:18:20.000Z" value="28.073333899180096" /> </MetricSeries> <MetricSeries expectedInterval="300" name="cpu.usage.maximum" unit="PERCENT"> <Sample timestamp="2015-06-19T05:11:20.000Z" value="8.653333455324173" /> <Sample timestamp="2015-06-19T05:13:20.000Z" value="6.577999913692475" /> <Sample timestamp="2015-06-19T05:18:20.000Z" value="0.6933333426713943" /> </MetricSeries> <MetricSeries expectedInterval="300" name="cpu.usagemhz.average" unit="MEGAHERTZ"> <Sample timestamp="2015-06-19T05:11:20.000Z" value="215.83333333333334" /> <Sample timestamp="2015-06-19T05:13:20.000Z" value="164.13333333333333" /> <Sample timestamp="2015-06-19T05:18:20.000Z" value="17.166666666666668" /> </MetricSeries> <MetricSeries expectedInterval="1800" name="disk.provisioned.latest" unit="KILOBYTE"> <Sample timestamp="2015-06-19T04:55:00.000Z" value="0.0" /> </MetricSeries> </HistoricUsage> |