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!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...