

If the value of from_domain matches the regular expression, the count is updated for each suffix.
#Splunk eval software
The eval eexpression uses the match() function to compare the from_domain to a regular expression that looks for the different suffixes in the domain. Splunk Eval Commands With Examples Rating: 5 21603 Splunk is a software that enables one to monitor, search, visualize and also to analyze machine generated data (best example are application logs, data from websites, database logs for a start) to big-data using a web styled interface.The stats count() function is used to count the results of the eval expression. The results are then piped into the stats command.The mvindex() function is used to set from_domain to the second value in the multivalue field accountname.The first value of accountname is everything before the symbol, and the second value is everything after. The split() function is used to break the mailfrom field into a multivalue field called accountname.The from_domain is defined as the portion of the mailfrom field after the symbol. The first part of this search uses the eval command to break up the email address in the mailfrom field.| eval from_domain=mvindex(accountname,-1) The eval command in this search contains two expressions, separated by a comma. For example, the email might be To, From, or Cc).įind out how much of the email in your organization comes from. You should be able to run this search on any email data by replacing the sourcetype=cisco:esa with the sourcetype value and the mailfrom field with email address field name in your data. Use eval expressions to categorize and count fields This example uses sample email data. The results appear on the Statistics tab and look something like this: The counts of both types of events are then separated by the web server, using the BY clause with the host field.The second clause does the same for POST events.Then, using the AS keyword, the field that represents these results is renamed GET. The first clause uses the count() function to count the Web access events that contain the method field value GET.This example uses eval expressions to specify the different field values for the stats command to count. Sourcetype=access_* | stats count(eval(method="GET")) AS GET, count(eval(method="POST")) AS POST BY host Run the following search to use the stats command to determine the number of different page requests, GET and POST, that occurred for each Web server. Use the time range All time when you run the search.
#Splunk eval download
To try this example on your own Splunk instance, you must download the sample data and follow the instructions to get the tutorial data into Splunk. Use eval expressions to count the different types of requests against each Web server This example uses the sample data from the Search Tutorial but should work with any format of Apache web access log. Status=* | stats dc(eval(if(status=404, clientip, NULL()))) AS dc_ip_errors Status=* | eval dc_ip_errors=if(status=404,clientip,NULL()) | stats dc(dc_ip_errors)Īs an alternative, you can embed an eval expression using eval functions in a stats function directly to return the same results. Then the stats function is used to count the distinct IP addresses. This is a shorthand method for creating a search without using the eval command separately from the stats command.įor example, the following search uses the eval command to filter for a specific error code. You can embed eval expressions and functions within any of the stats functions. However, the queries on the right side of the eval statements work as expected.Use stats with eval expressions and functions

| eval totalCount = domain1Count + domain2Count Search "Middleware 2" "| stats distinct_count(UserId) as domain2Users Search "Middleware" "| stats distinct_count(UserId) as domain1Users At this time, I have the following Simple XML: besides the file name it will also contain the path details. I need to get a) the number of users for each domain and b) the total users for use in the dashboard. LHSPLUNK, ususally source name is fully qualified path of your source i.e. I have a Splunk dashboard that shows traffic across two sites.
