Splunk Search

How to combine chart count for two fields in one search

monipinni
Explorer

Hi,

Can any one help me adding two fields in one search I am seeing both fields in splunk selected fields but not seeing new field in Search result.

Query : Basic Search AND body.response.failedUpcName=* OR body.failedUpcName=* | chart count by body.response.failedUpcName , body.failedUpcName

Old Field Name : body.response.failedUpcName     
New Field Name : body.failedUpcName

How to get results for both Fields ?

0 Karma

arjunpkishore5
Motivator

Try this,


Basic Search AND body.response.failedUpcName=* OR body.failedUpcName=*
| rename body.response.failedUpcName as response_failedUpcName, body.failedUpcName as failedUpcName
| chart count by response_failedUpcName , failedUpcName

Not sure on the exact reason for this, however reporting commands don't seem to be able to handle nested fields very well.

If your goal is to get the fields separately


Basic Search AND body.response.failedUpcName=* OR body.failedUpcName=*
| rename body.response.failedUpcName as response_failedUpcName, body.failedUpcName as failedUpcName
|fields response_failedUpcName, failedUpcName
| chart count(*) as *

If your goal is to get count based on one or the other based on what is available

Basic Search AND body.response.failedUpcName=* OR body.failedUpcName=*
| rename body.response.failedUpcName as response_failedUpcName, body.failedUpcName as failedUpcName
| eval failedUpcName = coalesce(response_failedUpcName, failedUpcName)
| chart count by failedUpcName

0 Karma

jkat54
SplunkTrust
SplunkTrust

Does it work if you replace chart with this stats example?

 | stats count(field1) count(field2)
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...