Dashboards & Visualizations

How to display string values containing numbers as strings?

Dominik
Explorer

I extract with rex a field that contains numeric values, often with leading zeros. I want to display the values as strings, left aligned without getting leading zeros truncated.

Example values: 00123, 22222, 12345_67

When showing these values in a dashboard table, the String values are interpreted as numbers, where possible, and I get

                                 123
                            22222
12345_67

Is there a way to get string values correctly displayed as such in a dashboard table?

I tried also the dirty way as proposed here, prefixing the strings with space or non-breaking-space, but it does not work (I'm on Splunk 9.0.4). It works when adding a visible char (e.g. "x"), but that makes the table unusable.

Labels (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @Dominik,

I'm delaying the use of Dashboard Studio as long as I can  just for this reason: it still has some issue.

Anyway, using my search have you the same issue?

Ciao.

Giuseppe

 

View solution in original post

Dominik
Explorer

Thank you @gcusello for the reply..

Probably my question was not precise enough. The data is ok and the sample produces exactly what I have, but Dashboard Studio seems to have a problem.

Using the data from above in a table widget as data source, I can reproduce the problem.

Dominik_0-1691157563500.png

leading zeros cut off and colums formatted differently per row.

Playing around with this, I found a completely wired feature of the table widget. With a greater Result set, switching pages, it looks like the widget 'thinks' about the data and  if the majority of lines cannot be misinterpreted as numbers, the whole page is correctly displayed as left-aligned strings. Otherwise the data ist misinterpreted as numbers and changed (leading zeros cut off)..  Setting the Column formatting to string does not change anything.

In my untersanding, this is everything else than correct behavior for a display widget. But I'm a complete Splunk newbie and not sure if this is worth a bug report. Can you confirm that  this is really bad?

 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Dominik,

I'm delaying the use of Dashboard Studio as long as I can  just for this reason: it still has some issue.

Anyway, using my search have you the same issue?

Ciao.

Giuseppe

 

Dominik
Explorer

I take "delaying the use of Dashboard Studio as long as I can" as good solution. 

Widgets that change data values are inacceptable. 😞

Worth a bug report?

0 Karma

Dominik
Explorer

Yes, as written above.  This is your example data. The data is perfect, the result fatal. 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Dominik,

using your data I didn't find any problem:

| makeresults
| eval _raw="00123, 22222, 12345_67"
| rex max_match=0 "(?<num>[^,\n]+)"
| mvexpand num
| eval num=tostring(trim(num))
| table num

could you share some full log sample to test the regex?

Ciao.

Giuseppe

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...