SlideShare a Scribd company logo
The Cloud Specialists
CloudStackUsage Service Deep Dive
Dag Sonstebo
Cloud Architect
dag.sonstebo@shapeblue.com
Twitter: @dagsonstebo
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
Ab ou t m e
• Cloud Architect @ ShapeBlue
• Background:
• Cloud and virtualization architect with 20 years experience
from the service provider, financial and manufacturing
industries.
• Specialize in:
• Cloud infrastructure architecture and engineering.
• Virtualization - VMware vSphere, Citrix XenServer, KVM.
• Automationand configurationmanagement, love Ansible.
• Involvedwith CloudStacksince version 2.1.
• Downtime: traveland motorbikes.
C l i c k t o e d i t
The Cloud Specialists ShapeBlue.com @ShapeBlue
“ShapeBlue are expert builders of public & private
clouds. They are the leading global CloudStack
services company.”
Ab o u t S h ap eB l u e
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
S h a p e B l u e c u s t o m e r s
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
S h a p e B l u e c u s t o m e r s
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
S h a p e B l u e c u s t o m e r s
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
CloudStack usage service
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
O ver vi ew
CloudStack usage is a complimentary service
which:
• tracks end user consumption of CloudStack
resources
• summarizes all data in a separate database for
reporting or billing
The usage database can be:
• queried directly
• queried through the CloudStack API
• or it can be integrated into external billing or reporting systems.
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
H ow d o I i n s t al l i t ?
CentOS:
# yum install cloudstack-usage
# chkconfig cloudstack-usage on
# service cloudstack-usage on
Ubuntu:
# apt-get install cloudstack-usage
# update-rc.d cloudstack-usage defaults
# service cloudstack-usage on
Configuration files:
# ls -l /etc/cloudstack/usage/
total 4
lrwxrwxrwx. 1 root root 40 Sep 8 08:18 db.properties -> /etc/cloudstack/management/db.properties
lrwxrwxrwx. 1 root root 30 Sep 8 08:18 key -> /etc/cloudstack/management/key
-rw-r--r--. 1 root root 2968 Jul 12 10:36 log4j-cloud.xml
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
G l ob al s et t i n g s
Setting Comment
usage.stats.job.aggregation.range The range of time for aggregating the user statistics specified in
minutes (e.g. 1440 for daily (default), 60 for hourly)
usage.stats.job.exec.time The time at which the usage statistics aggregation job will run
(default 00:15). This is utilized together with the
usage.stats.job.aggregation.range to determine service scheduling.
enable.usage.server Switches usage service on/off
usage.aggregation.timezone Timezone used for usage aggregation (default “GMT”)
usage.execution.timezone Timezone for usage job execution
usage.sanity.check.interval Interval (in days) to check sanity of usage data
usage.snapshot.virtualsize.select Set the value to true if snapshot usage need to consider virtual size,
else physical size is considered (default “false”)
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
U s ag e even t s an d t y p es
• All lifecycle events for resources in
CloudStack are tracked in the
cloud.usage_event table.
• This table lists all timestamps for:
• Create / destroy
• Start / stop
• Request / release
• These events are processed by the
usage service and categorized as usage
types.
Create
Start
Request
Release
Stop
Destroy
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
U s ag e t y p es
# cloudmonkey list usagetypes
count = 21
usagetype:
+-------------+--------------------------------------+
| usagetypeid | description |
+-------------+--------------------------------------+
| 1 | Running Vm Usage |
| 2 | Allocated Vm Usage |
| 3 | IP Address Usage |
| 4 | Network Usage (Bytes Sent) |
| 5 | Network Usage (Bytes Received) |
| 6 | Volume Usage |
| 7 | Template Usage |
| 8 | ISO Usage |
| 9 | Snapshot Usage |
| 10 | Security Group Usage |
| 11 | Load Balancer Usage |
| 12 | Port Forwarding Usage |
| 13 | Network Offering Usage |
| 14 | VPN users usage |
| 21 | VM Disk usage(I/O Read) |
| 22 | VM Disk usage(I/O Write) |
| 23 | VM Disk usage(Bytes Read) |
| 24 | VM Disk usage(Bytes Write) |
| 25 | VM Snapshot storage usage |
| 27 | VM Snapshot on primary storage usage |
| 28 | VM Backup storage usage |
+-------------+--------------------------------------+
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
P r o c e s s f l o w – AP I c a l l a n d u s a g e j o b s
API
• Call received
API
• Call processed
DB
• Lifecycle action
written to
cloud.usage_event
Start
• Execute usage job at:
• usage.stats.job.exec.time
• + usage.stats.job.aggregation.range
Copy
• Copy all new events:
• FROM: cloud.usage_event
• TO: cloud_usage.usage_event
• Copy account table for reference
Process
• Summarise each usage type per account:
• Populate helper tables, e.g. usage_storage,
usage_vm_instance, etc
• Aggregate usage types for all accounts
• in cloud_usage.cloud_usage
• based on usage.status.job.aggregation.range
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
U s ag e even t s
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
H el p er t ab l es
• Helper tables summarise each resource with:
• start and end datestamp
• usage type (if required)
• Note though – every table has a different schema depending on
the resource usage type
• Example (all in the cloud_usage) DB:
• usage_vm_instance
• usage_storage
• usage_vm_disk
• Etc.
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
H e l p e r t a b l e s - e xa m p l e s
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
H e l p e r t a b l e s - e xa m p l e s
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
H e l p e r t a b l e s - e xa m p l e s
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
U s ag e ag g r eg at i on
• Once helper tables are processed the
cloud_usage.cloud_usage table is populated.
• The usage service analyses the helper table
entries and divides the time usage for each by
the time period defined in
“usage.stats.job.aggregation.range”.
• E.g.:
• how many hours has a VM been running in each 1440
minute (24 hour) period
• how many hours has each GB of storage been used in
1440 minute period
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
C l o u d _ u s a g e . c l o u d _ u s a g e
Usage
type
Raw
usage
Resource
ID
Vol/snap
size
Start /
end date
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
Q u er y t h r ou g h AP I w i t h C l o u d Mo n k e y
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
R e p o r t i n g e xa m p l e – r u n n i n g VMs
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
R ep or t i n g exam p l e – n et w or k u t i l i z at i on
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
R ep or t i n g exam p l e – vol u m es
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
R e p o r t i n g e x a mp l e – I P a d d r e s s e s , p o r t f o r w a r d i n g a n d VP N
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
Tr o u b l e s h o o t i n g
• Check usage job status in the database:
• Usage jobs:
• On service startup the usage service will check the DB whether last job was ran – if not this job is
ran once.
• Note if execution time takes longer than “usage.stats.job.aggregation.range” – default 1 day. If so
jobs may overlap and cause problems, hence avoid this situation.
• Logs:
• /var/log/cloudstack/usage/usage.log
• Relativelyverbose – will show processing of usage types, accounts, etc.
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
Tr o u b l e s h o o t i n g a n d h o u s e k e e p i n g
• DB inconsistencies:
• Back up databases before editing…….. ☺
• If usage job fails it will report in logs what the problem is.
• Watch out for inconsistencies like STOP entry without START, DESTROY without CREATE or double
entries – e.g. 2 x START entries for a VM.
• If required you can add/delete entries in the cloud.usage_event table.
• Housekeeping of cloud_usage table:
• Use the removeRawUsageRecords API call to delete entries older than 5 days.
# cloudmonkey removeRawUsageRecords interval=5
success = true
• Regenerating usage data:
• Use the generateUsageRecords API call to rerun usage in case of failure:
# cloudmonkey generateUsageRecords startdate=2018-09-01 enddate=2018-09-30
success = true
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
A b r i ef w or d on t h e q u ot a s er vi c e
• In the cloud_usage database you will see a number of “quota_*” tables.
• These are not directly used by the usage service, rather the separate
Quota service.
• Check the following for more information:
• https://cwiki.apache.org/confluence/display/CLOUDSTACK/Quota+Service+-
+FS
• http://docs.cloudstack.apache.org/projects/cloudstack-
administration/en/4.11/plugins/quota.html
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
Any questions?
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
Some references
• Blog post:
http://www.shapeblue.com/cloudstack-usage-service-deep-dive
This has more technicaldetail.
• CloudStack usage references:
• http://docs.cloudstack.apache.org/projects/cloudstack-
installation/en/4.11/optional_installation.html
• http://docs.cloudstack.apache.org/projects/cloudstack-
administration/en/4.11/usage.html
C l i c k t o e d i t
The Cloud Specialists
ShapeBlue.com @ShapeBlue
Mo r e i n f o r m a t i o n
• Slide decks: http://www.slideshare.net/shapeblue
• Blog: http://shapeblue.com/blog
http://dsonstebo.wordpress.com
• Email: dag.sonstebo@shapeblue.com
• Twitter: @dagsonstebo
• Web: http://shapeblue.com
The Cloud Specialists
CloudStackUsage Service Deep Dive
Dag Sonstebo
Cloud Architect
dag.sonstebo@shapeblue.com
Twitter: @dagsonstebo

