Knowledge Management

How to range columns and rows ?

jw44250
New Member

I have the following result from Splunk Query using appCols because same logs always has different events with different message

message1 or message2 just a name..

Message Count1 Message2 count2
hello 5 hi 10

Output i am looking is :
Message count --< Header Fields>
hello 5

hi 10

Tags (3)
0 Karma

somesoni2
Revered Legend

Instead of appendcols, you should use just append. Also, remember to rename the fields in 2nd search (Message2 and count2) same as first search.

search 1 | table Message Count
| append [search 2 | table Message2 Count2 | rename Message2 as Message Count2 as Count ]

See this to know difference between append and appendcols.
https://answers.splunk.com/answers/144351/what-are-the-differences-between-append-appendpipe.html

0 Karma

jw44250
New Member

it is same index. but i have to extract different fields each time from events.. since the events returns has different message

0 Karma

jw44250
New Member

i using transport i didnt work ..

0 Karma

jw44250
New Member

Thanks it did work.

0 Karma

somesoni2
Revered Legend

Glad it's working for you. If it's same index, you probably don't need a subsearch. If you could share you search, we can look at it to see if both searches can be merged into one for better performance.

0 Karma

jw44250
New Member

Here is the Splunk Query..

index=index1 sourcetype=index1_log | rex field=_raw "(?exception\s\w+\s\w+)" |stats count by Message| table Message count | append
[search index=index2 sourcetype=index2_log | rex field=_raw "(?message\s\w+\s\w+)" |stats count as count1 by message| table message count1 |rename message as Message count1 as count] | rename count as "Hit Count"

0 Karma

somesoni2
Revered Legend

Give this a try

(index=index1 sourcetype=index1_log) OR (index=index2 sourcetype=index2_log) 
| rex field=_raw "(?<Message>(exception|message)\s\w+\s\w+)" 
|stats count as "Hit Count" by Message
0 Karma

jw44250
New Member

let me tried it..thanks

0 Karma

jw44250
New Member

When adding timechart span=3h count usenull=f useother=f into both indexes getting error :- please rename count columns.

0 Karma

somesoni2
Revered Legend

YOu're getting that in same query?

0 Karma
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!

All Work and No Play? Not at .conf26! Unwind at These Evening Events

Between hands-on technical sessions, keynote reveals, and diving into live architectures, .conf26 is packed ...

Join the Hackathon at .conf26 and build a No-Code AI agent

Join us for the AI Agent Buildathon, an in-person, three-hour hands-on Hackathon where you’ll use Splunk Agent ...

Level Up Your Workflow: Mastering Splunk Cloud Management via Terraform

Tech Talk Recap   From Chaos to Control: Scaling Splunk Cloud with Infrastructure as Code Managing apps in ...