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
Revered Legend

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
Revered Legend

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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...