Splunk Search

tostring commas on a negative number

flora123
Path Finder

Hello ALL!

x=-241

eval final_x=tostring(x,"commas")

It shows [-,241], but it should be [-241].

How could I show the negative number correctly?

Thanks a lot. 😃

Tags (1)
1 Solution

bwooden
Splunk Employee
Splunk Employee

Interesting....It works as advertised when x=-1241 or x=-41 but not x=-241 or x=-111241.

I file this as a bug. In the mean time, you may use this temporary workaround:

eval final_x=replace(tostring(x, "commas"),"-,","-")

View solution in original post

bwooden
Splunk Employee
Splunk Employee

Interesting....It works as advertised when x=-1241 or x=-41 but not x=-241 or x=-111241.

I file this as a bug. In the mean time, you may use this temporary workaround:

eval final_x=replace(tostring(x, "commas"),"-,","-")

bwooden
Splunk Employee
Splunk Employee

Good news - This was reported and resolved last month in an upcoming release.

flora123
Path Finder

I found I think too much...replace is a good idea in this time.

Thanks again!

0 Karma

flora123
Path Finder

Oh... I get another trouble.
Because the x is a variable number... 😞
Anyway thank you very much.

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...