Splunk Search

Keep numbers right-aligned after using fieldformat

mjosen
Engager

Hello,

I have a numeric field that I convert to a comma separated number using fieldformat. The only problem is that after the conversion it changes the format from right align to left align. Since this is a numeric field, is there anyway to keep the column right-aligned with commas? It's very difficult to compare numbers within a column when they are all left-aligned. Thanks.

lguinn2
Legend

In Splunk 6.5, you can format a table column in a dashboard. You can apply both numeric and color formatting. This is preferable to using the fieldformat command.

fieldformat never worked consistently (when combined with other commands) to display a formatted numeric value while preserving the underlying field as numeric.

Here is the documentation showing how to Format table visualizations.

0 Karma

jrodman
Splunk Employee
Splunk Employee

This is tricky, because the fields don't have any alignment, they're just strings in a conceptual table. However, the UI tries to make some guesses on how to display them based on their content.

Thus there's little in the search language that can control the UI behavior (unless we implement some kind of ui-hint-field which doesn't currently exist). Some more direct control in the UI would be nice, but that wouldn't persist cleanly in a search for all users. I think this boils down to an Enhancement Request.

0 Karma

cchange
Path Finder

Do we have any solution in v6.5 for this issue?

0 Karma

Flynt
Splunk Employee
Splunk Employee

How are you using fieldformat? Using the example below, it appears to right format in 6.5.0 when using tostring "commas".

|stats count|fields - count |eval number=10000  |fieldformat formattednumber=tostring(number,"commas")  
0 Karma

season88481
Contributor

Same problem here. We are using v6.4. And column became left-aligned after applying a fieldformat command.

0 Karma

niketn
Legend

@cchange and @season88481...Can you give example of query / mock data? It works fine for me in 6.4.3 as well as 6.5. Following is the run anywhere search I tested:

| makeresults
| eval TestNumber=12345678912345
| fieldformat TestNumber=tostring(TestNumber,"commas")
| table _time TestNumber
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

rettops
Path Finder

Did you ever find a solution to this? I'm looking for the same thing - some way to force the chart's text alignment to right align.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...