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!

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