Splunk Search

How do I use a stats sum and then divide by a field not used when summing?

riotto
Path Finder

I have events that have

tablespace, tablespace_size, table_owner, table_name, table_size

ie
WORK_TS 10000000 joe Joe_table1 1000
WORK_TS 10000000 joe Joe_table2 5000
WORK_TS 10000000 mary Mary_table1 3000
WORK_TS 10000000 mary Mary_table2 7000
PROD_TS 10000000 joe Joe_table3 1000
PROD_TS 10000000 joe Joe_table4 5000
PROD_TS 10000000 mary Mary_table3 3000
PROD_TS 10000000 mary Mary_table4 7000

I want to sum the total space used in a tablespace by the table_owner, tablespace and then divide that sum by the tablespace_size

index="oracle" source="oracle_tables" | stats sum(table_size) as owner_used_space by table_owner, tablespace

I get the sums but cannot divide by them by the tablespace_size

Tags (1)
0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Try like this

index="oracle" source="oracle_tables" | stats sum(table_size) as owner_used_space max(tablespace_size) as tablespace_size  by table_owner, tablespace | eval percent_owner_used_space=round(owner_used_space*100/tablespace_size,2)

View solution in original post

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Try like this

index="oracle" source="oracle_tables" | stats sum(table_size) as owner_used_space max(tablespace_size) as tablespace_size  by table_owner, tablespace | eval percent_owner_used_space=round(owner_used_space*100/tablespace_size,2)
0 Karma

riotto
Path Finder

seems so simple now....Works like a champ!

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...