Dashboards & Visualizations

Dynamic source selection based on search

systematics78
Loves-to-Learn

Hi.. I have in splunk logs comes from different sources.. and different events. For example, one type of events contains user information without server name:

Logged-in user {'kind': 'user', 'name': 'XXXXXX', 'admin': False, 'groups': [], 'server': '/jhub-test/user/XXXXXX/', 'pending': None, 'created': '2020-12-27T03:29:41.850432Z', 'last_activity': '2021-01-16T05:18:16.822564Z', 'servers': None}
 
and other have server ip on that..
 
So I need to construct query were I can select the source based on server ip search and after search the specific action - for example user logon events.
 
so I want to write some query like this:
if source=* contain ip address
when source="the actual source name which contain ip address"  |search "*Logged*"
Labels (1)
Tags (1)
0 Karma

to4kawa
Ultra Champion

Create a lookup and check it against the source.

0 Karma

systematics78
Loves-to-Learn

I just want to construct a table for example:

Environment                   User Activity               Username

DEV                                        Logged IN                       systematics78

 

And I have sources from this environment but exactly with the same configuration

For example from Dev Environment I have log file with several rows like this

I log:187 10.161.2.165  some info

I log:587 Logged-In systematics78

For sandbox environment

I log:187 10.161.1.175  some info

I log:587 Logged-In systematics78

The logs name generated randomly on daily basis.. So I have just one info - ip address - based on that I can decide that User activity is related with for example DEV or Sandbox environment

So the main guest ion How I can create such report

0 Karma

to4kawa
Ultra Champion
index=_internal | head 1 | fields _raw
| eval _raw="I log:187 10.161.2.165  some info I log:587 Logged-In systematics78
I log:187 10.161.1.175  some info  I log:587 Logged-In systematics78"
| multikv noheader=t
| rex "(?<ip>\d+\.\d+\.\d+\.\d+)"
| rex "(?<UserActivity>Logged\S+)\s*(?<Username>\S+)"
| table ip UserActivity Username
```
| lookup ipaddress as ip OUTPUT Environment
```
0 Karma

systematics78
Loves-to-Learn

Can I have more explanation what you exactly mean?

0 Karma

to4kawa
Ultra Champion

https://docs.splunk.com/Documentation/Splunk/8.1.1/SearchReference/Lookup

A field with a description and a field with an IP address would be fine, I guess.

0 Karma

systematics78
Loves-to-Learn

Actually the fields not the same.. for example

log[I 2021-01-20 10:50:14.071 JupyterHub log:174] 302 GET / -> /jhub-test/hub/ (@10.161.10.174) 1.30ms

log[I 2021-01-19 08:05:10.633 JupyterHub login:43] User logged out: systematics

 

This is from the same source - So based on first row I can decide that user logged off from app in QA environment..  

 

 

0 Karma

to4kawa
Ultra Champion

log[I 2021-01-20 10:50:14.071 JupyterHub log:174] 302 GET / -> /jhub-test/hub/ (@10.161.10.174) 1.30ms

log[I 2021-01-19 08:05:10.633 JupyterHub login:43] User logged out: systematics

 

It has good features. Pay attention here.

Also, I think it says ip in the source, so you can extract it from there.

0 Karma

systematics78
Loves-to-Learn

Yes.. I know it.. I'm not so good on Splunk side.. that why I'm asking.. As I told i have more that 100+ such files as a source - some of them from different environment.. And I need just create dashboard and visualize users activities regarding with the environment.. I can construct this tables on segregated source.

0 Karma

to4kawa
Ultra Champion

Splunk can create new fields with regular expressions, and there's nothing wrong with that.
Use rex as in my example.

0 Karma

to4kawa
Ultra Champion

Why don't you search and filter them all?

index=yours source=normal OR source=X.X.X.X "Logged"
| where match(source,"\d+\.\d+\.\d+\.\d+")

0 Karma

systematics78
Loves-to-Learn

I have source from multiply environments - for example SandBox, Dev, QA etc.. with exact same configuration and need to segregate by environment - so need to filter source by searching ip address to identify the source relationship with environment and after use just that source with some events..

0 Karma
Get Updates on the Splunk Community!

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Index This | What goes away as soon as you talk about it?

May 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...

What's New in Splunk Observability Cloud and Splunk AppDynamics - May 2025

This month, we’re delivering several new innovations in Splunk Observability Cloud and Splunk AppDynamics ...