More Related Content

PPTX
Paul Angus - CloudStack Container Service
PDF
Paul Angus – Backup & Recovery in CloudStack
PPTX
CloudStack news
PDF
Introductions & CloudStack news - Giles Sirett
PPTX
Adam Dagnall: Advanced S3 compatible storage integration in CloudStack
PDF
Paul Angus - what's new in ACS 4.11
PDF
John Spray - Ceph in Kubernetes
PDF
CloudStack usage service
Paul Angus - CloudStack Container Service
Paul Angus – Backup & Recovery in CloudStack
CloudStack news
Introductions & CloudStack news - Giles Sirett
Adam Dagnall: Advanced S3 compatible storage integration in CloudStack
Paul Angus - what's new in ACS 4.11
John Spray - Ceph in Kubernetes
CloudStack usage service

What's hot (20)

PDF
Wido den Hollander - building highly available cloud with Ceph and CloudStack
PDF
Giles Sirett - welcome and CloudStack news
PDF
Giles Sirett: Introduction and CloudStack news
PDF
Boyan Krosnov - Building a software-defined cloud - our experience
PDF
Paul Angus - CloudStack Backup and Recovery Framework
PDF
Boris Stoyanov - some new features in Apache cloudStack
PDF
KVM High Availability Regardless of Storage - Gabriel Brascher, VP of Apache ...
PDF
Building software defined clouds - Boyan Ivanov
PDF
XCP-ng - Olivier Lambert
PDF
New stuff in CloudStack!
PPTX
CloudStack Container Service
PPTX
vBACD - Deploying Infrastructure-as-a-Service with CloudStack - 2/28
PPTX
Containers and CloudStack
PDF
XCP-ng - past, present and future
PPTX
Introduction and news
PPTX
CloudStack news
PDF
CSEUG introduction
PDF
Customising the CloudStack UI - CloudStack European User Group Virtual, May 2...
PPTX
Introduction and CloudStack news
PPTX
Improving CloudStack for operators
Wido den Hollander - building highly available cloud with Ceph and CloudStack
Giles Sirett - welcome and CloudStack news
Giles Sirett: Introduction and CloudStack news
Boyan Krosnov - Building a software-defined cloud - our experience
Paul Angus - CloudStack Backup and Recovery Framework
Boris Stoyanov - some new features in Apache cloudStack
KVM High Availability Regardless of Storage - Gabriel Brascher, VP of Apache ...
Building software defined clouds - Boyan Ivanov
XCP-ng - Olivier Lambert
New stuff in CloudStack!
CloudStack Container Service
vBACD - Deploying Infrastructure-as-a-Service with CloudStack - 2/28
Containers and CloudStack
XCP-ng - past, present and future
Introduction and news
CloudStack news
CSEUG introduction
Customising the CloudStack UI - CloudStack European User Group Virtual, May 2...
Introduction and CloudStack news
Improving CloudStack for operators
Ad

