Category: Splunk

  • Operating a Splunk Environment with Multiple Deployment Servers

    Operating a Splunk Environment with Multiple Deployment Servers

    Operating a Splunk Environment with Multiple Deployment Servers

    By: Eric Howell | Splunk Consultant

    Splunk Environments come in all shapes and sizes, from the small single-server installation managing all of your Splunk needs in one easily-managed box, to the multi-site, extra complex environments scaled out for huge amounts of data and all the bells and whistles to get in-depth visibility and reporting into a wide variety of circumstances as suits functionally any use case you can throw at Splunk. And, of course, everything in between.

    For those multi-site, or multi-homed environments, that many data centers require for any range of needs, managing your configurations begins to get complicated between the additional firewall rules, data management stipulations, and any other broad range of issues that might crop up.

    Thankfully, Splunk Enterprise allows for your administrative team, or Splunk professional services, to set up a Deployment Server to manage the configurations (bundled into apps) for all of the universal forwarders, so long as they’ve been set up as deployment clients. In a complicated environment, you may find that you need two deployment servers to manage the workload, for any number of reasons. Perhaps you are trying to keep uniform configuration management systems in multiple environments, or perhaps you are aiming to spread the communication load across multiple servers for these deployments. Whatever the use case, setting up two (or more) deployment servers is not the heartache you may be worried about, and the guide below should be ample to get you on the right track.

    Multiple Deployment Servers – Appropriate Setup

    To set up multiple deployment servers in an environment, you will need to designate one of the Deployment Servers as the “Master” or “Parent” server (DS1). This is likely to be the original deployment server that houses all of the necessary apps, and is likely already serving as deployment server to your environment.

    The use case below will allow you to service a multi-site environment where each environment requires the same pool of apps, but is small enough to be serviced by a single deployment server.

    1. Stand up a new box (or repurpose a decommissioned server, as is your prerogative)! Install Splunk on this new server. This will act as your second deployment server (DS2).
    2. The key difference between these servers is that DS2 will actually be a client of the DS1.
    3. Initial set up is minimal, but make sure that this server has any standard configurations the rest of your environment holds, such as an outputs.conf to send its internal logs to the indexer layer, if you are leveraging that functionality.
    • You will create a deployment client app on DS2. You could use a copy of a similar app that resides on one of your heavy forwarders that poll DS1 for configuration management, but you will need to make two key adjustments in deploymentclient.conf:
    Screenshot of configuration changes showing repository and policy updates in a code block.

    • Once this change has been made, the apps that will be pulled down from DS1 will reside in the appropriate location on DS2 to be deployed out to any servers that poll it.
    • Restart Splunk on DS2
    • Next, you will need to navigate to the ForwarderManagement UI on DS1 and create a Server Class for your Slave or ChildDeployment Servers (DS2 in this case)
    • Add all apps to this new server class
      • Allowing Splunk to restart with these apps isfine, as changes made to the originating Deployment Server (DS1) will allow DS2
        to recognize that the apps that it holds have been updated and are ready for
        deployment.
    • Add DS2 to this Server Class
    • Depending on the settings you have configured indeploymentclient.conf on DS2 for its polling period (phoneHomeIntervalInSecs
      attribute), and how many apps there are for it to pull down from DS1, wait an appropriate amount of time (longer than your polling period, and more) and
      verify if the apps have all been deployed.
    • After this, updates made to the apps on DS1 will propagate down to DS2.

    Alternative Use Case

    If you are planning to leverage multiple deployment servers to service the same group of servers/forwarders, you will want to also copy over the serverclass.conf from DS1. If all server classes have been created through the web ui, the file should be available here:

    $SPLUNK_HOME/etc/system/local/serverclass.conf

    If this is your intended use case, you will also want to work with your Network Team to place the Deployment Servers behind a loadbalancer. If you do so, you’ll need to modify the following attribute in deploymentclient.conf in your deployment client app that resides on your forwarders to indicate the VLAN:

    Example configuration block showing how to define the target URI for a deployment server.

    You will also need to make sure both Deployment Servers generate the same “checksums” so that servers polling in and reaching different DS servers do not redownload the full list of apps with each check-in.

    To do so, you will need to modify serverclass.conf on both Deployment Servers to include the following attribute:

    Code block with a setting enabling crossServerChecksum and a note that the default is false.

    This attribute may not be listed by default, so you may need to include it manually. This can be included with the other attributes in your [global] stanza.

    Want to learn more about operating a Splunk environment with multiple deployment servers? Contact us today!

  • Email Routing Using Sendemail in Splunk Enterprise Security

    Email Routing Using Sendemail in Splunk Enterprise Security

    Email Routing Using Sendemail in Splunk Enterprise Security

    By: Bruce Johnson | Practice Lead, Operational Intelligence

    This was the use case scenario: Something went bump in the night. We needed to be able to send alerts from correlation searches to the security guards after hours and on weekends for a few specific correlation searches. Certain categories of activity (e.g, access violations, creating a new account, getting deleted, getting locked out, clearing security or system logs, using service accounts, etc.) needed to alert the after-hours team.

    Now there are plenty of tools that do this very effectively (VictorOps among them). We needed something simple and, in Splunk, it really couldn’t be simpler.

    The brute force method would have been to create correlation searches that run after hours and send to different email aliases. In other words, you have a different schedule to run a correlation search because you want that correlation search to route to different people, so create a duplicate search with different schedule settings. I suppose this would have been appropriate if the after-hours search had different levels of severity because of the timing, in which case I would have definitely taken that approach, but that was not the case. There is also no way to use cron to do conditionals. So I couldn’t  do a single secondary search that would run on both after hours on weekdays and all hours on weekends (e.g. <*/15 0,1,2,3,4,5,6,19,20,21,22,23 * * 1-5> OR <*/5 * * * 6-7>). Practically speaking that would mean three different correlation searches – untenable for Splunkers like me that are aspirationally lazy (not very successful yet but someday).

    What we needed was a means to determine whether a search result was run after hours or on weekends and set a flag. Then use a lookup to return the emails that we would route to and pass that as a parameter to the email action set up in the correlation search. This was just so much simpler than I thought it would be.

    The lookup (mail_recipients.csv) for routing purposes at its simplest level:

    email after_hours
    [email protected] 1
    [email protected] 0
    [email protected] 1

    I added other columns for userid, escalation level, cc, bcc and some fields that we might anticipate using should our routing need to be more complex, but for now we focused simply on the “after hours” use case. By The Way – the Sendresults app makes sending emails to a column dead simple but our use case was so basic, it really wasn’t needed. If you want to play with it: https://splunkbase.splunk.com/app/1794/

    Here’s the search – formatted to use _internal instead of CIM or wineventlog for testing purposes. The sendemail is included for testing as well. All we want to do in the format of the correlation search is to set the routing to $result.recipients$ in the To field. This may not work if you have no errors in your environment (insert appropriate emoji).

    Splunk search script that identifies error logs after business hours and sends automated emails using a recipient lookup.

    In the final version I pulled out the code between the evals and the recipient creation and put it in a macro (stripping all the fields I used except for recipients. Then inserted the macro into every correlation search that needed the routing.

    Search macro configuration in Splunk showing a script to detect after-hours events and identify email recipients for alerts.

    The eventual correlation searches just needed to insert the macro, ensure that the recipients field was in the final result, and change the routing on the email action to go to $result.recipients$ – simple but useful.

    Screenshot of Splunk’s adaptive response action configuration screen showing an email alert setup with tokens for recipients and alert names.

    The eventual search looked similar to this…

    Splunk dashboard displaying search results of locked user account events, including time, actor, target, and email recipients.
    Splunk dashboard showing search results for replication service errors, listing host details, destination IP, and error messages.

    Next up: Modify the search to use data models and to actually use the max hour for the search so that if the search results that come back have a mix of times that cross the current hour boundary, the most conservative path is chosen.

    Want to learn more about email routing in Splunk Enterprise Security? Contact us today! 

    [pardot-form id=”17645″ title=”Blog – Bruce Johnson – Email Routing Using Sendemail in Splunk Enterprise Security”]

  • Using Splunk to Monitor USB Removable Storage Devices

    Using Splunk to Monitor USB Removable Storage Devices

    By: Pete Chen | Splunk Practice Team Lead

     

    Windows Event Log Monitoring

    Abstract

    Information security is only as effective as physical security policies. Splunk continues to be a valuable tool in providing insight into risk and threat detection. As more security operation centers (SOC’s) look to limit sensitive data being exposed, USB removable storage devices (thumb drives, external hard drives, cell phones with high capacity storage, and SD cards) introduce risk. These devices are helpful in providing a backup location for important documents and files. They can help in moving data from one system to another. They can also be used to steal data, or move them into an unsecured location. Using Splunk, a security team can now monitor when these devices are plugged into systems.

    Using Windows

    Windows information on USB devices can be found here:

    Information on USB devices in Windows needs to be enabled before moving forward. The current default in administrative policy is to have this feature disabled. Enabling this feature will require administrative access to Windows.

    Test Procedures

    Devices
    By default, the Windows logging option for operations is disabled. This means there is no historical data to draw upon. Once operational logging is enabled, it’s important to generate data by plugging in different devices. Record the time a device was plugged in, when the device was stopped via software, and when the device was physically removed.

    Time – InsertTime – StopTime – RemoveDevice
    10:20am10:23am10:24amGeneric USB Drive
    10:29am10:30am10:31amKingston Micro SD Card
    10:33am10:36am10:37amSeagate USB External Drive
    10:45am10:52am10:53amWestern Digital External Hard Drive Micro USB

    Different devices should produce different results, especially when vendor ID and device ID is recorded. A list of USB ID’s can be found here:
    https://www.linux-usb.org/usb.ids

    Adding Data to Splunk

    Perform a series of tests (inserting and removing USB devices), and generate a log full of events to be exported. While it’s possible to ingest the data through the Splunk Add-On for Windows, doing so without the add-on will require exporting the log as a text file, where the fields were separated by Tab.
    In Splunk, add the data using the UI. Select Add Data, and the Upload.

    Screenshot of Splunk’s “Add Data” interface showing three main options: upload, monitor and forward, each represented by green icons.

    Based on how the data was exported from Windows, select the following sourcetype:

    Structure >> TSV (Tab-Separated Value)

    Splunk interface showing the source type dropdown menu with categories like Application, Database, Email, Network & Security and Structured data formats like CSV and JSON.

    Create a new index, such as “wineventlog”, to group the events and make searching easier.

    Event ID

    Identifying Microsoft’s Event ID’s is one of the requirements in identifying when a USB device has been inserted. This helps to better refine a search for qualifying events, eliminating non-useful events from the group. A search was used in Splunk to count the number of event id’s seen in the logs.

    The values of the event ID’s are:

    1000Startup of the driver manager service. The Driver Manager service started successfully
    1003Creation of a new driver host process. The Driver Manager service is starting a host process for device (Device){GUID}.
    1004Creation of a new driver host process. The host process ({GUID}) started successfully.
    1006Shutdown of a driver host process. The host process ({GUID}) is being asked to shutdown.
    1008Shutdown of a driver host process. The host process ({GUID}) has been shutdown.
    2000Startup of a new driver host process. The UMDF Host Process ({GUID}) is starting up.
    2001Startup of a new driver host process. The UMDF Host Process ({GUID}) started successfully.
    2003Loading drivers to control a newly discovered device. The UMDF Host Process ({GUID}) has been asked to load drivers for device (Device).
    2004Loading drivers to control a newly discovered device. The UMDF Host is loading driver WUDFUsbccidDriver at level 0 for device (Device).
    2005Loading drivers to control a newly discovered device. The UMDF Host Process ({GUID}) has loaded module C:windowsSystem32USER32.dll while loading drivers for device (Device).
    2006Loading drivers to control a newly discovered device. The UMDF Host successfully loaded the driver at level 0.
    2010Loading drivers to control a newly discovered device. The UMDF Host Process ({GUID}) has successfully loaded drivers for device (Device).
    2100Pnp or Power Management operation to a particular device. Received a Pnp or Power operation (RequestMajorCode, RequestMinorCode) for device (Device).
    2101Pnp or Power Management operation to a particular device. Completed a Pnp or Power operation (RequestMajorCode, RequestMinorCode) for device (Device) with status 0x0.
    2102Pnp or Power Management operation to a particular device. Forwarded a finished Pnp or Power operation (RequestMajorCode, RequestMinorCode) to the lower driver for device (Device) with status 0x0.
    2105Pnp or Power Management operation to a particular device. Forwarded a Pnp or Power operation (RequestMajorCode, RequestMinorCode) for device (Device) to the lower driver with status 0xC00000BB
    2106Pnp or Power Management operation to a particular device. Received a Pnp or Power operation (RequestMajorCode, RequestMinorCode) for device (Device) which was completed by the lower drivers with status 0x0
    2900Shutdown of a driver host process. The UMDF Host ({GUID}) has been asked to shutdown.
    2901Shutdown of a driver host process. The UMDF Host ({GUID}) has shutdown.

    *Value labels represented inside < >, actual events will have specific values in place.

    In reviewing the events, we concluded Event ID’s 1003, 2003, and 2102 provided the best group of events to identify when a device is inserted and removed, without being overly verbose. If Event Filtering is available prior to being ingested into Splunk, these events would be the most valuable. From what we have seen, 1003 seems to capture USB Removable Drives, but will not capture mobile devices. In addition, 2003 seems to capture MTP devices.

    Splunk

    The Search
    Ultimately, the data with corresponding Event ID’s were used to formulate a search which would return relevant information about when a USB device was inserted or removed.

    Block of search query code written for Splunk using index filtering, renaming fields, regular expressions and eval statements to categorize device events.

    Line Notes

    Table listing Splunk query line numbers alongside notes that explain the purpose of each line, including filtering logs, creating fields and transforming time formats.

    The Results

    Search results table in Splunk showing columns like date_time, host, event_id, action, device and Vendor_id to track device connection events across a system.

    Future Consideration

    In the search, important fields are pulled out which are not heavily used in the search above. GUID, Vendor ID, Product ID, device names can all be used to further elaborate on devices specifics, and correlate these events with other actions. The process GUID may be linked to a different process, potentially one which reveals actions taken from or to the removable USB device. It’s worth exploring further, and getting a more detailed analysis on USB Mass Storage Devices.

    Want to learn more about using Splunk to monitor USB removable storage devices? Contact us today!

    [pardot-form id=”17340″ title=”Blog – Pete Chen – Using Splunk to Monitor USB Removable Storage Devices”]

  • Machine Learning with Splunk: Fitting a Model

    Machine Learning with Splunk: Fitting a Model

    What is machine learning? A quick search online will return definitions using the words algorithm, statistics and model. A slightly less technical definition would be that machine learning is a general term used for formulas to determine outcomes based on features from provided data. If the goal was to classify plants, for example, height, petal color and environment might all be features in the data set.

    The objective for today will be to learn how to fit a model using Splunk’s Machine Learning Toolkit.  We will be using data from the passenger list of the Titanic to fit a model to predict who survived. The data set can be found at https://www.kaggle.com/c/titanic/data. The training set is what will be used to build and validate our model.

    The data set contains the features passenger ID (PassengerId), passenger class (Pclass), the name of the passenger (Name), the sex of the passenger (Sex), the age of the passenger (Age), the number of siblings and spouses on board with the passenger (SibSp), the number of parents on board with the passenger (Parch), the passenger’s ticket number (Ticket), the amount of the passenger’s fare (Fare), the passengers cabin number (Cabin), and the port the passenger embarked from (Embarked). The training set also has the additional feature of Survived.

    Spreadsheet showing Titanic passenger data with columns for PassengerId, Name, Age, Sex, Fare, and other details.

    Now that the data has been gathered the first step is to clean the data or in other words to make the data as complete and useful as possible. Not all features are useful; a good first step is to remove features that have no predictive value. It is better to leave features than to remove them before determining the predictive capabilities, but features that always have a unique entry such as ticket and name can be removed. (PassengerId will remain as the identifier for each entry.) There are a couple of options with Cabin; it can either be removed or turned into a binary feature. In this case the binary would be zero (0) for no cabin and a one (1) if a cabin is listed. For simplicity this feature will be removed as well due to a lack of information.

    The next step involves dealing with data that is not complete but too important to remove. The age feature is not complete but due to “women and children first” age will most likely be a strong predictor in who survives. One option is to remove all entries missing the feature. While not a majority of the entries, a significant number are missing age and removing them may impact the predictive capabilities of other features.

    A better option would be to insert a value that has little to no effect on the age feature and allows for the predictive potential from the other features to be used in the model. Setting an age too low will imply the passenger is a child; setting it too high may not be accurate either. The best option is to fill the blanks with the average age of all the passenger given. This should minimize any effects filling the blanks will have and allow the entries to remain in the data set. The average age for the data set is just under 30. Since age is counted in whole numbers the blank ages will be replaced with 30.

    Partial view of Titanic dataset in Excel with selected columns including Age, Sex, Pclass, and Fare.

    Now that the data has been cleaned it is time to begin using Splunk to build our model! Load the train.csv file into Splunk (it won’t have a timestamp so don’t worry about that) and then click on the Machine Learning Toolkit app. Once inside the app go to experiments and click on create new experiment and select predict categorical fields (since survivor is a category with only two possible values of one (1) or zero (0)). Name the experiment anything you like.

    Splunk Machine Learning Toolkit logo featuring a brain inside an orange square.

    In the search field enter “source=train.csv”. The results should be 891 events. Select “logistic regression” for Algorithm, “survived” in field to predict, and set the split for training/test to 80/20. The split will allow for 80 percent of the data to be used to fit the model and 20 percent to be used to validate the model. The split is randomized from the 891 entries of the entire data set.

    Splunk search bar showing query for source equals train.csv with 891 events loaded.

    The final step in building this model is feature selection. Begin by selecting all the features except passengerId in the fields to use for predicting as shown below.

    Splunk feature selection dropdown showing checked options like Age, Embarked, Fare, and Pclass.

    Depending on how the 80/20 split is done your results will vary but most likely it will be somewhere around 75 percent.  75 percent is better than what is expecting from guessing (50 percent), but the model can be improved. Unselect Embarked from the fields to use for predicting and fit the model again. The model should now be in the high 70’s to low 80’s.  The terms precision and recall measure the accuracy of the model. Precision is the percentage of returned values that were accurate and recall is the percentage of accurate values that were returned. In this scenario precision and recall are the same.  In the experiment history previous setting can be loaded and earlier models can be fit again allowing for several variations of the same model without needing different experiments.

    Splunk machine learning evaluation metrics showing Precision, Recall, Accuracy, and F1 score, all at 0.84

    The Splunk Machine Learning Toolkit is a powerful toolkit with the potential to take your data to the next step from descriptive to predictive. The Machine Learning Toolkit, however, is just that – a tool. Loading data into the MLT or knowing Splunk are not enough.  Understanding how to clean and wrangle data to have the most predictive impact is necessary as well.

    Want to learn more about machine learning with Splunk? Contact us today!

    [pardot-form id=”16985″ title=”Blog – Abe Hardy – Machine Learning with Splunk: Fitting a Model”]

  • New Feature in Splunk to Monitor Environment Health

    New Feature in Splunk to Monitor Environment Health

    A new feature introduced in Splunk 7.2 is the Splunkd Health Status Report. Monitoring Splunk’s status by checking if Splunkd is running may tell you if Splunk is running, but it won’t tell you if there’s a problem developing while Splunk is running. In the latest version of Splunk, you’ll only need to look next to your name to figure out how Splunk is doing.

    Splunk Enterprise homepage showing icons for product tours, data inputs and documentation.

    Once you click on the icon, a screen will pop up with the health status of Splunk.

    Health status explanation screen in Splunk with descriptions of green, yellow, gray and red indicators.

    The status tree is broken down into 4 areas, Splunkd, Feature Categories, Features, and Indicators.

    SplunkdThe overall status of Splunkd is based on the least healthy component in the tree. The status is for the specific host only.
    Feature CategoriesThis is the second stage, and represents a logical grouping of features. Feature categories won’t have a status.
    FeatureEach feature status is based on one or more indicators, with the least healthy indicator status as the status for the particular feature.
    IndicatorsIndicators are the lowest levels of measurable health status that are tracked by each feature. The colors for status change as health for each feature changes.

    In the event more details are required, the health report also generates a log, and can be found at: SPLUNK_HOME/splunk/var/log/splunk/health.log

    Here’s a sample of the log:

    Splunk system configuration screen showing navigation options for data, knowledge and monitoring.

    Changing notification settings can be found in the Settings menu. From Settings, select Health report manager.

    Splunk navigation interface showing administrative options like Add Data and Monitoring Console, with categorized links under Knowledge, Data, System, Distributed Environment, and Users and Authentication.

    From there, each feature can be enabled or disabled, and the thresholds set.

    Table listing Splunk system features with toggle buttons to enable or disable status thresholds.

    As with other functions and features in Splunk, settings for health monitoring can be changed through a conf file. This is located in $SPLUNK_HOME/etc/system/local/health.conf. Alerting thresholds, intervals, and seriousness can all be defined in the configuration file. A tremendous benefit to being able to configure the health monitoring is the ability to add alerts. When an alert fires, it can send a notification via email or PagerDuty. To enable this feature, simply add the following stanza to health.conf:

    [alert_action:email]

    disabled = 0

    action.to =  <[email protected]>

    action.cc = <[email protected]>

    action.bcc = <[email protected]>

    And finally, the health monitoring feature can be used by other monitoring tools. Using a curl command, other tools can help to better monitor your Splunk environment. The curl command is:

    curl -k -u admin:pass https://<host>:8089/services/server/health/splunkd

    When things go wrong, it may be difficult to determine where to begin troubleshooting. The monitoring tool helps by proving a root cause, and the last 50 related messages. This will help the admin better asses the problem and remediate it.

    Health Status of Splunk screen displaying a data durability error with detailed log messages.

    Splunk health monitoring is a simple, effective tool to help keep a Splunk environment healthy. Adding features, tuning indicators, adjusting intervals, and setting

    alerts are all ways this new tool pre-loaded into Splunk can help ensure Splunk is healthy.

    Want to learn more about Splunkd Health Status Report? Contact us today!

    [pardot-form id=”16923″ title=”Blog – Pete Chen – New Feature in Splunk to Monitor Environment Health”]

  • Version Source Control for your Splunk Environment

    Version Source Control for your Splunk Environment

    When Splunk environments grow in organizations, the need for source control also grows with it. It is good practice to use the widely available source control tools that are available for enterprise level source control. There are many Version Source Control (VCS) software available online, but the one most widely used is the open source, Git, which has proven to be a very powerful tool for distributed source control. Using Git, multiple Splunk Admins can work with their local repositories and the changes shared separately. To take the conversation further, I would separate the need for version control in two major segments
    • User Applications
    • Administrative Applications
    I have broken down the applications into two segments to enable ease of management for Splunk Admins. The User Applications should consist of the search artifacts that are built and developed as use cases evolve and change often, whereas the Administrative applications I would classify as those which are mostly used to deploy setup Splunk like TAs and other deployment apps. These applications rarely change once set up unless new data sources are on-boarded, there are significant changes to the architecture, etc. In the context of this blog post, we will focus on the administrative applications. These apps are the backbone on your Splunk deployment and should be cautiously changed to make sure there is no downtime in the environment. Changing these files could cause irreparable damage to the way data is indexed to Splunk, causing loss to indexed events, especially when changing sourcetypes, etc. As I already mentioned, there are numerous flavors of source control and depending on your taste, you can use either. If you’re starting off fresh with source control, Git is easy to set-up and you can use it with Github or Atlassian Bitbucket. Both these tools can help you get started in a matter of minutes, where you can create repositories and setup source control for your distributed Splunk environment. The Git server will host all the master repos in the Splunk Environment for all the administrative apps. The admins who need make edits do it in the following two ways;
    • Edit the master directly.
    • Create local clones of the master, make the required edits, commit them to the local branch and then push it out to the remote repo.
    Ideally, no one should edit the master branch directly to reduce the risk of unwanted changes to the master files. All admins should edit in local branches, and then once the edits are approved, they should be merged to the master. There should be three Master repos with their respective apps and TAs in those repos. These repos should correspond to the following servers;
    • Cluster Master for Indexers
    • Deployer for Search Head Cluster
    • Deployment Server for Forwarders
    To deploy the repos to the servers, you can use git hooks or tie your git deployment back into your puppet or chef environment. This is based on your discretion and how you are comfortable with distributed deployment in your organization. The repos should be deployed to the following directories
    • Cluster Master to $SPLUNK_HOME/etc/master-apps/
    • Deployer to $SPLUNK_HOME/etc/shcluster/apps
    • Deployment Server to $SPLUNK_HOME/etc/deployment-apps
    After the updated repos are deployed to the respective directories, you can push them out to the client nodes using Splunk commands. If you are interested in more information, please reach out to us and someone will get in touch with you and discuss options on how TekStream can help you manage your Splunk environment. [pardot-form id=”16859″ title=”Blog- Zubair Rauf – Version Source Control for your Splunk Environment”]
  • Optimizing Splunk Dashboards with Post-Process Searches

    Optimizing Splunk Dashboards with Post-Process Searches

    Optimizing Splunk Dashboards with Post-process Searches

    When creating Splunk dashboards, we often have the same search run multiple times showing different types of graphs or with slight variations (i.e. one graph showing “allowed” and another showing “blocked”). This creates more overhead every time the dashboard is opened or refreshed, causing the dashboard to open or populate more slowly and increasing the demand on the Splunk infrastructure. There are other situations or limitations that occur such as user concurrent-search limits.

    With proper optimization techniques a full typical dashboard with 10 panels can run less than three Splunk queries versus the 10 individual searches that would normally run. This is accomplished by using Post-process searches that are easily added in the SimpleXML of the desired dashboard.

    Starting Point of Post-process Searches

    When running a search in Splunk it will return RAW event data or transformed event data. Transformed event data is data that was returned by a search and is placed in the form of statistical tables which is used as the basis for visualizations. The primary transforming commands are:

    • Chart
    • Timechart
    • Top
    • Rare
    • Stats

    The Post-process search is known and referred to as a base search. The base search should always avoid returning RAW events and instead return transformed results. This is largely due to one of the limitation of Post-process being it can only return a max of 500,000 events and it will truncate without warning. To circumvent this limitation, it is best practice to use one of the transforming commands and as always, refine your search as much as possible to reduce the number of results and reduce your search .

    The Documented Limitations of Post-Process Searches

    The documentation that is provided on Splunk Docs show a few limitations that you should consider before using the Post-process search:

    https://docs.splunk.com/Documentation/Splunk/6.2.5/Viz/Savedsearches#Post-process_searches
    • Chaining for multiple post-process searches is not currently supported for SimpleXML dashboards.
    • If the base search is a non-transforming search, the Splunk platform retains only the first 500,000 events returned. The post-process search does not process events in excess of this 500,000 event limit, silently ignoring them. This results in incomplete data for the post-process search. A transforming search as the base search helps avoid reaching the 500,000 event limitation.
    • If the post-processing operation takes too long, it can exceed Splunk Web client’s non-configurable timeout value of 30 seconds. This can result in a timeout due to an unresponsive splunkd daemon/service. This scenario typically happens when you use a non-transforming search as the base .

    Examples of the Basic Concepts

    Splunk Search with non-transforming commands returning RAW results:

    Splunk search bar with query filtering by sourcetype "pan:threat" and action "allowed".

    Splunk dashboard displaying multiple threat event logs with sourcetype pan:threat.

    Splunk Search with transforming command retuning transformed results:

    Splunk search bar showing a stats count query grouped by app, category, rule and other fields.

    Splunk query results in table format showing apps, categories, signatures and source IPs.

    Examples of Post-process

    There are many different ways to determine what should be the base search and what should be in each post-process search. One method is to create all of the queries for your dashboard first and then find the beginning commonality between the searches which will end up being your base search. Then the part that does not meet the commonality will then be the post-process searches. Keep in mind that if you have four Splunk queries and three have a commonality but the fourth is completely different, you can do the base search for the three common Splunk queries and the fourth will just run as a normal query.

    We will take the following 5 Splunk queries as our example for what we have determined to put into our new dashboard. If you just ran these in our dashboard it would run 5 almost identical queries taking up valuable search resources and user limits.

    sourcetype=”pan:threat” action=allowed | stats count by app
    sourcetype=”pan:threat” action=allowed | stats count by rule
    sourcetype=”pan:threat” action=allowed | stats count by category
    sourcetype=”pan:threat” action=allowed | stats count by signature
    sourcetype=”pan:threat” action=allowed | stats count, values(rule) as rule by dest_ip

    As we can easily see, the commonality of the 5 queries is going to be:

    sourcetype=”pan:threat” action=allowed |

    The issue with just taking that portion as your base search is that it will return RAW results. If we review the 5 queries, they are using 5 different fields which means our transforming base search should include all 5 fields.

    sourcetype=”pan:threat” action=allowed
    | stats count by app, category, rule, signature, dest_ip, src_ip

    If we continue our method of initially creating our dashboard with our 5 independent queries:

    Splunk Threat Dashboard with multiple panels showing app usage, rules, signatures, and destination IP data.

    Then we can switch to the XML source view of the dashboard and start making our base search and post-process searches. Below is how the dashboard’s XML looks before using any post-process searches.

    <

    <panel>

    <table>

    <title>Applications</title>

    <search>

    <query>sourcetype=”pan:threat” action=allowed | stats count by app</query>

    <earliest>-24h@h</earliest>

    <latest>now</latest>

    </search>

    <option name=”drilldown”>none</option>

    </table>

    </panel>

    <panel>

    <table>

    <title>Rule</title>

    <search>

    <query>sourcetype=”pan:threat” action=allowed | stats count by rule</query>

    <earliest>-24h@h</earliest>

    <latest>now</latest>

    </search>

    <option name=”drilldown”>none</option>

    </table>

    </panel>

    <panel>

    <table>

    <title>Catergory</title>

    <search>

    <query>sourcetype=”pan:threat” action=allowed | stats count by category</query>

    <earliest>-24h@h</earliest>

    <latest>now</latest>

    </search>

    <option name=”drilldown”>none</option>

    </table>

    </panel>

    </row>

    <row>

    <panel>

    <table>

    <title>Signature</title>

    <search>

    <query>sourcetype=”pan:threat” action=allowed | stats count by signature</query>

    <earliest>-24h@h</earliest>

    <latest>now</latest>

    </search>

    <option name=”drilldown”>none</option>

    </table>

    </panel>

    <panel>

    <table>

    <title>Rules by Destination IP</title>

    <search>

    <query>sourcetype=”pan:threat” action=allowed | stats count, values(rule) as rule by dest_ip</query>

    <earliest>-24h@h</earliest>

    <latest>now</latest>

    </search>

    <option name=”drilldown”>none</option>

    </table>

    </panel>

    </row>

    </dashboard>

    We will create our base search with the following:

    Base Searchsourcetype=”pan:threat” action=allowed
    | stats count by app, category, rule, signature, dest_ip, src_ip
    Post-process 1| stats sum(count) as count by app
    Post-process 2| stats sum(count) as count by rule
    Post-process 3| stats sum(count) as count by category
    Post-process 4| stats sum(count) as count by signature
    Post-process 5| stats sum(count) as count, values(rule) as rule by dest_ip

    Once in the XML Source view, create your base search at the top, under the label but before the first row:

    XML code snippet showing base search setup for a Splunk dashboard panel.

    The base search id can be named anything (in this case it is “baseSearch”) but it is best to make it something easy because you will need to use it throughout the dashboard. The base search id is referenced in each post-process search which appends the base search in front of each post-process search. To create the base search, the id is placed inside of the search tags at the top of the dashboard before all of the panels.
    <search id=”{id name}”>

    The id name must be in double quotes “” and the name is case sensitive. Next, the transforming base search query is added inside of the open and closed query tags
    <query> {insert query here} </query>

    After the query tags, any other supported tags can be used such as the timeframe tags including tokens created and assigned in the dashboard. Then close the search tag.
    </search>

    Next we will add the post-process searches to each of the panels on the dashboard. The time references should be removed since the base search controls the timeframe:

    XML code snippet for a Splunk panel titled "Applications" with a post-process search query.

    Similarly to the base search, the post-process search uses the base search id in the search tags.
    <search base=”{id name of base search}”>

    Next would be the query tags where the post-process search goes. This query should start with a pipe “|” because it will be appended to the base search like it was all one query.
    <query> “ {post-process search that start with a pipe “|” } </query>

    After the query tags, any other supported tags can be used except the timeframe tags since the post-process searches go off the timeframe of the base search. Then close the search tag.
    </search>

    After modifying all 5 of the post-process searches in the XML source, the dashboard will be ready to use the base search. If you run the dashboard and look at the current searches, there will only be 1 search compared to 5 searches. Below is how the dashboard’s XML looks after making the changes.

    <dashboard>

    <label>Threat Dashboard</label>

    <!– Base Search Called “baseSearch” (This can be named anything) –>

    <search id=”baseSearch”>

    <query>sourcetype=”pan:threat” action=allowed | stats count by app, category, rule, signature, dest_ip, src_ip</query>

    <earliest>-24h@h</earliest>

    <latest>now</latest>

    </search>

    <row>

    <panel>

    <table>

    <title>Applications</title>

    <!– post-process search 1 –>

    <search base=”baseSearch”>

    <query>| stats sum(count) as count by app</query>

    </search>

    <option name=”drilldown”>none</option>

    </table>

    </panel>

    <panel>

    <table>

    <title>Rule</title>

    <!– post-process search 2 –>

    <search base=”baseSearch”>

    <query>| stats sum(count) as count by rule</query>

    </search>

    <option name=”drilldown”>none</option>

    </table>

    </panel>

    <panel>

    <table>

    <title>Catergory</title>

    <!– post-process search 3 –>

    <search base=”baseSearch”>

    <query>| stats sum(count) as count by category</query>

    </search>

    <option name=”drilldown”>none</option>

    </table>

    </panel>

    </row>

    <row>

    <panel>

    <table>

    <title>Signature</title>

    <!– post-process search 4 –>

    <search base=”baseSearch”>

    <query>| stats sum(count) as count by signature</query>

    </search>

    <option name=”drilldown”>none</option>

    </table>

    </panel>

    <panel>

    <table>

    <title>Rules by Destination IP</title>

    <!– post-process search 5 –>

    <search base=”baseSearch”>

    <query>| stats sum(count) as count, values(rule) as rule by dest_ip</query>

    </search>

    <option name=”drilldown”>none</option>

    </table>

    </panel>

    </row>

    </dashboard>

    The use of post-process searches in dashboards might not always work if there are no common queries. In the situations where there is commonality, then post-process searches should be used. This is not only to reduce the work load that each query requires but it reduces the likeliness off users reaching their search limits especially if the dashboard has a large number of common panels.

    Want to learn more about optimizing Splunk dashboards? Contact us today!

    [pardot-form id=”16215″ title=”Blog – Josh Grissom – Optimizing Splunk Dashboards with Post-process Searches”]

  • Step by Step Guide to Installing Splunk Insights for Infrastructure

    Step by Step Guide to Installing Splunk Insights for Infrastructure

     

    Step by Step Guide to Installing Splunk Insights for Infrastructure

    By: Pete Chen | Splunk Consultant

    Overview

    Since the release of Splunk Insights for Infrastructure, I’ve heard a few people tried to install it, and have had some challenges along the way. There are some pre-requisites before starting a successful installation, which will be covered in this blog. We’ll talk a little about what Insights for Infrastructure is, installing the home instance, and installing remote instances.

    Before we go any further, the environment I used in my installation consisted of:

    1 x Home Instance

    1 virtual CPU

    8 GB RAM

    128 GB HD

    1 x Remote Instance

    1 virtual CPU

    4 GB RAM

    80 GB HD

    Both servers are virtual, with Microsoft Hyper-V as the hypervisor. The OS used for the servers is CentOS 7 (x86_64). Using the .iso from CentOS, the servers are installed as bare minimum servers.

    What is Splunk Insights for Infrastructure?

    Splunk Insights for Infrastructure is a new product offering from Splunk, which aims to provide a faster and easier way to gain insight into collecting monitoring data from servers in a technical infrastructure. While traditional Splunk offers licenses based on daily ingestion rate, Splunk Insights for Infrastructure pricing is based on Storage (GB) per month. And if that wasn’t enough to get you excited, the first 200GB is FREE!

    At the present time, the only operating systems supported by Splunk Insights for Infrastructure are Red Hat Enterprise Linux 6 2.6.32+

    Splunk Insights for Infrastructure dashboard showing one host marked as available with a green status indicator and host ID 10.10.12.229.

    After logging in, this is the grid view of the entities being monitored. The blocks are color-coded based on health. The server being monitored in this example is healthy.

    Splunk infrastructure metrics dashboard displaying CPU and memory usage charts for host 10.10.12.229 with time-series performance graphs.

    Installing Splunk Insights for Infrastructure Base

    From a base installation of CentOS 7, this is a description of the steps needed to complete the task. Please keep in mind that this guide uses a .tgz installation (compared to rpm, deb, or, dmg). Using a different version of Linux may change the commands used below.

    Step-by-Step

    Step 1: Prepare the server for Splunk by disabling the firewall service. By default, firewalld is enabled, which may block access to port 22 (ssh), 8000 (web access), and 8089 (Splunk Admin Port). The first command listed in this step stops the firewall service. The second step turns the service off for future restarts.

    Step 2: SELinux is “Security-Enhanced” Linux. While this is helpful to secure a server, it interferes with the operations of Splunk Insights for Infrastructure. To disable this, use any text editor to change the SELinux configuration file. Change the value from “SELINUX=enforcing” to “SELINUX=disabled”.

    Step 3: Updating the server libraries and applications is never a bad idea. Installing updates can provide better security and add newer features and capabilities. This is not a required step.

    Step 4: WGET allows a server to download an application from the web. This will help in downloading the software on the base server. On the remote servers, using a script to install monitoring services will also require WGET.

    Step 5: EPEL stands for “Extra Packages for Enterprise Linux”. The additional packages don’t conflict with existing standard Linux packages, and can add more functionality to the server. CollectD is a package found in EPEL (and not in standard Enterprise Linux) and will be necessary to configure remote servers for monitoring. Since it’s helpful to monitor the performance of the base server as well, this should be installed.

    Step 6: CollectD is a background process which collects, transfers, and stores performance data of the server. This data is the foundation of Splunk Insights for Infrastructure and determines the health of a server. Once CollectD is installed, the data collected will be sent to the base server via Splunk Universal Forwarder.

    At this point, the prerequisite work is complete, and the server is ready to download and install Splunk Insights for Infrastructure.

    Step 7: Use WGET to download the installation tar file directly to the server. The alternative is downloading the software locally, then having to find a way to transfer the installation file to the server. Using WGET makes it much simpler.

    Step 8: To install Splunk, copy the installation file into the folder /opt. This will require root permissions. Once the file is copied, enter the command “tar -vxzf” followed by the file name. Tar is the application used to decompress the installation file. The subsequent letters also have value. V stands for Verbose. Z tells the application to decompress the file. X tells the application to extract the files. F tells the application a file name will be specified. Depending on how your Splunk user is set up, this may require root permissions.

    Step 9: This step is a precautionary step. Changing the ownership of the Splunk folder will ensure the Splunk user can run the software without permission concerns. The R makes the change recursive, so subordinate directories will also have their permissions changed. “splunk:splunk” changes the owner of folders to the user “splunk” (first), within the group “splunk” (second). This will need to be run as root.

    Step 10: This is the standard Splunk start command. The first time Splunk is run, there will be a requirement to read through and accept the software license agreement. To skip this and accept the license automatically, use “–accept-license”. This command assumes Splunk was installed in the /opt folder.

    Step 11: Servers can restart for many reasons. If an application is not configured to run on start, it will have to be manually restarted after the server is back online. Running the “enable boot-start” creates an init script, which is used to start Splunk as the server is starting up.

    Now, Splunk is set up, and should be accessible through a web browser by going to the site https://<hostname>:8000. When going to the URL, if a security certificate is not properly set (which it isn’t in this case), there will be a warning about the site not being secure. Advancing to the site is safe.

    Installing Splunk Insights for Infrastructure Remote

    Much like the installation of the base Insights for Infrastructure server, there are a few assumptions made in this document for the installation of remote services. This document will detail steps taken for a CentOS 7 server. The remote nature of the server simply means a different server, gathering its own metrics, and sending them to the base server for analysis. The prerequisite steps are the same as above.

    Step by Step

    Step 1: Prepare the server for Splunk by disabling the firewall service. By default, firewalld is enabled, which may block access to port 8089 (Splunk Admin Port). The first command listed in this step stops the firewall service. The second step turns the service off for future restarts.

    Step 2: SELinux is “Security-Enhanced” Linux. While this is helpful to secure a server, it interferes with the operations of Splunk Insights for Infrastructure. To disable this, use any text editor to change the SELinux configuration file. Change the value from “SELINUX=enforcing” to “SELINUX=disabled”.

    Step 3: Updating the server libraries and applications is never a bad idea. Installing updates can provide better security and add newer features and capabilities. This is not a required step.

    Step 4: WGET allows a server to download an application from the web. This will help in downloading the software on the remote servers, using a script to install monitoring services will also require WGET.

    Step 5: EPEL stands for “Extra Packages for Enterprise Linux”. The additional packages don’t conflict with existing standard Linux packages, and can add more functionality to the server. CollectD is a package found in EPEL (and not in standard Enterprise Linux) and will be necessary to configure remote servers for monitoring.

    Step 6: CollectD is a background process which collects, transfers, and stores performance data of the server. This data is the foundation of Insights for Infrastructure and determines the health of a server. Once CollectD is installed, the data collected will be sent to the base server via Splunk Universal Forwarder.

    Step 7: Run the installation script found in the configuration page of the Splunk Insights for Infrastructure base. In this document, the default script will be used. In a production environment, key-value pairs can be added for troubleshooting, analysis, and filtering hosts. This will need to be run as root on the remote server.

    Step 8: Once the script is run, a Collectd folder will be created in /opt. Browse to /opt/collectd/etc and modify collectd.conf. By default, core server metrics should be enabled.

    At this point, the remote server should start aggregating metrics into Collectd, and sent to the base server through Splunk Universal Forwarder. Within a few minutes, data should start to appear on Insights for Infrastructure.

    Splunk licensing dashboard displaying total storage usage, data indexed, ingestion by data type and unlimited data retention indicator.

    If you have questions or need further help installing SII, please contact us today: 

    [pardot-form id=”15664″ title=”Blog- Pete Chen – Step by Step Guide to Installing Splunk Insights for Infrastructure”]

  • TekStream Ready to Partner with Small Enterprises to Implement Splunk Insights for Infrastructure

    TekStream Ready to Partner with Small Enterprises to Implement Splunk Insights for Infrastructure

    TekStream is a Leading Implementation Provider for New Splunk Solution

        ATLANTA, GA, May 31, 2018 — TekStream Solutions, a dynamic Atlanta-based technology company specializing in digital transformation services and technical recruiting, today announced it is ready and available to partner with small enterprises to implement Splunk® Insights for Infrastructure, an analytics driven IT Operations tool for System Administrators and DevOps teams to collect, analyze, and monitor data from their on-premises, cloud or hybrid server infrastructures. TekStream is a Splunk professional services, reseller, and MSP partner with 100% of its team members being accredited Splunk architects; the company’s consultants hail from diverse backgrounds in operations, security, development, and consulting.

    Splunk Insights for Infrastructure is a single download designed for individual Infrastructure teams of SysAdmins and DevOps teams who are responsible for up to 1,000 on-premises, cloud or hybrid server infrastructures. The new software solution provides a seamless experience for infrastructure monitoring and troubleshooting. Splunk Insights for Infrastructure simplifies how system administrators and DevOps teams find and fix infrastructure performance problems, enabling them to automatically correlate metrics and logs to monitor their IT environments – in an easier-to-use, more interactive, and lower-cost package.

    “Our clients in the Commercial segment have different needs and, of course, smaller budgets, than large enterprises,” said Judd Robins, Executive Vice President of Sales at TekStream. “Splunk Insights for Infrastructure gives companies of any size a monitoring product they can get started with quickly, easily and for free. There is a lot of demand among our Commercial clients for a robust yet affordable monitoring solution to support their digital transformation efforts, and we are excited to be able to help them take advantage of it.”

    The smallest IT environments – up to approximately 50 servers, with 200GB in total storage – are charged no licensing fee for Splunk Insights for Infrastructure. The 200GB free tier includes Community support. For tiers greater than 200GB, Base support is included in the paid license price. Splunk’s Base support includes all major and minor software updates and customer support. If the company is growing and needs to move into larger infrastructure environments, they can easily upgrade to Splunk® Enterprise, the leading analytics platform for machine data.

    “TekStream offers a full array of Splunk services to companies that wish to implement Splunk Insights for Infrastructure,” said Robins. “As a Splunk partner, TekStream has the knowledge and experience to help companies every step of the way, from deciding which initial licensing option would be best for them, to implementation and training, to maintenance and support, to determining when it is time to upgrade. Our Splunk consultants also have experience and expertise integrating Splunk software with existing technologies to build a unique complementary solution. We are looking forward to helping businesses make the most of this innovative new Splunk solution and partnering with them as they grow with this use case and other use cases in the future.”

    You can download Splunk Insights for Infrastructure here.

    About TekStream
    We are “The Experts of Business & Digital Transformation,” but more importantly, we understand the challenges facing businesses and the myriad of technology choices and skillsets required in today’s “always on” companies and markets. We help you navigate the mix of transformative enterprise platforms, talent, and processes to create future-proof solutions in preparing for tomorrow’s opportunities – so you don’t have to. TekStream’s IT consulting solutions, combined with its specialized IT recruiting expertise, helps businesses increase efficiencies, streamline costs, and remain competitive in an extremely fast-changing market. For more information about TekStream, visit www.tekstream.com or email [email protected]

  • Data Onboarding in Splunk

    Data Onboarding in Splunk


    Data Onboarding in Splunk

    By: Joe Wohar | Splunk Consultant

    Splunk is an amazing platform for analyzing any and all data in your business, however you may not be getting the best performance out of Splunk if you’re using the default settings. To get the best performance out of Splunk when ingesting data, it is important to specify as many settings as possible in a file called “props.conf” (commonly referred to as “props”). Props set ingestion settings per data sourcetype and if you do not put anything into props for your sourcetype, Splunk will automatically try to figure it out for you. While this can be a good thing when you’re first beginning with Splunk, having Splunk figure out how to parse and ingest your data affects the overall performance of Splunk. By configuring the ingestion settings manually, Splunk doesn’t have to figure out how to ingest your data. These are the 8 settings that you should set for every sourcetype in order to get the best performance:

    SHOULD_LINEMERGE – As the name suggests, this settings determines whether lines from a data source file are merged or not. If your data source file contains 1 full event per line, set this to “false”; if your data source file contains multiple lines per event, set this to “true”. If you set this to “true” you’ll also need to use some other settings such as BREAK_ONLY_BEFORE or MUST_BREAK_AFTER to determine how to break the data up into events.

    LINE_BREAKER – This setting divides up the data coming in based on a regular expression defining the “breaks” in the data. By default, this setting looks for new lines, however if your events are all on the same line, you’ll need create a regular expression to divide the data into lines.

    TRUNCATE – TRUNCATE will split an event if it’s number of characters exceeds the value set. The default is 10000, it’s a good idea to lower this to better fit your data and it’s absolutely necessary to increase this if the events exceed 10000 characters.

    TIME_PREFIX – This setting takes a regular expression for what precedes the timestamp in events so that Splunk doesn’t have to search through the event for the timestamp.

    MAX_TIMESTAMP_LOOKAHEAD – This tells Splunk how far to check after the TIME_PREFIX for the full timestamp so that it doesn’t keep reading further into the event.

    TIME_FORMAT – Define a timestamp in strftime format. Without this defined, Splunk has to go through its list of predefined timestamp formats to determine which one should be used.

    EVENT_BREAKER – This setting should be set on the Splunk Forwarder installed on the host where the data originally resides. It takes a regular expression which defines the end of events so that only full events will be sent from the Splunk Forwarder to your indexers. EVENT_BREAKER_ENABLE – This setting merely tells Splunk to start using the EVENT_BREAKER setting. It defaults to false so if when you use EVENT_BREAKER, you’ll need to set this to “true”.

    There are many other settings which can be used but as long as you have these defined, Splunk will perform much better than if it has to figure them out on its own. For more information on these settings, visit Splunk’s documentation on props: https://docs.splunk.com/Documentation/Splunk/latest/Admin/Propsconf

    If you have questions, or would like more information on data onboarding best practices, please contact us: