sureshanaparti commented on PR #11531:
URL: https://github.com/apache/cloudstack/pull/11531#issuecomment-3389915308
Verified the usage, event and volumes records when volumes are attached to
& detached from VMs. LGTM.
```
mysql> SELECT * FROM cloud.usage_event WHERE type LIKE '%VOLUME%' AND
resource_id IN (8, 10) ORDER BY id;
+----+---------------+------------+---------------------+---------+-------------+---------------+-------------+-------------+------------+---------------+-----------+--------------+-------+
| id | type | account_id | created | zone_id |
resource_id | resource_name | offering_id | template_id | size |
resource_type | processed | virtual_size | vm_id |
+----+---------------+------------+---------------------+---------+-------------+---------------+-------------+-------------+------------+---------------+-----------+--------------+-------+
| 12 | VOLUME.CREATE | 2 | 2025-10-09 09:55:02 | 1 |
8 | DATA02 | 6 | NULL | 3221225472 | NULL |
0 | NULL | NULL |
| 20 | VOLUME.CREATE | 2 | 2025-10-09 09:55:24 | 1 |
10 | DATA04 | 6 | NULL | 1073741824 | NULL |
0 | NULL | NULL |
| 22 | VOLUME.ATTACH | 2 | 2025-10-09 09:55:55 | 1 |
8 | DATA02 | 6 | NULL | 3221225472 | NULL |
0 | NULL | 3 |
| 24 | VOLUME.ATTACH | 2 | 2025-10-09 09:56:07 | 1 |
10 | DATA04 | 6 | NULL | 1073741824 | NULL |
0 | NULL | 6 |
| 33 | VOLUME.DETACH | 2 | 2025-10-09 10:31:13 | 1 |
8 | DATA02 | 6 | NULL | 3221225472 | NULL |
0 | NULL | NULL |
| 34 | VOLUME.DETACH | 2 | 2025-10-09 10:31:17 | 1 |
10 | DATA04 | 6 | NULL | 1073741824 | NULL |
0 | NULL | NULL |
| 37 | VOLUME.ATTACH | 2 | 2025-10-10 08:42:33 | 1 |
8 | DATA02 | 6 | NULL | 3221225472 | NULL |
0 | NULL | 7 |
| 38 | VOLUME.DETACH | 2 | 2025-10-10 08:55:37 | 1 |
8 | DATA02 | 6 | NULL | 3221225472 | NULL |
0 | NULL | NULL |
| 39 | VOLUME.ATTACH | 2 | 2025-10-10 09:00:39 | 1 |
10 | DATA04 | 6 | NULL | 1073741824 | NULL |
0 | NULL | 3 |
| 40 | VOLUME.ATTACH | 2 | 2025-10-10 09:01:39 | 1 |
8 | DATA02 | 6 | NULL | 3221225472 | NULL |
0 | NULL | 6 |
| 41 | VOLUME.DETACH | 2 | 2025-10-10 09:05:23 | 1 |
8 | DATA02 | 6 | NULL | 3221225472 | NULL |
0 | NULL | NULL |
| 42 | VOLUME.DETACH | 2 | 2025-10-10 09:05:31 | 1 |
10 | DATA04 | 6 | NULL | 1073741824 | NULL |
0 | NULL | NULL |
+----+---------------+------------+---------------------+---------+-------------+---------------+-------------+-------------+------------+---------------+-----------+--------------+-------+
12 rows in set (0.00 sec)
mysql> SELECT * FROM cloud_usage.usage_event WHERE type LIKE '%VOLUME%' AND
resource_id IN (8, 10) ORDER BY id;
+----+---------------+------------+---------------------+---------+-------------+---------------+-------------+-------------+------------+---------------+-----------+--------------+-------+
| id | type | account_id | created | zone_id |
resource_id | resource_name | offering_id | template_id | size |
resource_type | processed | virtual_size | vm_id |
+----+---------------+------------+---------------------+---------+-------------+---------------+-------------+-------------+------------+---------------+-----------+--------------+-------+
| 12 | VOLUME.CREATE | 2 | 2025-10-09 09:55:02 | 1 |
8 | DATA02 | 6 | NULL | 3221225472 | NULL |
1 | NULL | NULL |
| 20 | VOLUME.CREATE | 2 | 2025-10-09 09:55:24 | 1 |
10 | DATA04 | 6 | NULL | 1073741824 | NULL |
1 | NULL | NULL |
| 22 | VOLUME.ATTACH | 2 | 2025-10-09 09:55:55 | 1 |
8 | DATA02 | 6 | NULL | 3221225472 | NULL |
1 | NULL | 3 |
| 24 | VOLUME.ATTACH | 2 | 2025-10-09 09:56:07 | 1 |
10 | DATA04 | 6 | NULL | 1073741824 | NULL |
1 | NULL | 6 |
| 33 | VOLUME.DETACH | 2 | 2025-10-09 10:31:13 | 1 |
8 | DATA02 | 6 | NULL | 3221225472 | NULL |
1 | NULL | NULL |
| 34 | VOLUME.DETACH | 2 | 2025-10-09 10:31:17 | 1 |
10 | DATA04 | 6 | NULL | 1073741824 | NULL |
1 | NULL | NULL |
| 37 | VOLUME.ATTACH | 2 | 2025-10-10 08:42:33 | 1 |
8 | DATA02 | 6 | NULL | 3221225472 | NULL |
1 | NULL | 7 |
| 38 | VOLUME.DETACH | 2 | 2025-10-10 08:55:37 | 1 |
8 | DATA02 | 6 | NULL | 3221225472 | NULL |
1 | NULL | NULL |
| 39 | VOLUME.ATTACH | 2 | 2025-10-10 09:00:39 | 1 |
10 | DATA04 | 6 | NULL | 1073741824 | NULL |
1 | NULL | 3 |
| 40 | VOLUME.ATTACH | 2 | 2025-10-10 09:01:39 | 1 |
8 | DATA02 | 6 | NULL | 3221225472 | NULL |
1 | NULL | 6 |
| 41 | VOLUME.DETACH | 2 | 2025-10-10 09:05:23 | 1 |
8 | DATA02 | 6 | NULL | 3221225472 | NULL |
1 | NULL | NULL |
| 42 | VOLUME.DETACH | 2 | 2025-10-10 09:05:31 | 1 |
10 | DATA04 | 6 | NULL | 1073741824 | NULL |
1 | NULL | NULL |
+----+---------------+------------+---------------------+---------+-------------+---------------+-------------+-------------+------------+---------------+-----------+--------------+-------+
12 rows in set (0.01 sec)
mysql> SELECT * FROM cloud_usage.usage_volume WHERE volume_id IN (8, 10)
ORDER BY id;
+----+-----------+---------+------------+-----------+------------------+-------------+------------+---------------------+---------------------+-------+
| id | volume_id | zone_id | account_id | domain_id | disk_offering_id |
template_id | size | created | deleted | vm_id |
+----+-----------+---------+------------+-----------+------------------+-------------+------------+---------------------+---------------------+-------+
| 8 | 8 | 1 | 2 | 1 | 6 |
NULL | 3221225472 | 2025-10-09 09:55:02 | NULL | NULL |
| 10 | 10 | 1 | 2 | 1 | 6 |
NULL | 1073741824 | 2025-10-09 09:55:24 | NULL | NULL |
| 12 | 8 | 1 | 2 | 1 | 6 |
NULL | 3221225472 | 2025-10-09 09:55:55 | 2025-10-09 10:31:13 | 3 |
| 14 | 10 | 1 | 2 | 1 | 6 |
NULL | 1073741824 | 2025-10-09 09:56:07 | 2025-10-09 10:31:17 | 6 |
| 63 | 8 | 1 | 2 | 1 | 6 |
NULL | 3221225472 | 2025-10-10 08:42:33 | 2025-10-10 08:55:37 | 7 |
| 66 | 10 | 1 | 2 | 1 | 6 |
NULL | 1073741824 | 2025-10-10 09:00:39 | 2025-10-10 09:05:31 | 3 |
| 67 | 8 | 1 | 2 | 1 | 6 |
NULL | 3221225472 | 2025-10-10 09:01:39 | 2025-10-10 09:05:23 | 6 |
+----+-----------+---------+------------+-----------+------------------+-------------+------------+---------------------+---------------------+-------+
7 rows in set (0.00 sec)
```
Usage records:
```
(cmk) 🐱 > list usagerecords startdate=2025-10-07 enddate=2025-10-10 type=6
usageid=2c218702-abff-46e8-bc8a-3e12fffa2188
{
"count": 436,
"usagerecord": [
{
"account": "admin",
"accountid": "f709bdb4-a4f1-11f0-9b4e-1e00e6000172",
"description": "Volume usage for DATA02
(2c218702-abff-46e8-bc8a-3e12fffa2188) attached to VM testvm01
(282033c0-18df-46cd-809a-470f1a38a800) with disk offering Custom
(b528eb0d-0efd-4df7-bffe-f0db170ac2e1) and size (3.00 GB) 3221225472",
"domain": "ROOT",
"domainid": "9f57bbb6-a4f1-11f0-9b4e-1e00e6000172",
"domainpath": "/",
"enddate": "2025-10-09T09:59:59+0000",
"offeringid": "b528eb0d-0efd-4df7-bffe-f0db170ac2e1",
"rawusage": "0.068056",
"size": 3221225472,
"startdate": "2025-10-09T09:00:00+0000",
"tags": [],
"usage": "0.068056 Hrs",
"usageid": "2c218702-abff-46e8-bc8a-3e12fffa2188",
"usagetype": 6,
"virtualmachineid": "282033c0-18df-46cd-809a-470f1a38a800",
"zoneid": "1f5131c0-cb48-4dc4-bb7c-33f8a0de2ec9"
},
...
{
"account": "admin",
"accountid": "f709bdb4-a4f1-11f0-9b4e-1e00e6000172",
"description": "Volume usage for DATA02
(2c218702-abff-46e8-bc8a-3e12fffa2188) with disk offering Custom
(b528eb0d-0efd-4df7-bffe-f0db170ac2e1) and size (3.00 GB) 3221225472",
"domain": "ROOT",
"domainid": "9f57bbb6-a4f1-11f0-9b4e-1e00e6000172",
"domainpath": "/",
"enddate": "2025-10-10T07:59:59+0000",
"offeringid": "b528eb0d-0efd-4df7-bffe-f0db170ac2e1",
"rawusage": "1",
"size": 3221225472,
"startdate": "2025-10-10T07:00:00+0000",
"tags": [],
"usage": "1 Hrs",
"usageid": "2c218702-abff-46e8-bc8a-3e12fffa2188",
"usagetype": 6,
"zoneid": "1f5131c0-cb48-4dc4-bb7c-33f8a0de2ec9"
},
{
"account": "admin",
"accountid": "f709bdb4-a4f1-11f0-9b4e-1e00e6000172",
"description": "Volume usage for DATA02
(2c218702-abff-46e8-bc8a-3e12fffa2188) attached to VM testvm04
(332284cf-f56a-4075-adf5-3ac4f4fc8033) with disk offering Custom
(b528eb0d-0efd-4df7-bffe-f0db170ac2e1) and size (3.00 GB) 3221225472",
"domain": "ROOT",
"domainid": "9f57bbb6-a4f1-11f0-9b4e-1e00e6000172",
"domainpath": "/",
"enddate": "2025-10-10T08:59:59+0000",
"offeringid": "b528eb0d-0efd-4df7-bffe-f0db170ac2e1",
"rawusage": "0.217778",
"size": 3221225472,
"startdate": "2025-10-10T08:00:00+0000",
"tags": [],
"usage": "0.217778 Hrs",
"usageid": "2c218702-abff-46e8-bc8a-3e12fffa2188",
"usagetype": 6,
"virtualmachineid": "332284cf-f56a-4075-adf5-3ac4f4fc8033",
"zoneid": "1f5131c0-cb48-4dc4-bb7c-33f8a0de2ec9"
},
{
"account": "admin",
"accountid": "f709bdb4-a4f1-11f0-9b4e-1e00e6000172",
"description": "Volume usage for DATA02
(2c218702-abff-46e8-bc8a-3e12fffa2188) with disk offering Custom
(b528eb0d-0efd-4df7-bffe-f0db170ac2e1) and size (3.00 GB) 3221225472",
"domain": "ROOT",
"domainid": "9f57bbb6-a4f1-11f0-9b4e-1e00e6000172",
"domainpath": "/",
"enddate": "2025-10-10T08:59:59+0000",
"offeringid": "b528eb0d-0efd-4df7-bffe-f0db170ac2e1",
"rawusage": "1",
"size": 3221225472,
"startdate": "2025-10-10T08:00:00+0000",
"tags": [],
"usage": "1 Hrs",
"usageid": "2c218702-abff-46e8-bc8a-3e12fffa2188",
"usagetype": 6,
"zoneid": "1f5131c0-cb48-4dc4-bb7c-33f8a0de2ec9"
},
{
"account": "admin",
"accountid": "f709bdb4-a4f1-11f0-9b4e-1e00e6000172",
"description": "Volume usage for DATA02
(2c218702-abff-46e8-bc8a-3e12fffa2188) attached to VM testvm02
(ca3309cd-15e7-4718-9b33-d2c3af12ecd8) with disk offering Custom
(b528eb0d-0efd-4df7-bffe-f0db170ac2e1) and size (3.00 GB) 3221225472",
"domain": "ROOT",
"domainid": "9f57bbb6-a4f1-11f0-9b4e-1e00e6000172",
"domainpath": "/",
"enddate": "2025-10-10T09:59:59+0000",
"offeringid": "b528eb0d-0efd-4df7-bffe-f0db170ac2e1",
"rawusage": "0.062222",
"size": 3221225472,
"startdate": "2025-10-10T09:00:00+0000",
"tags": [],
"usage": "0.062222 Hrs",
"usageid": "2c218702-abff-46e8-bc8a-3e12fffa2188",
"usagetype": 6,
"virtualmachineid": "ca3309cd-15e7-4718-9b33-d2c3af12ecd8",
"zoneid": "1f5131c0-cb48-4dc4-bb7c-33f8a0de2ec9"
},
{
"account": "admin",
"accountid": "f709bdb4-a4f1-11f0-9b4e-1e00e6000172",
"description": "Volume usage for DATA02
(2c218702-abff-46e8-bc8a-3e12fffa2188) with disk offering Custom
(b528eb0d-0efd-4df7-bffe-f0db170ac2e1) and size (3.00 GB) 3221225472",
"domain": "ROOT",
"domainid": "9f57bbb6-a4f1-11f0-9b4e-1e00e6000172",
"domainpath": "/",
"enddate": "2025-10-10T09:59:59+0000",
"offeringid": "b528eb0d-0efd-4df7-bffe-f0db170ac2e1",
"rawusage": "1",
"size": 3221225472,
"startdate": "2025-10-10T09:00:00+0000",
"tags": [],
"usage": "1 Hrs",
"usageid": "2c218702-abff-46e8-bc8a-3e12fffa2188",
"usagetype": 6,
"zoneid": "1f5131c0-cb48-4dc4-bb7c-33f8a0de2ec9"
},
{
"account": "admin",
"accountid": "f709bdb4-a4f1-11f0-9b4e-1e00e6000172",
"description": "Volume usage for DATA02
(2c218702-abff-46e8-bc8a-3e12fffa2188) with disk offering Custom
(b528eb0d-0efd-4df7-bffe-f0db170ac2e1) and size (3.00 GB) 3221225472",
"domain": "ROOT",
"domainid": "9f57bbb6-a4f1-11f0-9b4e-1e00e6000172",
"domainpath": "/",
"enddate": "2025-10-10T10:59:59+0000",
"offeringid": "b528eb0d-0efd-4df7-bffe-f0db170ac2e1",
"rawusage": "1",
"size": 3221225472,
"startdate": "2025-10-10T10:00:00+0000",
"tags": [],
"usage": "1 Hrs",
"usageid": "2c218702-abff-46e8-bc8a-3e12fffa2188",
"usagetype": 6,
"zoneid": "1f5131c0-cb48-4dc4-bb7c-33f8a0de2ec9"
},
{
"account": "admin",
"accountid": "f709bdb4-a4f1-11f0-9b4e-1e00e6000172",
"description": "Volume usage for DATA02
(2c218702-abff-46e8-bc8a-3e12fffa2188) with disk offering Custom
(b528eb0d-0efd-4df7-bffe-f0db170ac2e1) and size (3.00 GB) 3221225472",
"domain": "ROOT",
"domainid": "9f57bbb6-a4f1-11f0-9b4e-1e00e6000172",
"domainpath": "/",
"enddate": "2025-10-10T11:59:59+0000",
"offeringid": "b528eb0d-0efd-4df7-bffe-f0db170ac2e1",
"rawusage": "1",
"size": 3221225472,
"startdate": "2025-10-10T11:00:00+0000",
"tags": [],
"usage": "1 Hrs",
"usageid": "2c218702-abff-46e8-bc8a-3e12fffa2188",
"usagetype": 6,
"zoneid": "1f5131c0-cb48-4dc4-bb7c-33f8a0de2ec9"
}
]
}
(cmk) 🐱 > list usagerecords startdate=2025-10-07 enddate=2025-10-10 type=6
usageid=6c766c5c-1ab8-4428-a3ba-4b9a17b84502
{
"count": 432,
"usagerecord": [
{
"account": "admin",
"accountid": "f709bdb4-a4f1-11f0-9b4e-1e00e6000172",
"description": "Volume usage for DATA04
(6c766c5c-1ab8-4428-a3ba-4b9a17b84502) attached to VM testvm02
(ca3309cd-15e7-4718-9b33-d2c3af12ecd8) with disk offering Custom
(b528eb0d-0efd-4df7-bffe-f0db170ac2e1) and size (1.00 GB) 1073741824",
"domain": "ROOT",
"domainid": "9f57bbb6-a4f1-11f0-9b4e-1e00e6000172",
"domainpath": "/",
"enddate": "2025-10-09T09:59:59+0000",
"offeringid": "b528eb0d-0efd-4df7-bffe-f0db170ac2e1",
"rawusage": "0.064722",
"size": 1073741824,
"startdate": "2025-10-09T09:00:00+0000",
"tags": [],
"usage": "0.064722 Hrs",
"usageid": "6c766c5c-1ab8-4428-a3ba-4b9a17b84502",
"usagetype": 6,
"virtualmachineid": "ca3309cd-15e7-4718-9b33-d2c3af12ecd8",
"zoneid": "1f5131c0-cb48-4dc4-bb7c-33f8a0de2ec9"
},
...
{
"account": "admin",
"accountid": "f709bdb4-a4f1-11f0-9b4e-1e00e6000172",
"description": "Volume usage for DATA04
(6c766c5c-1ab8-4428-a3ba-4b9a17b84502) with disk offering Custom
(b528eb0d-0efd-4df7-bffe-f0db170ac2e1) and size (1.00 GB) 1073741824",
"domain": "ROOT",
"domainid": "9f57bbb6-a4f1-11f0-9b4e-1e00e6000172",
"domainpath": "/",
"enddate": "2025-10-10T08:59:59+0000",
"offeringid": "b528eb0d-0efd-4df7-bffe-f0db170ac2e1",
"rawusage": "1",
"size": 1073741824,
"startdate": "2025-10-10T08:00:00+0000",
"tags": [],
"usage": "1 Hrs",
"usageid": "6c766c5c-1ab8-4428-a3ba-4b9a17b84502",
"usagetype": 6,
"zoneid": "1f5131c0-cb48-4dc4-bb7c-33f8a0de2ec9"
},
{
"account": "admin",
"accountid": "f709bdb4-a4f1-11f0-9b4e-1e00e6000172",
"description": "Volume usage for DATA04
(6c766c5c-1ab8-4428-a3ba-4b9a17b84502) attached to VM testvm01
(282033c0-18df-46cd-809a-470f1a38a800) with disk offering Custom
(b528eb0d-0efd-4df7-bffe-f0db170ac2e1) and size (1.00 GB) 1073741824",
"domain": "ROOT",
"domainid": "9f57bbb6-a4f1-11f0-9b4e-1e00e6000172",
"domainpath": "/",
"enddate": "2025-10-10T09:59:59+0000",
"offeringid": "b528eb0d-0efd-4df7-bffe-f0db170ac2e1",
"rawusage": "0.081111",
"size": 1073741824,
"startdate": "2025-10-10T09:00:00+0000",
"tags": [],
"usage": "0.081111 Hrs",
"usageid": "6c766c5c-1ab8-4428-a3ba-4b9a17b84502",
"usagetype": 6,
"virtualmachineid": "282033c0-18df-46cd-809a-470f1a38a800",
"zoneid": "1f5131c0-cb48-4dc4-bb7c-33f8a0de2ec9"
},
{
"account": "admin",
"accountid": "f709bdb4-a4f1-11f0-9b4e-1e00e6000172",
"description": "Volume usage for DATA04
(6c766c5c-1ab8-4428-a3ba-4b9a17b84502) with disk offering Custom
(b528eb0d-0efd-4df7-bffe-f0db170ac2e1) and size (1.00 GB) 1073741824",
"domain": "ROOT",
"domainid": "9f57bbb6-a4f1-11f0-9b4e-1e00e6000172",
"domainpath": "/",
"enddate": "2025-10-10T09:59:59+0000",
"offeringid": "b528eb0d-0efd-4df7-bffe-f0db170ac2e1",
"rawusage": "1",
"size": 1073741824,
"startdate": "2025-10-10T09:00:00+0000",
"tags": [],
"usage": "1 Hrs",
"usageid": "6c766c5c-1ab8-4428-a3ba-4b9a17b84502",
"usagetype": 6,
"zoneid": "1f5131c0-cb48-4dc4-bb7c-33f8a0de2ec9"
},
{
"account": "admin",
"accountid": "f709bdb4-a4f1-11f0-9b4e-1e00e6000172",
"description": "Volume usage for DATA04
(6c766c5c-1ab8-4428-a3ba-4b9a17b84502) with disk offering Custom
(b528eb0d-0efd-4df7-bffe-f0db170ac2e1) and size (1.00 GB) 1073741824",
"domain": "ROOT",
"domainid": "9f57bbb6-a4f1-11f0-9b4e-1e00e6000172",
"domainpath": "/",
"enddate": "2025-10-10T10:59:59+0000",
"offeringid": "b528eb0d-0efd-4df7-bffe-f0db170ac2e1",
"rawusage": "1",
"size": 1073741824,
"startdate": "2025-10-10T10:00:00+0000",
"tags": [],
"usage": "1 Hrs",
"usageid": "6c766c5c-1ab8-4428-a3ba-4b9a17b84502",
"usagetype": 6,
"zoneid": "1f5131c0-cb48-4dc4-bb7c-33f8a0de2ec9"
},
{
"account": "admin",
"accountid": "f709bdb4-a4f1-11f0-9b4e-1e00e6000172",
"description": "Volume usage for DATA04
(6c766c5c-1ab8-4428-a3ba-4b9a17b84502) with disk offering Custom
(b528eb0d-0efd-4df7-bffe-f0db170ac2e1) and size (1.00 GB) 1073741824",
"domain": "ROOT",
"domainid": "9f57bbb6-a4f1-11f0-9b4e-1e00e6000172",
"domainpath": "/",
"enddate": "2025-10-10T11:59:59+0000",
"offeringid": "b528eb0d-0efd-4df7-bffe-f0db170ac2e1",
"rawusage": "1",
"size": 1073741824,
"startdate": "2025-10-10T11:00:00+0000",
"tags": [],
"usage": "1 Hrs",
"usageid": "6c766c5c-1ab8-4428-a3ba-4b9a17b84502",
"usagetype": 6,
"zoneid": "1f5131c0-cb48-4dc4-bb7c-33f8a0de2ec9"
}
]
}
```
--
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]