Similar to Dag Sonstebo - CloudStack usage service (20)

PPTX
CloudStack Metering - Working with Usage Data #CCCNA14
PPTX
CloudStack Metering – Working with the Usage Data
PPTX
CloudStack Metering – Working with the Usage Data
PPTX
Working with CloudStack Usage Data - CCCEU13
PPTX
Working with CloudStack Usage Data
PDF
Whats new in Cloudstack 4.11 - behind the headlines
PPTX
CCCNA17 CloudStack Container Service
PDF
CloudStack Container Service
PDF
Session 2 - CloudStack Usage and Application (2013.Q3)
PDF
CloudStack - Top 5 Technical Issues and Troubleshooting
PPTX
Silicon Valley CloudStack User Group - Designing CloudStack Clouds
PDF
Elevating Cloud Infrastructure with Object Storage, DRS, VM Scheduling, and D...
PPTX
Cloudstack container service
PPTX
Whats the Use!? (Real Customer Use-Cases)
PPTX
From The Coalface CCCEU13
PPTX
Silicon Valley CloudStack User Group - Introduction to Apache CloudStack
PPTX
The business Use-Case’s for building clouds with Apache CloudStack
PPTX
ShapeBlue South Africa Launch-Iaas business use cases
PPTX
Designing cloud stack clouds geoff higginbottom/shapeblue
PPTX
Building Clouds with Apache CloudStack - the business use-cases
CloudStack Metering - Working with Usage Data #CCCNA14
CloudStack Metering – Working with the Usage Data
CloudStack Metering – Working with the Usage Data
Working with CloudStack Usage Data - CCCEU13
Working with CloudStack Usage Data
Whats new in Cloudstack 4.11 - behind the headlines
CCCNA17 CloudStack Container Service
CloudStack Container Service
Session 2 - CloudStack Usage and Application (2013.Q3)
CloudStack - Top 5 Technical Issues and Troubleshooting
Silicon Valley CloudStack User Group - Designing CloudStack Clouds
Elevating Cloud Infrastructure with Object Storage, DRS, VM Scheduling, and D...
Cloudstack container service
Whats the Use!? (Real Customer Use-Cases)
From The Coalface CCCEU13
Silicon Valley CloudStack User Group - Introduction to Apache CloudStack
The business Use-Case’s for building clouds with Apache CloudStack
ShapeBlue South Africa Launch-Iaas business use cases
Designing cloud stack clouds geoff higginbottom/shapeblue
Building Clouds with Apache CloudStack - the business use-cases
Ad

