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!

Shape the Future of Splunk: Join the Product Research Lab!

Join the Splunk Product Research Lab and connect with us in the Slack channel #product-research-lab to get ...

Auto-Injector for Everything Else: Making OpenTelemetry Truly Universal

You might have seen Splunk’s recent announcement about donating the OpenTelemetry Injector to the ...

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...