Analyzing CloudStack Usage Records with Excel
Join the DZone community and get the full member experience.Join For Free
curator's note: the content of this article was originally written by david nailey on the
build a cloud blog.
wrote up a post over a year ago about analyzing his cloud usage stats
with excel. i was going to refer to that, and when i went looking for
it, i realized that it was posted as a kb article on the now defunct
docs.cloudstack.org site. since i still had the write up, and it's still
relevant, i thought i'd repost that content here, so it is accessible
in my setup usage server runs every 24 hours. usage database called “cloud_usage” is on the same mysql server machine as main database called “cloud”. resource usage is stored in table called cloud_usage (same name as database). i use following query to pull de-normalized usage records into comma delimited file ready to be processed in excel:
(select dc.name as "datacenter", ac.account_name as "account", u.domain_id as "domain id", u.raw_usage, s.cpu as "cpu count", s.speed as "cpu, mhz", s.ram_size as "ram, mb", 8589934592/1024/1024/1024 as "storage, gb", u.start_date, "-", u.offering_id, u.usage_id, u.usage_type, u.description from cloud_usage.cloud_usage u, cloud.account ac, cloud.data_center dc, cloud.service_offering s where u.account_id=ac.id and u.zone_id=dc.id and u.offering_id=s.id and u.usage_type=1) union (select dc.name as "datacenter", ac.account_name as "account", u.domain_id as "domain id", u.raw_usage, null as "cpu count", null as "cpu, mhz", null as "ram mb", u.size/1024/1024/1024 as "storage, gb", u.start_date, "-", u.offering_id, u.usage_id, u.usage_type, u.description from cloud_usage.cloud_usage u, cloud.account ac, cloud.data_center dc, cloud.disk_offering dsk where u.account_id=ac.id and u.zone_id=dc.id and u.offering_id=dsk.id and u.usage_type=6)this query combines vms and data volumes usage into the same table and de-referencing id fields. for now i am not including network usage data since i am using direct attached vlan based networking model. please note that usage_type “1” corresponds to vm, “6” – to data volume.
in order to import data into excel we need to install mysql odbc connector which will allow us to connect to mysql server directly. the mysql odbc connector is available free of charge from oracle.
when you install the connector open a new excel workbook, click data, then select “from other sources” then select “from microsoft query”. select “new data source”
name the source and select mysql odbc driver:
i am using ssh tunnel and read-only account with read privileges to cloud and cloud_usage database. when you enter credentials click test button and select cloud_usage database.
the new data source is available now.
select the newly created data source and click ok button. welcome to windows 3.1 interface! do not use microsoft query wizard to create query. cancel all the prompts and click sql button go to sql statement window.
paste your sql into ridiculously small window and save your query into a file with meaningful name. excel will prompt you where to put the resulting data, accept the defaults.
the result of this exercise will be our query results imported into excel spreadsheet. here is how it looks like for me:
please note that all my templates have 8gb hdd so i hardcode root disk size into sql query. now let’s analyze some data. click top right corner to select the whole sheet and click insert in excel main menu, then pivot table, and then pivot chart. make following selection in pivot table field list:
Published at DZone with permission of Mark Hinkle, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Revolutionizing System Testing With AI and ML
Getting Started With Istio in AWS EKS for Multicluster Setup
Database Integration Tests With Spring Boot and Testcontainers
Introduction to Domain-Driven Design