More from ShapeBlue (20)

PPTX
The Yotta x CloudStack Advantage: Scalable, India-First Cloud
PPTX
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
PPTX
Extensions Framework (XaaS) - Enabling Orchestrate Anything
PDF
CloudStack GPU Integration - Rohit Yadav
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
PDF
Ampere Offers Energy-Efficient Future For AI And Cloud
PDF
Empowering Cloud Providers with Apache CloudStack and Stackbill
PDF
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
PDF
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
PDF
Fully Open-Source Private Clouds: Freedom, Security, and Control
PPTX
Pushing the Limits: CloudStack at 25K Hosts
PPTX
Stretching CloudStack over multiple datacenters
PPTX
Proposed Feature: Monitoring and Managing Cloud Usage Costs in Apache CloudStack
PPSX
CloudStack + KVM: Your Local Cloud Lab
PDF
I’d like to resell your CloudStack services, but...
PDF
Storage Setup for LINSTOR/DRBD/CloudStack
PDF
Apache CloudStack 101 - Introduction, What’s New and What’s Coming
PDF
Development of an Оbject Storage Plugin for CloudStack, Christian Reichert, s...
PDF
VM-HA with CloudStack and Linstor, Rene Peinthor
PDF
How We Use CloudStack to Provide Managed Hosting, Swen Brüseke, proIO
The Yotta x CloudStack Advantage: Scalable, India-First Cloud
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
Extensions Framework (XaaS) - Enabling Orchestrate Anything
CloudStack GPU Integration - Rohit Yadav
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
Ampere Offers Energy-Efficient Future For AI And Cloud
Empowering Cloud Providers with Apache CloudStack and Stackbill
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
Fully Open-Source Private Clouds: Freedom, Security, and Control
Pushing the Limits: CloudStack at 25K Hosts
Stretching CloudStack over multiple datacenters
Proposed Feature: Monitoring and Managing Cloud Usage Costs in Apache CloudStack
CloudStack + KVM: Your Local Cloud Lab
I’d like to resell your CloudStack services, but...
Storage Setup for LINSTOR/DRBD/CloudStack
Apache CloudStack 101 - Introduction, What’s New and What’s Coming
Development of an Оbject Storage Plugin for CloudStack, Christian Reichert, s...
VM-HA with CloudStack and Linstor, Rene Peinthor
How We Use CloudStack to Provide Managed Hosting, Swen Brüseke, proIO

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Machine learning based COVID-19 study performance prediction
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
KodekX | Application Modernization Development
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
A Presentation on Artificial Intelligence
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
Big Data Technologies - Introduction.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
20250228 LYD VKU AI Blended-Learning.pptx
The AUB Centre for AI in Media Proposal.docx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Advanced methodologies resolving dimensionality complications for autism neur...
Machine learning based COVID-19 study performance prediction
Chapter 3 Spatial Domain Image Processing.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Unlocking AI with Model Context Protocol (MCP)
Mobile App Security Testing_ A Comprehensive Guide.pdf
KodekX | Application Modernization Development
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
A Presentation on Artificial Intelligence
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
NewMind AI Weekly Chronicles - August'25 Week I

