Splunk Search

Error in 'EvalCommand': Type checking failed. '-' only takes numbers.

shimada-k
Explorer

Hi all,

I want to find the difference between two values (values.in65To127OctetFrames).

My data is like below.

{"name":"ethernet_counter","timestamp":1717838243109,"tags":{"interface_name":"Ethernet48","source":"sri-devgrp-prert00","subscription-name":"ethernet_counter"},"values":{"in65To127OctetFrames":2922198453881}}

{"name":"ethernet_counter","timestamp":1717837943109,"tags":{"interface_name":"Ethernet48","source":"sri-devgrp-prert00","subscription-name":"ethernet_counter"},"values":{"in65To127OctetFrames":2922102453899}}

{"name":"ethernet_counter","timestamp":1717837643345,"tags":{"interface_name":"Ethernet48","source":"sri-devgrp-prert00","subscription-name":"ethernet_counter"},"values":{"in65To127OctetFrames":2922006507704}}

I tried the following SPL, but I received "Error in 'EvalCommand': Type checking failed. '-' only takes numbers.".

index=gnmi name=ethernet_counter tags.source=sri-devgrp-prert00 earliest=06/08/2024:08:00:00 latest=06/08/2024:09:22:00
| sort _time
| streamstats current=f last(values.in65To127OctetFrames) as previous_value by tags.interface_name
| eval value_diff = values.in65To127OctetFrames - previous_value
| table _time tags.interface_name value_diff

I am very new to splunk. Could someone help me to write a proper SPL?

Many thanks,

Kenji

Labels (1)
Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Try putting the field name in single quotes so Splunk knows it's a field and not something else.

index=gnmi name=ethernet_counter tags.source=sri-devgrp-prert00 earliest=06/08/2024:08:00:00 latest=06/08/2024:09:22:00
| sort _time
| streamstats current=f last(values.in65To127OctetFrames) as previous_value by tags.interface_name
| eval value_diff = 'values.in65To127OctetFrames' - previous_value
| table _time tags.interface_name value_diff
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Try putting the field name in single quotes so Splunk knows it's a field and not something else.

index=gnmi name=ethernet_counter tags.source=sri-devgrp-prert00 earliest=06/08/2024:08:00:00 latest=06/08/2024:09:22:00
| sort _time
| streamstats current=f last(values.in65To127OctetFrames) as previous_value by tags.interface_name
| eval value_diff = 'values.in65To127OctetFrames' - previous_value
| table _time tags.interface_name value_diff
---
If this reply helps you, Karma would be appreciated.

shimada-k
Explorer

Hi richgalloway,

Thanks a lot for you prompt response! It works.

Many thanks,

Kenji

Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...