Splunk Search

How to get employee name in chart?

kumasaua
Explorer

Dear All,

I have one employee master csv that have employee name, departmentname, projectname.
If the employee is the group head then in project , it mention Group head, otherwise it mentions project name
like:

Name      DeptName       ProjectName
saurabh  softwaredept  skyject
gaurav     softwaredept  GroupHead
manish    rnd                    hrmanagement
rekesh     rnd                    GroupHead

I want to show data like Deptname , Name of the grophead of this dept, No of employees.

Result like:

softwaredept  gaurav   2
rnd                    rakesh   2

Requesting you to please provide query for this requirement.

0 Karma
1 Solution

niketn
Legend

@kumasaua, please try the following using eventstats

 <yourCurrentSearch>
| eventstats count by DeptName
| search ProjectName=GroupHead
| table DeptName count

Following is a run anywhere search based on the sample data provided:

| makeresults
| eval data="saurabh softwaredept skyject;gaurav softwaredept GroupHead;manish rnd hrmanagement;rekesh rnd GroupHead"
| makemv data delim=";"
| mvexpand data
| makemv data delim=" "
| eval Name=mvindex(data,0),DeptName=mvindex(data,1),ProjectName=mvindex(data,2)
| table Name DeptName ProjectName
| eventstats count by DeptName
| search ProjectName=GroupHead
| table DeptName count
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

harishalipaka
Motivator

@niketnilay answer will work or you can try with small change in count by like .

| eventstats count by ProjectName| search ProjectName=GroupHead
 | table DeptName Name count
Thanks
Harish
0 Karma

kumasaua
Explorer

Thank you.. it works..

0 Karma

niketn
Legend

@kumasaua, please try the following using eventstats

 <yourCurrentSearch>
| eventstats count by DeptName
| search ProjectName=GroupHead
| table DeptName count

Following is a run anywhere search based on the sample data provided:

| makeresults
| eval data="saurabh softwaredept skyject;gaurav softwaredept GroupHead;manish rnd hrmanagement;rekesh rnd GroupHead"
| makemv data delim=";"
| mvexpand data
| makemv data delim=" "
| eval Name=mvindex(data,0),DeptName=mvindex(data,1),ProjectName=mvindex(data,2)
| table Name DeptName ProjectName
| eventstats count by DeptName
| search ProjectName=GroupHead
| table DeptName count
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

kumasaua
Explorer

Dear Niketnilay,

When i use first query then it show result like
Departname count but i want to show Group name also like
Departname Groupheadname count.

Can you help me for this.

0 Karma

kumasaua
Explorer

Thank you , now it works.

Get Updates on the Splunk Community!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...