Tag: Splunk

  • Not Enough Space? Rotate Through Your Dashboard Panels Automatically

    Not Enough Space? Rotate Through Your Dashboard Panels Automatically

    By Marvin Martinez, Team Lead, Security Operations

    Splunk dashboards allow for great flexibility and can provide many ways to visualize your data. Sometimes, however, you may need to ensure you can fit everything on one non-scrollable screen. Perhaps you’re in a SOC with a main screen and need some different panes to display at specific intervals? What if you need to cycle through a set of data between different time ranges like the last 24 hrs, 7 days, and 30 days? In these situations, it would be very helpful to be able to have a dashboard that automatically rotates the desired panels on specific time intervals, not unlike a fast food menu screen or those digital billboards you frequently see on the interstate!

    In the example we’ll use for this article, I’ll demonstrate how to configure a dashboard to display an Attack Map in two separate ways. The first view will contain a full screen attack map with all of the different sources in one single map to provide a comprehensive view. The second view is a broken out set of panels that shows each individual source/group in its own panel with a dedicated attack map for added detail. The Missile Map app that contains this attack map visualization used below can be found on Splunkbase.

    View 1

    Cybersecurity attack map showing global data flows and threat origins in a single interactive panel.

    View 2

    Rotated Splunk dashboard displaying four grouped attack maps with segmented threat visualization panels.

    These two views will cycle automatically based on a specified time interval defined within a global search in your dashboard. There are a few tokens to ensure you set up correctly but, once set up as needed, your dashboard will cycle through the two configured views (sets of panels) on its own for use in any monitor on a wall or other constantly monitored screen.

    The snippet of dashboard XML code responsible for the setup is below, with a full detailed explanation below:

       <search> 
    
        <query>| makeresults count=1 
    
    | eval test = IF("global" = "global","individual","global") 
    
        </query> 
    
        <done> 
    
          <eval token="panelView">IF($panelView$ = 
    
    &quot;global&quot;,&quot;individual&quot;,&quot;global&quot;)</eval> 
    
          <set token="form.panelView">$panelView$</set> 
    
          <eval token="refreshCount">$refreshCount$ + 1</eval> 
    
        </done> 
    
        <refresh>15s</refresh> 
    
        <refreshType>interval</refreshType> 
    
      </search> 
    
      <fieldset submitButton="false"> 
    
        <input type="text" token="panelView" depends="$tok_hide$"> 
    
          <label>field1</label> 
    
          <initialValue>global</initialValue> 
    
        <change> 
    
          <condition value="global"> 
    
              <set token="globalView">true</set> 
    
              <unset token="individualView"></unset> 
    
          </condition> 
    
          <condition> 
    
            <unset token="globalView"></unset> 
    
            <set token="individualView">true</set> 
    
          </condition> 
    
        </change> 
    
        </input> 
    
      </fieldset> 

    Components

    The components of this setup are as follows:

    – Search to detect what view is currently being displayed and what the next one will be, as well as to define what the refresh interval will be

    – A hidden input to allow for catching the resulting value and setting the appropriate tokens for view hiding/showing.

    – Setup your rows (or panels) with the appropriate depends settings to leverage the appropriate tokens to ensure they are shown only when desired.

    First, the initial search. Set this search up at the top of your dashboard.

    <search> 
    
        <query>| makeresults count=1 
    
    | eval test = IF("global" = "global","individual","global") 
    
        </query> 
    
        <done> 
    
          <eval token="panelView">IF($panelView$ = &quot;global&quot;,&quot;individual&quot;,&quot;global&quot;)</eval> 
    
          <set token="form.panelView">$panelView$</set> 
    
          <eval token="refreshCount">$refreshCount$ + 1</eval> 
    
        </done> 
    
        <refresh>15s</refresh> 
    
        <refreshType>interval</refreshType> 
    
      </search> 

    The query is just a generic makeresults command to return some output value but it’s being leveraged to set the token value of the hidden input. This is to ensure that you don’t end up with an infinite loop by trying to set the token of an input within itself. Use the done event handler to set the token of the hidden input (“panelView” in my example) (details below) within it. Use an eval to set the token appropriately based on the value of the “panelView” input currently (i.e. if “global” currently, set it to “individual” and vice versa). The refresh property is what defines how often the panels/views will rotate between displaying. You can statically set it here or even define it using a token from an input, if desired, to make that refresh interval easily customizable.

    As far as the input is concerned, create a text box input and set the “depends” property on it to a token you don’t intend on setting so that it is always hidden (i.e. “$tok_hide$”). Add a change condition so you can set, and unset, appropriate tokens based on the value of the input. This is where the magic happens! When the value of the token is “global”, in this case, it sets the globalView token and unsets the individualView token. This will hide the individual panels and display the global one. The default condition after that is executed when the value is anything other than “global”, which is sufficient in our scenario but you may need additional explicit conditions if you have more than two views in your dashboard. Note how the set/unset is just reversed from the first one to ensure only one is set at any given time.

    <fieldset submitButton="false"> 
    
        <input type="text" token="panelView" depends="$tok_hide$"> 
    
          <label>field1</label> 
    
          <initialValue>global</initialValue> 
    
        <change> 
    
          <condition value="global"> 
    
              <set token="globalView">true</set> 
    
              <unset token="individualView"></unset> 
    
          </condition> 
    
          <condition> 
    
            <unset token="globalView"></unset> 
    
            <set token="individualView">true</set> 
    
          </condition> 
    
        </change> 
    
        </input> 
    
      </fieldset> 
    
     

    Finally, it’s time to configure your rows/panels with the appropriate depends property to hide/show panels when necessary, as shown below. Set the value of each to be the token that will show the panel/row.

      <row depends="$globalView$"> 

    Save your dashboard and enjoy the automatic cycling between your panels with no engagement from a human!

  • Splunk Index Earliest and Index Latest

    Splunk Index Earliest and Index Latest

    By Jay Young, Senior Splunk Consultant

    In Splunk, _index_earliest and _index_latest are two special time-based SPL and SPL2 search constraints that help you specify a time range based on indexed time and not event time for your search within a specific index. These constraints are useful for limiting the scope of your search to a specific a time and improving the efficiency of your searches. They also help find events they may have been indexed with incorrect event time stamps.

    _index_earliest

    The _index_earliest constraint specifies the earliest time that your search should begin when searching within a specific index.

    You can think of it as setting the starting point in time for your search within the specified index.

    This constraint is particularly useful when you want to focus on a specific time range within an index, allowing you to exclude data that’s outside that range.

    _index_latest

    The _index_latest constraint specifies the latest time that your search should end when searching within a specific index.

    It sets the ending point in time for your search within the specified index.

    Like _index_earliest, _index_latest helps you narrow down your search to a specific time frame, excluding data that falls outside of it.

    Reference materials can be found on the Splunk SPL Search Manual

    Example 1

    Suppose you have an index called “web_logs” and you want to search for events between 10:00 AM and 11:00 AM on a specific day.

    index=web_logs source=”/var/log/access.log” | search

    _index_earliest=”10:00:00″ _index_latest=”11:00:00″

    Example 2

    To search for events in the “security” index that occurred between October 1, 2023, and October 15, 2023, you can use the constraints like this:

    index=security | search _index_earliest=”10/01/2023:00:00:00″

    _index_latest=”10/15/2023:23:59:59″

    Example 3

    You can also use relative time expressions. For instance, to search for events within the last 24 hours in the “application” index:

    index=application | search _index_earliest=-24h _index_latest=now

    Conclusion

    These examples demonstrate how to use _index_earliest and _index_latest to specify time ranges when searching within specific indexes in Splunk. This can help you focus on relevant data and improve efficiency and find events that may have been ingested with an event timestamp that was out of the normal date and time range.

  • How to Dynamically Extract and Set Field Names in Splunk

    How to Dynamically Extract and Set Field Names in Splunk

    By Brent Mckinney, Splunk Team Lead

    This blog demonstrates how to dynamically set field names based on values in your Splunk events, and set them to corresponding field values. This requires a unique configuration, as opposed to doing traditional field extractions with static field names.

    Let’s Get Started

    For this example, let’s say we have the following events with the sourcetype test_sourcetype:

    11/30/2023 01:34:30 field_name=”response_code” field_value=”200″

    11/30/2023 02:30:39 field_name=”response_code” field_value=”200″

    11/30/2023 03:36:47 field_name=”response_code” field_value=”404″

    11/30/2023 04:39:31 field_name=”response_code” field_value=”500″

    11/30/2023 05:34:55 field_name=”response_code” field_value=”200″

    11/30/2023 06:32:21 field_name=”response_code” field_value=”200″

    11/30/2023 07:39:54 field_name=”response_code” field_value=”200″

    11/30/2023 08:38:29 field_name=”response_code” field_value=”200″

    11/30/2023 09:36:34 field_name=”response_code” field_value=”404″

    11/30/2023 10:31:01 field_name=”response_code” field_value=”500″

    By default, Splunk will extract these fields as follows:

    field_name = response_code

    field_value = 200

    But what if we want the fields extracted like this?

    response_code = 200

    Rather than creating a custom, static field name, and extracting a corresponding value, Splunk provides the ability to extract both the field name AND value, and apply them accordingly. This is done using field transformations applied to our sourcetype.

    Field Transformations

    The first thing we need to do is create a regular expression to capture the fields of interest. Our initial regex looks like this:

    field_name=”(?<field_name>w*)”sfield_value=”(?<field_value>w*)”” 

    This regex extracts the desired fields, but by itself, sets them in 2 fields, field_name and field_value respectively. In order to have the value of field_name be our field name, and the value of field_value be the corresponding field value, we need adjust our regex to use specific syntax that Splunk expects for the transformation. This involves using KEY and VAL to extract and correlate the field/value pair.

    Our regex now looks like this:

    field_name=”(?<_KEY_1>w*)\sfield_value=”(?<_VAL_1>w*)”” 

    The value of <string> specified in _KEY_<string> and _VAL_<string> will ensure the field name extracted is set to the field value extracted. In order to implement we can add our transformation:

    Navigate to Settings > Fields > Field transformations and provide the following then Save.

    Name: testing_extraction 

    Type: regex-based 

    Format: leave this blank 

    Regular expression: field_name=”(?<_KEY_1>w*)”sfield_value=”(?<_VAL_1>w*)” 

    Source Key: _raw 

    Next we set our field extraction to the appropriate sourcetype, to use the above transformation. To start, navigate to Fields > Field extractions:

    Name: test_extraction

    Apply to sourcetype named test_sourcetype

    Type: Uses transform

    Extraction/Transform: testing_extraction

    The above values should match the sourcetype of the data you are extracting these fields from. The value of Extraction/Transform MUST match the name of the Field Transformation. Once saved, running a search on the sourcetype will show the field names and values extracted and available to filter on.

    Note, this can NOT be done directly in SPL at search time. It must be done via field transformation. You may also need to check permissions on both the field transformation AND field extraction so that users can use the new fields.

    You should now be able to dynamically set field names based on values in your Splunk events, and set them to corresponding field values. As always, we are available if you have any questions – just fill out the form below:

  • Letter from the CEO 

    Letter from the CEO 

    As the CEO of TekStream, cybersecurity is on my mind every day. And it must be for you as well. It seems we can’t go a day without word of another breach taking place, with the cost to individuals and to corporations rising with each incident. We are fortunate, here, to have a team of the best cybersecurity experts in the business who use Splunk, AWS and other tools to create a safe environment for our employees and our data.

    Not every company has the luxury or the budget for best-in-class digital security. Often, an IT generalist is tasked with the first defense measures against threats, with best of intentions and a set of foundational basics that kick the ball down the field a bit. We ask a lot of our teams in this category, and for every alarming thought we have on the subject, they have two.

    Fatigue and fear of the unknown creep in eventually, though, and with alarming infiltrations and new complexities coming from threat actors our staff can get underwater quickly.

    There are answers out there, though. After a consultation with our security team, we can give you a roadmap to security and a platform for future growth and innovation.

    It starts with our security assessment. This program gives you visibility into your current posture, fidelity measurement of your responses and a strategy and communication plan. Members of your IT, security and C-Suite will take away a clear view of current security gaps and a plan for remediation.

    Next, our team will assess security architecture, tools, and resources, creating a documented incident response process, security policy and related documents. This three-to-five-week engagement builds the foundation for your digital assets. After stakeholder interviews, the collaborative assessment delivers an optimized resource allocation model and remediation roadmaps, prioritized by risk and complexity.

    Some of our clients choose 24/7 coverage by our team, some choose a combination approach and some take the reins fully. With training and tools, the options are limitless.

    With the freedom of security comes innovation. The modern data platform gives way to GenAI, machine learning and other artificial intelligence protocols that can vault your firm into the next level of performance and efficiency.

    Let’s explore the possibilities together.

    Sincerely;
    Rob Jansen
    CEO

  • Best Practices for Writing Efficient Splunk SPL Queries

    Best Practices for Writing Efficient Splunk SPL Queries

    By David Allen, Senior Splunk Consultant

    Data is the lifeblood of any organization, and harnessing its insights is paramount for making informed decisions. In the realm of data analytics, Splunk stands out as a powerful tool for searching, monitoring, and analyzing vast datasets.

    However, as datasets grow in size and complexity, the efficiency of your Splunk Search Processing Language (SPL) queries becomes a critical factor in unlocking the true potential of your data.

    In this blog post, we delve into the art of writing efficient SPL queries—strategies and best practices that not only enhance the speed of your searches but also contribute to a more streamlined and effective Splunk experience. Whether you are a seasoned Splunk veteran or just embarking on your data analytics journey, understanding how to optimize your SPL queries is a valuable skill set.

    In Splunk SPL, data is stored in indexes and the index command is used to specify the index or indexes from which you want to retrieve data. It is best practice to start your query with this command unless you are using another generating command. Here are scenarios and use cases where you would use the index command:

    Data Segmentation

    When your Splunk environment contains multiple indexes, you use the index command to segment your search to a specific index or a set of indexes. This is essential for isolating your search to a particular data source.

    index=your_index sourcetype=your_sourcetype

    Efficient Searches Across Indexes

    If you need to search across multiple indexes, you can use the index command to specify a list of indexes. This is useful when your data is distributed across different indexes based on sources or use cases and ensures that Splunk only scans the relevant indexes, improving the efficiency of your queries.

    index=index1 
    OR 
    index=index2

    Remember that the index command is a fundamental component of SPL and is often used in conjunction with other commands and criteria to tailor searches to your specific needs. Whether you’re conducting ad-hoc searches or building complex queries for monitoring and reporting, incorporating the index command allows you to precisely target and retrieve the data you require.

    After using the index command in Splunk SPL to specify a particular index or set of indexes, you can further refine and reduce the dataset using additional SPL commands and criteria. Here are several techniques to narrow down and focus your search:

    Specify Sourcetype or Source

    After filtering by index, you can refine your search by specifying a particular sourcetype or source. This is particularly useful when you want to focus on a specific type of data within the selected index.

    index=your_index sourcetype=your_sourcetype

    Time Range Restriction

    Limit the search to a specific time range using the earliest and latest parameters. This reduces the volume of data processed, enhancing search performance.

    index=your_index sourcetype=your_sourcetype earliest=-24h latest=now

    Field-Based Filtering

    Utilize field-based filtering to narrow down your search results based on specific field values. This is effective when looking for events that match certain criteria.

    index=your_index sourcetype=your_sourcetype field_name=value

    Combining Commands for Further Filtering

    index=your_index sourcetype=your_sourcetype 
    | stats count by field_name 
    | search count>100 
    | table field_name, count
    

    Advanced Field Filtering with eval

    Use the eval command to create calculated fields that meet specific conditions. This is helpful for advanced filtering based on complex expressions.

    index=your_index sourcetype=your_sourcetype 
    | eval new_field=if(old_field > 100, "High", "Low") 
    | search new_field="High"
    

    Regular Expression (Regex) Filtering

    Use regular expressions to filter events based on complex patterns or substrings. This is useful when you need to match events that follow a specific format. You can use a regex command for example to keep only the results that match a valid email address like [email protected].

    index=your_index sourcetype=your_sourcetype 
    | regex email="^([a-z0-9_.-]+)@([da-z.-]+).([a-z.]{2,6})$"
    

    Splunk Architecture Options

    In this next section we will look at the different architectures in Splunk and how we can take advantage of those architectures to write even more efficient SPL. But first, a little background information explaining the differences between a standalone and distributed environments.

    In Splunk, the terms “standalone” and “distributed” refer to different deployment architectures that organizations can adopt based on their data processing and scalability requirements. Let’s explore the key differences between a standalone and distributed environment in Splunk:

    Diagram comparing Splunk standalone vs. distributed environments, with icons illustrating single vs. multiple host configurations.

    Standalone Environment

    Single Instance:

    In a standalone environment, there is a single Splunk instance. This instance performs all functions, including indexing, searching, and serving the user interface.

    Indexing and Searching on the Same Instance:

    In a standalone deployment, the indexing and searching processes take place on the same machine. This simplicity is beneficial for smaller use cases but can be a limiting factor as data volumes increase resulting in slower SPL execution times.

    Distributed Environment

    Multiple Components:

    In a distributed environment, the Splunk deployment is composed of multiple components, each responsible for specific functions. Common components include indexers, search heads, and forwarders.

    Indexing and Searching on many Instances:

    Since every distributed environment contains more than one indexer and possibly more than one search head, searches can be distributed across all the indexers to effectively run your SPL in parallel on the indexers and each indexer runs the same SPL on its dataset. This results in lightning fast execution times compared to running the same SPL on a Single Instance.

    But this potential gain of the distributed environment can only be utilized if the SPL commands are arranged for maximum efficiency. This is because only certain commands can be run on the indexers and other commands can only be run on the search heads and once one of the search head only commands is reached then all subsequent commands must be run on the one search head which reduces efficiency. Unfortunately, search head commands are not distributed across all search heads in search head cluster environments.

    Distributable Streaming Commands

    This type of command can run on the indexers. Here are the most common distributed streaming commands….

    Graphic listing common SPL transformation commands including eval, fields, rename, replace, and regex.

    But as not all Splunk commands are distributable streaming commands, it is important to make sure that all preceding commands are distributable streaming commands. This will keep the SPL running on the indexers.

    Transforming Commands

    This type of command can only be run on search heads;

    Graphic listing SPL aggregation commands including chart, stats, rare, top, and timechart.

    As you can see in order to accomplish one of these commands the instance running this command must have the entire dataset and once one of these commands is reached, then all the results from the indexers are sent to the one search head which from that point on completes the remaining query regardless of the type of command used.

    So it is important as you write your SPL to run as much as you can on the indexers as long as possible before using a transforming command. Because once a transforming command is used all subsequent commands are run on the search head and the benefit of parallel processing is lost.

    Execution Speed Calculation

    You can always check to see how long it takes to run your search by looking at the Job Inspector. Here is how to do that:

    Screenshot of Splunk’s Job menu with the dropdown options to edit, inspect, or delete a job.
    Screenshot showing job inspector summary indicating 0 events scanned and the query completing in 0.067 seconds.

    In conclusion, mastering the art of writing efficient Splunk SPL (Search Processing Language) is pivotal for unlocking the full potential of this powerful analytics platform. Efficient SPL not only accelerates search performance but also enhances the overall user experience, enabling quick and accurate insights into your data.

  • Predict Your Incident Tickets With Splunk MLTK 

    Predict Your Incident Tickets With Splunk MLTK 

    Experimenting with Forecast Time Series Workflow

    By Kamal Dorairaj, Senior Splunk Consultant

    This blog details a step-by-step process on how to create and run a prediction model with Splunk MLTK. The use case explained is specifically showing how to predict the number of incident tickets created for an Operations Team during a busy holiday time, so the team can prepare for the workload. Here are my guidelines for the prediction model.

    Experiment

    The experiment predicts the number of incident creation tickets for each month in Salesforce, for the next five months. The Forecast Time Series experiment assistant workflow is used for this use case. The FTS Assistant predicts the next value in a sequence of time series data, and the result includes both the predicted value and a measure of the uncertainty of that prediction.

    Follow these steps to create a Forecast Time Series Experiment:

    Go to Apps -> Splunk_ML_Toolkit -> Experiments.

    Click on Create New Experiment

    Select Forecast Time Series from the dropdown

    Complete the Experiment Title and Description and click Create. (Both the name and description can be edited later if needed)

    Splunk Machine Learning Toolkit Experiments page showing multiple available experiment types including Smart Forecasting, Smart Outlier Detection, and Clustering.
    A dropdown menu in Splunk MLTK showing options for creating a new experiment, with Forecast Time Series highlighted among other predictive options.
     Blank forecast experiment setup screen in Splunk MLTK showing options to select an algorithm, field to forecast, and configure method and intervals.

    Build The SPL

    Creating the SPL is the 80% of the work. The SPL should filter the condition appropriately to a specific numeric field value. The below SPL is an example where the search scans thru the past four years of salesforce incident tickets count through the input lookup with a one month span. Develop similar SPL based on your data sources.

    [| INPUTLOOKUP SALESFORCE_INDEX.CSV ] SOURCETYPE=”SFDC:CASE” CASENUMBER=* STATUS!=DUPLICATE | EVAL TEMP=STRPTIME( CREATEDDATE, “%Y-%M-%DT%H:%M:%S.%Q”) | EVAL _TIME=TEMP | TIMECHART SPAN=1MON DISTINCT_COUNT(CASENUMBER) AS “TICKETS COUNT”

    Forecast experiment in Splunk MLTK with a SPL query entered for analyzing duplicate Salesforce case tickets, including eval and timechart functions.

    Algorithim

    Select the Kalman Filter algorithm from the Algorithm dropdown. A good understanding of each algorithm is needed to use the algorithm that works best for our use case. The Kalman Algorithm considers subsets of features such as local level (an average of recent values), trend (a slope of line that fits through recent values) and seasonality (repeating patterns).

    From the Field to Forecast list, select the Tickets Count field which we want to forecast for this use case.

    Next, specify 5 in the Future Timespan field, which is 5 months of future data we want to forecast.

    Then, specify 95 in the Confidence Interval field, which is the percentage of the future data you expect to fall inside of the confidence envelope.

    All other fields are optional and can be used based on the use case.

    Completed forecast experiment setup in Splunk MLTK showing a populated query and configuration for Kalman Filter with a 95% confidence interval.

    Forecast

    Click on Forecast. The math behind the algorithm gets applied on the search results and will produce the results of the next five-month prediction count.

    Draft version of a forecast experiment for Salesforce duplicate tickets in Splunk MLTK, ready to be saved or executed with pre-filled parameters.
    Splunk MLTK forecast visualization with a line graph showing ticket count over time, shaded confidence intervals, and performance metrics like R² and RMSE.

    Definition of The Variables

    After you forecast a time series, review your results in the following tables and visualizations.

    Table explaining forecast result metrics in Splunk, including definitions for R² Statistic, Root Mean Squared Error, and Prediction Outliers.

    Run The Model

    Click on the Show SPL to generate a new modal window/overlay showing the search query you used to forecast. Copy the SPL for future use in other aspects of your Splunk environment.

    SPL code preview popup in Splunk MLTK showing the complete forecast command used to calculate and visualize predicted ticket counts.

    Once you are getting valuable results from your experiment, save it. Saving the experiment results in the following actions:

    Assistant settings saved as an experiment knowledge object. 
    The Draft version saves to the experiment Listings page. 
    Any affiliated scheduled trainings and alerts update to synchronize with the search SPL and trigger conditions. 

    Load a saved experiment by clicking the experiment name. 

    Within the experiment click  Open in Search  to generate a new search tab for this same dataset. This new search will open in a new browser tab, away from the assistant. This search query uses all data, not just the training set. You can adjust the SPL directly and see results immediately. You can also save the query as a Report, Dashboard Panel or Alert.

    Line and bar chart from a Splunk dashboard titled “Salesforce Monthly Incidents Prediction,” showing predicted and actual ticket creation counts from 2018 to early 2023, with a three-month forward forecast and confidence bands.

    Experiments are always stored under the user’s namespace, which means that changing sharing settings and permissions on experiments is not supported.

    Now you know how to create and run a prediction model with Splunk MLTK. Let us know if your model works, and if you have any questions after running your next prediction. Happy Splunking!

  • Splunk Timestamp Extraction – Where and How to Find Time!

    Splunk Timestamp Extraction – Where and How to Find Time!

    By Tyler Phillips, Splunk Consultant

    Splunk timestamp extraction can be tricky until you work with it a couple times. Follow along with me through a couple different examples and you should be able to extract a timestamp out of any data. 

    So, what do we use to extract a time stamp? There are a few settings in Splunk’s “Magic 8” that go into props.conf of the data you are trying to ingest. There are three settings were going to work with today.

    TIME_PREFIX

    TIME_PREFIX is the regex to tell Splunk where to start looking for the timestamp. Splunk will then attempt to make a timestamp out of the characters that follow the prefix. If the prefix cannot be found then timestamp extraction will not occur.

    MAX_TIMESTAMP_LOOKAHEAD

    This is the count of characters you want to look at in the timestamp. This count begins right after the end of the found TIME_PREFIX characters and counts from there. This does not count from the start of the event.

    TIME_FORMAT

    Time variables used to parse out our timestamp and tell Splunk what each item is.

    VariableDescription
    %EzSplunk-specific, timezone in minutes.
    %HHour (24-hour clock) as a decimal number. Hours are represented by the values 00 to 23. Leading zeros are accepted but not required.
    %IUppercase “i”. Hour (12-hour clock) with the hours represented by the values 01 to 12. Leading zeros are accepted but not required. Use with %p to specify AM or PM for the 12-hour clock.
    %MMinute as a decimal number. Minutes are represented by the values 00 to 59. Leading zeros are accepted but not required.
    %NThe number of subsecond digits. The default is %9N. You can specify %3N = milliseconds, %6N = microseconds, %9N = nanoseconds.
    %pAM or PM.
    %TThe time in 24-hour notation (%H:%M:%S). For example 23:59:59.
    %XThe time in the format for the current locale. For US English the format for 9:30 AM is 9:30:00.
    %ZThe timezone abbreviation. For example EST for US Eastern Standard Time.

    So, for testing we are going to use my local Splunk install and the add data wizard/upload data to test our configs and check the data.

    My first example is the splunkd_ui_accesslogs in my internal index. This one is pretty simple as Splunk actually already picks up the timestamp for us! That’s it right? Well, we could stop there and let Splunk do the work or we could tell Splunk exactly where to look and what to look at so it doesn’t have to waste resources trying to do this itself.

    Splunk's "Set Source Type" page showing basic line merge and line breaker settings without timestamp extraction configured.

    As you can see the correct timestamp is highlighted and yet we don’t have any settings set in advanced. Let’s change that.

    First were going to take this event into a regex tester (I use regex101) to create a regex for before the timestamp. Doing this I was able to use “s[“ as my TIME_PREFIX.

    TIME_PREFIX = s[

    Next, I counted the number of characters in the timestamp and came up with 30 characters including the space. Yes, the space does count.

    MAX_TIMESTAMP_LOOKAHEAD = 30

    Now for the fun part. We are going to use the Splunk Time Variables doc to create a TIME_FORMAT. 

    Using this page, we want to find the correct variable for each element of the time and write it out in the same format with those variables. Here is what I came up with for this timestamp.

    TIME_FORMAT = %d/%b/%Y:%H:%M:%S.%3N %z

    The %z at the end represents time zone in the data.

    Splunk source type configuration with advanced timestamp fields filled in, including TIME_PREFIX and TIME_FORMAT.

    Using these settings, we can see that our test worked and we are collecting the correct timestamp for Splunk so it can save on workload.

    Next, I am going to use a splunkd.log event.

    11-07-2023 12:09:09.683 -0500 INFO TailReader [1039908 tailreader0] – Batch input finished reading file=’/Applications/Splunk/var/spool/splunk/tracker.log’

    This event has the timestamp at the beginning of the event so we are going to use the TIME_PREFIX of “^”. This tells Splunk that the timestamp is at the very beginning of the event. The methods for creating the MAX_TIMESTAMP_LOOKAHEAD and TIME_FORMAT stay the same. Using this event, I came up with these settings.

    TIME_PREFIX = ^

    MAX_TIMESTAMP_LOOKAHEAD = 29

    TIME_PREFIX = %m-%d-%Y %H:%M:%S.%3N %z

    Splunk timestamp extraction example showing correctly parsed log events with yellow-highlighted timestamps and INFO-level log entries.

    Next, I did want to show some syslog data and working with its timestamps. Nothing different here but syslog is a very common type of data so I thought it would be good to include. Here I will be using a couple of F5 syslog events. My settings are:

    TIME_PREFIX = ^

    MAX_TIMESTAMP_LOOKAHEAD = 15

    TIME_FORMAT = %b %d %H:%M:%S

    Splunk input settings for source type F5_Example with mixed timestamp formats visible across multiple log types.

    If you are looking to work well with timestamps it may take a couple tries and some practice but it will be easy to pick up and make things smoother for you when bringing in data. I am happy to answer any questions you have, just contact me using the form below. Happy Splunking!

  • Useful Online Resources for the Aspiring Splunk Admin

    Useful Online Resources for the Aspiring Splunk Admin

    By Eric Levy, Splunk Consultant

    No matter how much training you go through and how many certifications you get, you can truly never know everything about Splunk. Some of it isn’t even provided in training itself – to properly use Splunk, you’ll need experience around the command line, data sources, and syslog. Even beyond that, you’ll never truly memorize every possible setting in props.conf or how to form every possible regular expression.

    Here is a list of resources that my fellow TekStream colleagues and I compiled that we use on a near daily basis to assist in our Splunk work.

    OFFICIAL SPLUNK RESOURCES 

    Splunk Docs

    You will never go a day using Splunk without referring to the official documentation, colloquially known as the “Docs”. It has pages on every product offered by Splunk, including premium apps and select supported apps in Splunkbase, and provides detailed installation steps, configuration steps, upgrade steps, and best practices. Nearly every .conf file and SPL command/function has its own page for reference, on top of formatting standards for time values and dashboards (both Classic and Studio). The added benefit is that Splunk keeps previous versions of the Docs available if you aren’t running on the latest version. While the Docs are an essential resource, be wary of vague wording on some pages.

    Splunk Community Posts

    If you didn’t find it in the Docs, somebody else didn’t either. The Splunk community has thousands of Q&A threads for tricky searches, error messages, unconventional log sources, and other specific use cases. Oftentimes community posts and the docs go hand in hand as several users link back to the docs for more information on an answer. It’s sites like here that show how limitless the sky can be with Splunk.

    Splunkbase

    A repository for apps to install in Splunk – some supported, others not. Includes technical add-ons (TAs) for data sources, front-facing apps with useful dashboards, alerts, and searches, and even custom visualizations (like a calendar, for example). While you’ll always interact with Splunkbase in some way or another (as Splunk communicates with it directly to install apps), the site itself is useful for documentation and important updates provided by the developers. Don’t see an app for your purposes? Develop one and submit it for others to use!

    ENTERPRISE SECURITY

    Splunk ES Detections

    This constantly updated list provided by Splunk has several threat detections to use in Enterprise Security. Each detection has steps for implementation, security context, and known false positives. Keep in mind that some are marked “experimental” and may not be confirmed as effective.

    Risk Based Alerting Guide

    Risk Based Alerting is a powerful and unique feature in Enterprise Security for prioritizing threat sources, and this free PDF is a guide for how to use it and get the most value out of your security notables.

    UNOFFICIAL SPLUNK RESOURCES

    Splunk Subreddit

    Unaffiliated with Splunk, but the subreddit is a sufficient alternative to the Splunk Community posts when searching for an unconventional use case.

    Stack Overflow

    Similar to the Splunk Community posts and the subreddit, here is another great resource to find unconventional use cases.

    GoSplunk 

    An open repository for SPL queries and dashboards, essential for anyone getting started with SPL and/or looking for inspiration for their own projects. They also have a blog with some helpful Splunk information, although they haven’t been updated in over 5 years.

    TekStream Splunk Blog Posts 

    Our esteemed Splunk Consultants from all over the country always post helpful information, tips, and resources to this very blog. Be sure to follow us on LinkedIn for updates and new blogs as they come in!

    NON-SPLUNK ESSENTIALS 

    RegexOne 

    A perfect starting ground for learning regular expressions.

    Regex101 

    Once you’ve mastered RegexOne, Regex101 becomes an invaluable tool for figuring out regular expressions for field extractions and line breaking. Don’t be surprised if you use this website every week, if not every day.

    JSON Formatter 

    Helpful for developing apps and deciphering complicated log files (although Splunk is generally quite good displaying these events via INDEXED_EXTRACTIONS or KV_MODE).

    Crontab Guru 

    Some reports and alerts may need to be run on an unconventional interval for their own reasons or for spreading out search jobs. Splunk uses cron jobs to set up such alerting and this site makes formatting them easy. Just copy and paste directly into Splunk when finished.

    Character Count Tool 

    MAX_TIMESTAMP_LOOKAHEAD and TRUNCATE are essential props.conf settings to help Splunk parse time and guide each sourcetype on event length. Instead of manually counting characters, paste an event or a timestamp here to get a value immediately.

    Epoch Time Converter 

    I’ve developed use cases for my own customers to filter dashboard panels based on time intervals, which involve weaving around values set by the time picker with directly comparing epoch values. Other times, I may want to verify that the timestamps coming in are being read correctly by Splunk into the right time zone offset. This converter is perfect for translating dates to and from epoch time for these use cases and beyond.

    This list is in no way comprehensive – there are infinite use cases for Splunk that may require other tools. These are just the ones that me and my fellow consultants at TekStream use regularly. Happy Splunking!

  • Get Your Custom App to Pass App Vetting on the First Try

    Get Your Custom App to Pass App Vetting on the First Try

    By Nate Hufnagel, Splunk Consultant II

    Introduction

    Every day, more and more Splunk customers are moving from on-prem to Splunk Cloud. While this move simplifies architecting and cuts down on server admin costs, it also makes it more difficult for Splunk admins to install new and existing custom apps (read non-Splunkbase). All apps in Splunk cloud must pass a vetting process called AppInspect. Without understanding the inner workings of the AppInspect process, the task of making an on-prem custom app Splunk Cloud compliant can be tedious and time consuming. This guide will give step-by-step instructions to get your custom app to pass the FIRST time. By the end, you’ll have a cloud app template you can use for other custom apps.

    Download Splunk Add-on Builder

    To get started, it is recommended to download the Splunk Add-On Builder and start by using the default add-on as a template. It contains the bare essential directories and files expected by the app vetting process (plus some extraneous files that can be removed).

    After downloading the app, navigate to the home page under Apps>Splunk Add-on Builder and click New Add-on on the far right.  Enter the name of your app, and optionally edit the directory name as needed. 

    Screenshot of the Splunk “Create Add-on” interface, showing fields like add-on name, folder name, version, and description used to initiate a custom app.

    The resulting custom app will be created under $SPLUNK_HOME/etc/apps.

    Prep the App

    Next the app will need to be prepped in order to pass AppInspect. These are the most common items that must be addressed for apps to pass (easiest to do these from the command line. Assume that the working directory for all steps is “$SPLUNK_HOME/etc/apps/”):

    1. Remove addon_builder.conf in the app’s default directory
    2. Move the auto-generated app.conf from local to default
      a. It’s recommended to use the auto-generated one, even if there is already an app.conf in the existing version of the custom app.
    3. Modify the auto-generated app.conf to clear errors and warnings
      a. Check that the package attribute and stanza already exist. Create them if they do not:
      [package]
      id = <custom_app_directory_name>
      b. Add the following additional id stanza and attributes anywhere in app.conf:
      [id]
      id = <custom_app_directory_name>
      name = <custom_app_directory_name>
      version = x.x.x
      *Make sure the version numbers are the same if they are listed multiple times.
    4. Ensure that app.manifest to matches what’s in app.conf
      a. Check the first block of json and ensure that “info.title”, “info.id.name”, and “info.id.version” have values that match what’s in app.conf.
    Code snippet showing a JSON schema definition for a Splunk app, including version info, app title, ID, and metadata structure.
    1. Remove the local directory (double check that it’s empty first!)
    2. Add binaries/conf files
      a. Be sure to place any executables in “bin/” and all Splunk configurations in “default/”
    3. Edit default.meta with necessary permissions
      a. The “admin” role is not available in Splunk cloud, so every reference in must be changed to “sc_admin”, which is the Splunk cloud equivalent.
      b. If the original custom app has a local.meta, it must be merged into default.meta.
    Code snippet displaying access control settings in a Splunk configuration file, including read/write permissions and export rules.
    1. Change permissions on app directories/files and compress the app
      a. All files must be changed to allow others to read, while all directories must allow others to read/write.
      b. On Linux/macOS, this equates to 755 for directories and 644 for files.
      c. Once the permissions are correct, compress the custom app into a .tgz or tar.gz archive.
      i. Note: if this is done on a mac, be sure to exclude any “__MACOSX” files. The command line options for this can vary depending on the current macOS version.

    Install in Splunk Cloud

    The new custom app is ready to be installed.  Navigate to Apps>Manage Apps>Uploaded Apps>Upload app on the desired search head in Splunk cloud and select the custom app archive.  Splunk will automatically run the app through AppInspect and create a report of its findings before installation, which can be viewed by clicking the “View Report” link in the pop-up window.  If there are no issues, Splunk Cloud will give the option to install the package.

    Note: It is recommended to also clear all warnings, even though the app can still technically be installed with warnings present.

    Here are some of the most common “gotchas” to look out for:

    1. If the custom app contains scheduled reports within savedsearches.conf, make sure that they are disabled before vetting. To do this, ensure that every instance of “enableSched” is set to 0 or false.
    2. Same with any data models in datamodels.conf – ensure that “acceleration = false” or “acceleration = 0”
    3. If the app utilizes an SDK, ensure that it’s updated to the latest version.

    And that’s it! By following this guide, you’ll be able to filter out the most common failures when building a custom app for Splunk Cloud. Depending on the complexity of the custom app, there may be additional failures to address in the custom config files.

  • Splunk Compliance Essentials: Your One-Stop Shop

    Splunk Compliance Essentials: Your One-Stop Shop

    Meet The Requirements of CMMC, DFARS, FISMA and More

    By David Cheever, Team Lead, Advanced Services

    Introduction

    Splunk’s Compliance Essentials provides several features that can help organizations meet the requirements of various compliance frameworks. This app comes pre-packaged with a library of compliance practices, dashboards that can be used to monitor compliance status & track progress, and reports that can be used to demonstrate compliance to auditors.

    After a fresh installation, the app will direct you to the App Initial Setup Page to select a framework.  You can also select multiple frameworks if more than one is applicable to your organization. Compliance Essentials addresses the requirements for the following five frameworks:

    1. Cybersecurity Maturity Model Certification (CMMC)
    2. Defense Federal Acquisition Regulation Supplement (DFARS)
    3. Federal Information Security Modernization Act (FISMA)
    4. Risk Management Framework (RMF)
    5. Office of Management (OMB) M-21-31

    This blog will provide a general overview of the features and benefits of the app, which is available for free on Splunkbase.

    Overview Pages

    The overview pages provide a high-level overview of your audit and continuous monitoring program. The Domain Overview page displays a selection of domains, each of which drills down into a Practice Overview page. The Practice Overview page, in turn, displays a selection of dashboards that provide more detailed information about the status of the program. For a single pane of glass view, the Executive Overview dashboard provides a top-down view of the status of the various audit review entries across the full scope of the solution.

    Executive Overview dashboard showing review metrics, practice status mix, and audit entry timelines for various security controls.

    Practice Dashboards

    Compliance Essentials uses lookups and KV Store collections to map content to different controls. It also relies on data models to ensure that pre-built dashboards are populated correctly. The app comes with a robust library of more than 50 dashboards that align with OMB requirements, more than 100 dashboards that align with DFARS practices, more than 170 dashboards that align with CMMC practices, more 300 dashboards that align with FISMA practices and 2,900+ dashboards that align with RMF practices.

    Dashboard displaying successful and failed remote logins, privileged account authentications, and login details by user and IP address.

    Custom Content

    The Custom Content page in Compliance Essentials includes a list of custom dashboard panels which can be added to already existing dashboards. These panels are organized by practice and domain, making it easy to locate the panels you need. To add a panel to a dashboard, simply click on the “Add to dashboard” button. The panel will then be added to the corresponding dashboard. The solution includes over 300 custom panels that can be added to dashboards, in addition to the panels that ship out-of-the-box. This gives you a wide range of options to customize the dashboards to meet your specific needs and make them more informative and useful.

    List of compliance panels with audit titles, descriptions, and dashboard integration options under Access Control domain AC-2.14.

    Adding Records

    Users can also add records to each dashboard, making it easier to store relevant documentation and artifacts directly within Splunk. This is especially useful for practices that are documented or policy-driven, as it eliminates the need to search for artifacts in multiple locations.

    Table listing compliance-related documents and reports with completion dates, descriptions, and options to edit or delete.

    Audit Entries

    Each dashboard has an audit entry capability that allows you to view, manage, and create audit entries. This workflow can be used by your internal teams to track comments and feedback from reviews, verify compliance status, and set follow-up review dates.

    Audit entries interface showing creation dates, statuses, reviewers, and descriptions with a conformant status indicator.

    Solution Activity

    The Solution Activity page allows you to track the app’s activity and utilization, as well as audit the auditor’s work. It also provides monitoring capabilities for your audit and continuous monitoring program, both in terms of activities and overall trends.

    Solution User Activity dashboard visualizing page access counts, recent trends, and a timeline graph broken down by compliance module and user.

    Conclusion

    Splunk’s Compliance Essentials is a one-stop shop that can help organizations improve their compliance posture by providing a centralized view of all their compliance data. This can help organizations to identify potential compliance gaps and track their progress towards compliance. If you are looking for a way to improve your organization’s compliance posture, contact us for more information on implementing Compliance Essentials into your environment.