Splunk Search

Convert data to hex with tostring inside chart

Voriaz
Engager

Hi,

Can we manipulate data with functions in a chart.
I have a chart table obtained with :

| chart count over user by date_wday

 

The result is the following :

usermondaythuesday
user13652
user228192
user3235492

 

Now  imagine that I want to convert the count field in hexadecimal with "tostring(count,"hex")".
How can I do ?

I already managed to do it with "foreach" statement but after that, I cannot use the Trellis view cause the chart command is not at the end of the search.

Thanks for yout help.

 

A.

Labels (2)
0 Karma
1 Solution

to4kawa
Ultra Champion

 

| makeresults
| eval _raw="user	monday	thuesday
user1	36	52
user2	28	192
user3	235	492"
| multikv forceheader=1
| table user	monday	thuesday
| untable user date_wday count
| eval count=mvrange(0,count)
| mvexpand count
| rename COMMENT as "this is your original sample. first, try chart. from here, the logic"
| stats count by user date_wday
| eval count = tostring(count,"hex")
| xyseries user date_wday count

 

try stats() ,eval and xyseries

| makeresults
| eval _raw="user	monday	thuesday
user1	36	52
user2	28	192
user3	235	492"
| multikv forceheader=1
| table user	monday	thuesday
| untable user date_wday count
| eval count=mvrange(0,count)
| mvexpand count
| rename COMMENT as "this is your original sample. from here, the logic"
| chart count over user by date_wday
| rename user as _user
| foreach * [ eval <<FIELD>> = tostring(<<FIELD>>,"hex")]
| rename _user as user

this is chart and foreach version.

 

View solution in original post

to4kawa
Ultra Champion

 

| makeresults
| eval _raw="user	monday	thuesday
user1	36	52
user2	28	192
user3	235	492"
| multikv forceheader=1
| table user	monday	thuesday
| untable user date_wday count
| eval count=mvrange(0,count)
| mvexpand count
| rename COMMENT as "this is your original sample. first, try chart. from here, the logic"
| stats count by user date_wday
| eval count = tostring(count,"hex")
| xyseries user date_wday count

 

try stats() ,eval and xyseries

| makeresults
| eval _raw="user	monday	thuesday
user1	36	52
user2	28	192
user3	235	492"
| multikv forceheader=1
| table user	monday	thuesday
| untable user date_wday count
| eval count=mvrange(0,count)
| mvexpand count
| rename COMMENT as "this is your original sample. from here, the logic"
| chart count over user by date_wday
| rename user as _user
| foreach * [ eval <<FIELD>> = tostring(<<FIELD>>,"hex")]
| rename _user as user

this is chart and foreach version.

 

Voriaz
Engager

Hello,

The first solution (with stats, eval and xyseries)  is working perfectly and is simpler.
I was not aware of the xyseries function.

For the second one, it is almost working as only the field "user" is available to trellis "splitBy" option ans this is not what I want.

But the first one is working, so thank you very much @to4kawa !

A.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

When I use foreach to convert the counts to hex the graph still displays the values in decimal.  And, yes, trellis format doesn't display correctly as I only see one day for each user.

---
If this reply helps you, Karma would be appreciated.
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 ...