Splunk Search

How do I divide data in a field by a certain value?

BobKimata
Path Finder

I have a search based on an SQL query e.g. select * from . I would like to divide some data displayed on a field called 'Cost' by 2 and display result on the same field. I only have one row of data.

Thanks

Tags (1)
0 Karma
1 Solution

Flynt
Splunk Employee
Splunk Employee

add |eval Cost=Cost/2 after your SQL search

View solution in original post

Flynt
Splunk Employee
Splunk Employee

add |eval Cost=Cost/2 after your SQL search

BobKimata
Path Finder

I did that but receive this error:
command="dbquery", A database error occurred: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '|eval Cost=Cost/2' at line 1.

The sql query works fine without the expression.

0 Karma

Flynt
Splunk Employee
Splunk Employee

Can you give the whole syntax for your search? The |eval Cost=Cost/2 is a Splunk function and would need to exist outside of any dbquery commands.

0 Karma

BobKimata
Path Finder

I got it working. I had forgotten to put the SQL query in quotes. Thanks

0 Karma

Flynt
Splunk Employee
Splunk Employee

Excellent! Please accept if the answer was helpful.

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 ...