You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[receiver/oracledb] Fix incorrect values for a couple of metrics (#32028)
**Description:**
Values were being scraped incorrectly for the metrics
`oracledb.tablespace_size.limit` and `oracledb.tablespace_size.usage`.
The changes these metrics to be scraped from the
[`DBA_TABLESPACE_USAGE_METRICS`](https://docs.oracle.com/en/database/oracle/oracle-database/19/refrn/DBA_TABLESPACE_USAGE_METRICS.html#GUID-FE479528-BB37-4B55-92CF-9EC19EDF4F46)
table. This results in a slight loss of granularity in these metrics, as
values will always be in multiples of the respective tablespace's block
size, but I think the clarity and simplicity is worth the trade off.
Note: The value of the usage metric was generally close to the expected
value, but the limit was being calculated as potential theoretical
capacity, unbound by server capacity. For example, in testing in a
docker container on my local machine, limit was set to **17TB**. This
doesn't line up with user expectations.
**Link to tracking Issue:**
Fixes#31451
**Testing:**
Updated existing tests, added a couple new ones.
Also, the original issue filed was comparing
`DBA_TABLESPACE_USAGE_METRICS` output for percent used to what we got
from `usage/limit * 100`. Here's the local testing outputs compared to
show they now line up.
```
2024-03-27T16:31:57.938-0700 info oracledbreceiver/scraper.go:285 DBA_TABLESPACE_USAGE_METRICS: Tablespace name: SYSTEM, used space: 111288, tablespace size: 3518587, percent used: 3.16286054600895188892586711654422641816 {"kind": "receiver", "name": "oracledb", "data_type": "metrics"}
```
```
Metric #20
Descriptor:
-> Name: oracledb.tablespace_size.usage
-> Description: Used tablespace in bytes.
-> Unit: By
-> DataType: Gauge
NumberDataPoints #0
Data point attributes:
-> tablespace_name: Str(SYSTEM)
StartTimestamp: 2024-03-27 23:31:56.873576 +0000 UTC
Timestamp: 2024-03-27 23:32:12.523295 +0000 UTC
Value: 911671296
```
```
Metric #19
Descriptor:
-> Name: oracledb.tablespace_size.limit
-> Description: Maximum size of tablespace in bytes, -1 if unlimited.
-> Unit: By
-> DataType: Gauge
NumberDataPoints #0
Data point attributes:
-> tablespace_name: Str(SYSTEM)
StartTimestamp: 2024-03-27 23:31:56.873576 +0000 UTC
Timestamp: 2024-03-27 23:32:12.523295 +0000 UTC
Value: 28824264704
```
Doing the same calculation, we get:
```
(911671296 / 28824264704) * 100 = ~3.16%
```
Copy file name to clipboardExpand all lines: receiver/oracledbreceiver/scraper.go
+33-25Lines changed: 33 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -38,8 +38,10 @@ const (
38
38
consistentGets="consistent gets"
39
39
sessionCountSQL="select status, type, count(*) as VALUE FROM v$session GROUP BY status, type"
40
40
systemResourceLimitsSQL="select RESOURCE_NAME, CURRENT_UTILIZATION, LIMIT_VALUE, CASE WHEN TRIM(INITIAL_ALLOCATION) LIKE 'UNLIMITED' THEN '-1' ELSE TRIM(INITIAL_ALLOCATION) END as INITIAL_ALLOCATION, CASE WHEN TRIM(LIMIT_VALUE) LIKE 'UNLIMITED' THEN '-1' ELSE TRIM(LIMIT_VALUE) END as LIMIT_VALUE from v$resource_limit"
41
-
tablespaceUsageSQL="select TABLESPACE_NAME, BYTES from DBA_DATA_FILES"
42
-
tablespaceMaxSpaceSQL="select TABLESPACE_NAME, (BLOCK_SIZE*MAX_EXTENTS) AS VALUE FROM DBA_TABLESPACES"
0 commit comments