Splunk Search

How can you format numbers in a ctable?

dpadams
Communicator

I've got a search like this against a collection of Web logs:

sourcetype="access_common" | ctable uri_path host

The result is a ctable with URLs down the left, a count column for each of our servers and a grand total column on the right.

How can you format the numbers that are in the cdata cells? (I've been having similar problems with summarizing over table results and xyseries results.) This fieldFormat statement does correctly format the grand total column:

sourcetype="access_common" | ctable uri_path host | fieldFormat TOTAL=tostring(TOTAL,"commas")

So far, I haven't figured out how to address the columns for each specific host. If I use the column name that Splunk produces, no error is generated but there's also no data. I'm guessing that the problem is that I don't know what the correct identifier for the column(s) that I'd like to format. Within the result data, I can see that there are definitions with "tag" elements for the various columns - but these ID values (c='6474' or c='327', etc.) are not stable. Each time you run the search, the IDs are generated from scratch.

Is there a way to address the generated columns in a ctable? For that matter, is there something that works with other, related sorts of extractions like xyseries?

Thanks a lot.

0 Karma

woodcock
Esteemed Legend

This works:

sourcetype="access_common" | ctable uri_path host | foreach * [eval <<FIELD>>=tostring(<<FIELD>>,"commas")]
0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...