Dag Sonstebo - CloudStack usage service

  • 1. The Cloud Specialists CloudStackUsage Service Deep Dive Dag Sonstebo Cloud Architect dag.sonstebo@shapeblue.com Twitter: @dagsonstebo
  • 2. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue Ab ou t m e • Cloud Architect @ ShapeBlue • Background: • Cloud and virtualization architect with 20 years experience from the service provider, financial and manufacturing industries. • Specialize in: • Cloud infrastructure architecture and engineering. • Virtualization - VMware vSphere, Citrix XenServer, KVM. • Automationand configurationmanagement, love Ansible. • Involvedwith CloudStacksince version 2.1. • Downtime: traveland motorbikes.
  • 3. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue “ShapeBlue are expert builders of public & private clouds. They are the leading global CloudStack services company.” Ab o u t S h ap eB l u e
  • 4. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue S h a p e B l u e c u s t o m e r s
  • 5. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue S h a p e B l u e c u s t o m e r s
  • 6. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue S h a p e B l u e c u s t o m e r s
  • 7. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue CloudStack usage service
  • 8. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue O ver vi ew CloudStack usage is a complimentary service which: • tracks end user consumption of CloudStack resources • summarizes all data in a separate database for reporting or billing The usage database can be: • queried directly • queried through the CloudStack API • or it can be integrated into external billing or reporting systems.
  • 9. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue H ow d o I i n s t al l i t ? CentOS: # yum install cloudstack-usage # chkconfig cloudstack-usage on # service cloudstack-usage on Ubuntu: # apt-get install cloudstack-usage # update-rc.d cloudstack-usage defaults # service cloudstack-usage on Configuration files: # ls -l /etc/cloudstack/usage/ total 4 lrwxrwxrwx. 1 root root 40 Sep 8 08:18 db.properties -> /etc/cloudstack/management/db.properties lrwxrwxrwx. 1 root root 30 Sep 8 08:18 key -> /etc/cloudstack/management/key -rw-r--r--. 1 root root 2968 Jul 12 10:36 log4j-cloud.xml
  • 10. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue G l ob al s et t i n g s Setting Comment usage.stats.job.aggregation.range The range of time for aggregating the user statistics specified in minutes (e.g. 1440 for daily (default), 60 for hourly) usage.stats.job.exec.time The time at which the usage statistics aggregation job will run (default 00:15). This is utilized together with the usage.stats.job.aggregation.range to determine service scheduling. enable.usage.server Switches usage service on/off usage.aggregation.timezone Timezone used for usage aggregation (default “GMT”) usage.execution.timezone Timezone for usage job execution usage.sanity.check.interval Interval (in days) to check sanity of usage data usage.snapshot.virtualsize.select Set the value to true if snapshot usage need to consider virtual size, else physical size is considered (default “false”)
  • 11. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue U s ag e even t s an d t y p es • All lifecycle events for resources in CloudStack are tracked in the cloud.usage_event table. • This table lists all timestamps for: • Create / destroy • Start / stop • Request / release • These events are processed by the usage service and categorized as usage types. Create Start Request Release Stop Destroy
  • 12. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue U s ag e t y p es # cloudmonkey list usagetypes count = 21 usagetype: +-------------+--------------------------------------+ | usagetypeid | description | +-------------+--------------------------------------+ | 1 | Running Vm Usage | | 2 | Allocated Vm Usage | | 3 | IP Address Usage | | 4 | Network Usage (Bytes Sent) | | 5 | Network Usage (Bytes Received) | | 6 | Volume Usage | | 7 | Template Usage | | 8 | ISO Usage | | 9 | Snapshot Usage | | 10 | Security Group Usage | | 11 | Load Balancer Usage | | 12 | Port Forwarding Usage | | 13 | Network Offering Usage | | 14 | VPN users usage | | 21 | VM Disk usage(I/O Read) | | 22 | VM Disk usage(I/O Write) | | 23 | VM Disk usage(Bytes Read) | | 24 | VM Disk usage(Bytes Write) | | 25 | VM Snapshot storage usage | | 27 | VM Snapshot on primary storage usage | | 28 | VM Backup storage usage | +-------------+--------------------------------------+
  • 13. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue P r o c e s s f l o w – AP I c a l l a n d u s a g e j o b s API • Call received API • Call processed DB • Lifecycle action written to cloud.usage_event Start • Execute usage job at: • usage.stats.job.exec.time • + usage.stats.job.aggregation.range Copy • Copy all new events: • FROM: cloud.usage_event • TO: cloud_usage.usage_event • Copy account table for reference Process • Summarise each usage type per account: • Populate helper tables, e.g. usage_storage, usage_vm_instance, etc • Aggregate usage types for all accounts • in cloud_usage.cloud_usage • based on usage.status.job.aggregation.range
  • 14. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue U s ag e even t s
  • 15. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue H el p er t ab l es • Helper tables summarise each resource with: • start and end datestamp • usage type (if required) • Note though – every table has a different schema depending on the resource usage type • Example (all in the cloud_usage) DB: • usage_vm_instance • usage_storage • usage_vm_disk • Etc.
  • 16. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue H e l p e r t a b l e s - e xa m p l e s
  • 17. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue H e l p e r t a b l e s - e xa m p l e s
  • 18. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue H e l p e r t a b l e s - e xa m p l e s
  • 19. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue U s ag e ag g r eg at i on • Once helper tables are processed the cloud_usage.cloud_usage table is populated. • The usage service analyses the helper table entries and divides the time usage for each by the time period defined in “usage.stats.job.aggregation.range”. • E.g.: • how many hours has a VM been running in each 1440 minute (24 hour) period • how many hours has each GB of storage been used in 1440 minute period
  • 20. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue C l o u d _ u s a g e . c l o u d _ u s a g e Usage type Raw usage Resource ID Vol/snap size Start / end date
  • 21. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue Q u er y t h r ou g h AP I w i t h C l o u d Mo n k e y
  • 22. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue R e p o r t i n g e xa m p l e – r u n n i n g VMs
  • 23. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue R ep or t i n g exam p l e – n et w or k u t i l i z at i on
  • 24. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue R ep or t i n g exam p l e – vol u m es
  • 25. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue R e p o r t i n g e x a mp l e – I P a d d r e s s e s , p o r t f o r w a r d i n g a n d VP N
  • 26. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue Tr o u b l e s h o o t i n g • Check usage job status in the database: • Usage jobs: • On service startup the usage service will check the DB whether last job was ran – if not this job is ran once. • Note if execution time takes longer than “usage.stats.job.aggregation.range” – default 1 day. If so jobs may overlap and cause problems, hence avoid this situation. • Logs: • /var/log/cloudstack/usage/usage.log • Relativelyverbose – will show processing of usage types, accounts, etc.
  • 27. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue Tr o u b l e s h o o t i n g a n d h o u s e k e e p i n g • DB inconsistencies: • Back up databases before editing…….. ☺ • If usage job fails it will report in logs what the problem is. • Watch out for inconsistencies like STOP entry without START, DESTROY without CREATE or double entries – e.g. 2 x START entries for a VM. • If required you can add/delete entries in the cloud.usage_event table. • Housekeeping of cloud_usage table: • Use the removeRawUsageRecords API call to delete entries older than 5 days. # cloudmonkey removeRawUsageRecords interval=5 success = true • Regenerating usage data: • Use the generateUsageRecords API call to rerun usage in case of failure: # cloudmonkey generateUsageRecords startdate=2018-09-01 enddate=2018-09-30 success = true
  • 28. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue A b r i ef w or d on t h e q u ot a s er vi c e • In the cloud_usage database you will see a number of “quota_*” tables. • These are not directly used by the usage service, rather the separate Quota service. • Check the following for more information: • https://cwiki.apache.org/confluence/display/CLOUDSTACK/Quota+Service+- +FS • http://docs.cloudstack.apache.org/projects/cloudstack- administration/en/4.11/plugins/quota.html
  • 29. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue Any questions?
  • 30. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue Some references • Blog post: http://www.shapeblue.com/cloudstack-usage-service-deep-dive This has more technicaldetail. • CloudStack usage references: • http://docs.cloudstack.apache.org/projects/cloudstack- installation/en/4.11/optional_installation.html • http://docs.cloudstack.apache.org/projects/cloudstack- administration/en/4.11/usage.html
  • 31. C l i c k t o e d i t The Cloud Specialists ShapeBlue.com @ShapeBlue Mo r e i n f o r m a t i o n • Slide decks: http://www.slideshare.net/shapeblue • Blog: http://shapeblue.com/blog http://dsonstebo.wordpress.com • Email: dag.sonstebo@shapeblue.com • Twitter: @dagsonstebo • Web: http://shapeblue.com
  • 32. The Cloud Specialists CloudStackUsage Service Deep Dive Dag Sonstebo Cloud Architect dag.sonstebo@shapeblue.com Twitter: @dagsonstebo