Splunk User Manual - v1.3
Splunk User Manual - v1.3
Splunk User Manual - v1.3
Searching MaxDB KnlMsg trace files............................................................................................... 18 Installing Splunk universal forwarder ............................................................................................. 22 8.1 8.2 Steps to install universal forwarder ........................................................................................ 22 Steps to configure forwarding and receving ........................................................................... 23
9.
Configuring email alerts .................................................................................................................. 26 9.1 9.2 9.3 Configuration .......................................................................................................................... 26 Few examples to show how email alerting works .................................................................. 27 Managing scheduled searches and reports ............................................................................ 31 Setting up roles and users ........................................................................................................... 36 Setting up roles: ...................................................................................................................... 36 Setting up users....................................................................................................................... 39 Field tagging ................................................................................................................................ 41 Search using field tags............................................................................................................. 42
17-Nov-11
Page 1
Author
Anandagouda Gubbi, Rajashekhar (C5153390)
17-Nov-11
Page 2
To see the logs and traces Search application is used. Launch the Search application either from Splunk Home tab or from Welcome tab as shown in above screenshots. We have created separate users as below for Basis colleagues, DB colleagues, OS colleagues so that by default they can view corresponding logs.
17-Nov-11
Page 3
Next steps explain how to use different search functionalities of Splunk to view logs from different hosts and sources. 2. Click on Search link and click on search button, it will display all the events splunk indexer has recorded from all hosts and all sources. As shown in below screenshot.
17-Nov-11
Page 4
In the above screenshot we can find various options to filter the indexed data: Search field: where you can enter custom search strings to filter the data. Time range: to view the data of particular time range, you can select different time range from the dropdown. Fields section: We can see hosts(monitored hosts), source(monitors/input data) Detailed steps on how to use these options will be discussed later in this document.
17-Nov-11
Page 5
Once the host is selected it will show all the data indexed from that host and you can see the selected host in search field.
4. Splunk Indexes
By default all the data consumed by splunk indexer is saved in default index called main. In Splunk we can create our own indexes and use them to push incoming data to specific index. In this setup we have created our own indexes named, erp, erp_maxdb, erp_webdisp, os_logs All the R/3 data coming from all hosts we are pushing into Index erp. All the database related logs/data is pushed into index erp_maxdb. Index os_logs is used for storing OS logs from all hosts. erp_webdisp is used for web dispatcher related logs. While searching we can make use of the index name to filter data. For example below screenshot shows erp index is being selected.
17-Nov-11
Page 6
Note: It will display matching terms as you type the search string.
To view the top10 sources, click on source link. And click on source you want to see the detailed data. Find the below screenshot.
17-Nov-11
Page 7
After selecting any source from above step you will see the data related to this source.
17-Nov-11
Page 8
17-Nov-11
Page 9
By default it will show only data from erp index as shown in below image, so that no need to specify index name in search string.
17-Nov-11
Page 10
17-Nov-11
Page 11
Click on Show Source to view the logfile, it will display the logfile in separate window as shown in below screenshot.
17-Nov-11
Page 12
Similarly to view /usr/sap/ixv/dvebmgs00/work/available.log logs use the below search string. host="spwdfvml0247" source="*available.log*" OR host="spwdfvml0247" source=/usr/sap/ixv/dvebmgs00/work/available.log
6.2 Database logs: We are saving all maxdb logs into index erp_maxdb and have created separate user to view these logs by default, with this user no need to mention index name in search string. Login to splunk using username/password as maxdbuser/splunk After logging in it will take you to Search page directly. There select any host as shown below.
17-Nov-11
Page 13
17-Nov-11
Page 14
6.3
We are saving all web dispatcher logs into index erp_webdisp and have created separate user to view these logs by default, with this user no need to mention index name in search string. Login to splunk using username/password as webdispuser/splunk After logging in it will take you to Search page directly. There select any host as shown below.
17-Nov-11
Page 15
To search for web dispatcher available log use the below string. host="spwdfvml0063" source="/usr/sap/IXP/W00/work/available.log"
17-Nov-11
Page 16
Similarly we can search all the files that are configured to monitor with their paths or just by giving wildcard search (*) and with specific time range filters can also be applied as already explained in above section. 6.4 OS logs: Splunk can index all OS logs from different systems (windows, Linux, Unix..etc) We are saving all OS logs into index os_logs and have created separate user to view these logs by default, with this user no need to mention index name in search string. Login to splunk using username/password as oslogsuser/splunk After logging in it will take you to Search page directly. There select any host as shown below.
17-Nov-11
Page 17
Similarly we can search for any OS logs just by giving host name and any file path or wild search, below are few examples. host="spwdfvml0247" source="/var/log/warn" host="spwdfvml0247" error
17-Nov-11
Page 18
In the above screenshot you can find the results in tabular format, which is easily readable. This will list the fields (columns) that are already selected which are shown on the left hand side of the above screen. If we need further fields to be added in the result table we can click on Pick Fields and select the fields of interest as shown below. Just select the field and it will be added in the selected field. Then we can click on search button again to display the results in tabular format.
17-Nov-11
Page 19
There is another option to view the results in tabular format using .. | table field1, field2 command. Use the search host="spwdfvml0249" source=*KnlMsg
17-Nov-11
Page 20
And then refine the search by using search string host="spwdfvml0249" source=*KnlMsg |table TIME,TEXT where TIME and TABLE are field names which you can see on the left side. which will display the results in table as below.
In the above search string we can use * which will display all the fields/columns host="spwdfvml0249" source=*KnlMsg |table *
17-Nov-11
Page 21
8.1
Download the universal forwarder from http://www.splunk.com/download/universalforwarder Depending on the OS flavour where we want to install. To install in Linux systems we downloaded rpm package. In Linux systems run the below command to install the Splunk RPM in the default directory /opt/splunk: rpm -i splunk_package_name.rpm To install on windows download the corresponding software from same location and install via GUI. 1) Starting and stopping universal forwarder Go to splunk home directory as shown below
17-Nov-11
Page 22
8.2
To set up forwarding and receiving, you need to perform two basic actions, in this order: Set up one or more Splunk indexers as receivers. These will receive the data from the forwarders. Set up one or more Splunk forwarders. These will forward data to the receivers.
Use Splunk Web to enable receiving on the indexer designated as receivers. Open Splunk GUI and then click on Manager and then select Forwarding and receiving.
17-Nov-11
Page 23
17-Nov-11
Page 24
From this configuration forwarder will understand to which receiver system it should forward the data. Next step is what all data needs to be sent or we need to define what all files needs to be monitored. This will be configured in 3 ways: using splunk web, Command Line interface(CLI) or edit inputs.conf file.
In above screenshot OS log monitor (/var/log/messages) will be added. To push this data to specific index for example os_logs index we have to edit and mention the index name in file /opt/splunkforwarder/etc/apps/search/local/inputs.conf as shown below.
Note: If the data needs to be pushed to a specific index, do the restart only after adding index name by editing the monitor in inputs.conf file. Else the data will be saved in default main index.
Adding monitors by editing inputs.conf file: Navigate to inputs.conf file in the path /opt/splunkforwarder/etc/apps/search/local
17-Nov-11
Page 25
Below is the monitors added in this inputs.conf and after that restart the splunk forwarder.
If we want to add any new monitor, this file needs to be modified with new monitors.
9.1
Configuration
Go to Manager, click on system settings--> Email alert settings and under Mail server settings Enter the mail host which is SMTP mail server as shown in below screenshots, in our case its mailwdf.sap.corp and other fields are optional and leave it as default.
17-Nov-11
Page 26
9.2
Below search displays os_logs of host spwdfvml0249 for last 15 minutes time.
Enter the below string in search field. host="spwdfvml0249" | sendemail to=rajashekhar.anandagouda.gubbi@sap.com sendresults=true format=html server=mailwdf.sap.corp
17-Nov-11
Page 27
Optional parameters in above search string are format which will send the mail in desired format depending on need we can have format=html, format=text, or format=raw etc. Note: We have to mention our SMTP server name using the parameter server=mailserver.sap.corp Because by default splunk will assume splunk host as mailserver host and it tries to send mails which will not work. So we have to explicitly specify the mail server host.
With this sendemail functionality if some logs related to OS or DB or R/3 logs need to be send to responsible teams or an individual mailID, this can be achieved easily without logging into servers, which will reduce manual effort. Below is the mail which is received in our mailbox.
There is other option to send an alert which is described below. For example lets search with the string host="spwdfvml0249" db_offline for time range last 60 min
17-Nov-11
Page 28
Click on Create alert as shown in the above screenshot. And then enter the fields as shown below Search name, Search string (modify if required) and click on Next
In Next screen select the condition and schedule this search to run every 5 min and if there is any event in past 5 min it will trigger an alert mail.
If you enable throttling and mention number of minutes as 60 min, it will make sure that if the events are occurring every 5 min it will not trigger the alert mail every 5 min, only after 60 min it will trigger the the
17-Nov-11
Page 29
alert mail. And time range selected as last 60 min will get data of the last 60 min only so that it will prevent sending of the alerts for same event. Expiration time determines how long Splunk keeps a record of your triggered alerts. Severity can be set it Info,Low,Medium,High,Critical. As shown in the below screenshot.
Click on Next Enable Send email and then enter mail ID of the admins who should receive the alert mail. Include search results as inline to get as text in mail or select csv/pdf to get as attachment in mail. Enable tracking this will enable the trigger alerts to be viewed in Splunk Alert Manager and click on Finish as shown below.
17-Nov-11
Page 30
Now this search will run every 5 minutes automatically and will trigger alert mail only if there are any events retrieved for db_offline in last 60 min.
9.3
Scheduled search what we have created in previous section can be managed by using Searches & Reports->Manage Searches & Results as shown below.
17-Nov-11
Page 31
Here you can see the scheduled search IXV_db_offline we have created in last step.
From the above screenshot you can select View recent which will show the recent run details of this scheduled search as shown below.The search can be run by Clicking on Run or it can be disabled or deleted completely. Alerts that have been triggered can be seen by selecting Alerts on top right corner as shown below which will display the alerts that have been triggered so far.
Here you can view the results /edit search /you can delete the alert.
17-Nov-11
Page 32
10.3
Deployment Monitor will show Index Throughput, Forwarder Connections, Indexer Warnings, Forwarder Warnings etc.. In section Forwarder Warnings you can see Missing Forwarders link as shown below. In that Click on Configure Alerting.
17-Nov-11
Page 33
17-Nov-11
Page 34
17-Nov-11
Page 35
10.
10.2 Setting up roles: Login to splunk indexer using admin user(admin/tbntbitq). Goto Manager->Access Control and click on Roles ->Click on New Give name of the role as role_erp. Below screenshots shows the steps.
As role_erp is already created, below screenshots shows the properties of the same.
17-Nov-11
Page 36
17-Nov-11
Page 37
Similarly other roles have been created with the same properties as above. Click on any one of the roles highlighted in below screenshot to see its properties.
17-Nov-11
Page 38
Login to splunk indexer using admin user(admin/tbntbitq). Goto Manager->Access Control and click on Users ->Click on New Give name of the user as erpuser. Assign the role created(role_erp) in above step(section 10.1) to this user. Also set the initial password for this user. Below screenshots shows the steps.
As erpuser is already created, below screenshot just shows the properties and roles assigned to it
17-Nov-11
Page 39
Similarly we have created other users maxdbuser,webdispuser,oslogsuser Click on any of these users to view its properties as shown in the below screenshot.
17-Nov-11
Page 40
11.
Field tagging
In splunk we can tag fields for example host, source etc.. We have done host tagging to group the hosts belonging to particular landscape and SID. Below screenshots shows how to do tagging. Give the hostname in search string which will display the results, click on the down arrow next to host and click on Tag host as shown below
Then enter the tag names. We can enter multiple tags separated by comma as shown below. Here we have used tags LS_IXP and IXP LS: Stands for landscape, IXP: is SID of the SAP instance on this host.
For spwdfvml0247(host of IX4) we have used tags, LS_IXP and IX4 Similarly we have used tags for all IX* hosts.
17-Nov-11
Page 41
SPLUNK USER Manual 1.3 11.1 Search using field tags Now we can search using the tags created in previous section. Enter search string as index=erp tag::host=IX4. It will display the hosts tagged to IX4 which is only one host as shown in below screenshot.
Similarly use the search string as index=erp tag::host=LS_IXP, this will display all the hosts of IXP landscape.
17-Nov-11
Page 42