Category: Blog

  • Securing Splunk Enterprise with SSL

    Securing Splunk Enterprise with SSL

    Kamal Doriaraj | Senior Splunk Consultant

    I recently worked with a customer where the entire Splunk architecture was not on SSL. The entire architecture migrated from the non-SSL to SSL communication using self-sign certificates. The following content consolidates the disparate information of securing Splunk enterprise with SSL, into one single blog in a step-by-step process.

    PART ONE: CERTIFICATES

    Splunk software ships with, and is configured to use, a set of default certificates. These certificates discourage casual snoopers but could still leave you vulnerable because the root certificate is the same in every Splunk download and anyone with the same root certificate can authenticate.

    SELF-SIGN CERTIFICATES:

    To use our own self-sign certificates; We need the below three files, which is everything you need to configure indexers, forwarders, and Splunk instances that communicate over the management port:

    • myServerCertificate.pem
    • myServerPrivateKey.key
    • myCACertificate.pem

    If you already possess or know how to generate the needed certificates, you can skip this topic and go directly to the configuration steps.

    a.     Create a new directory to work from when creating your certificates. In our example, we are using $SPLUNK_HOME/etc/auth/mycerts. (This ensures you do not overwrite the Splunk-provided certificates that reside in $SPLUNK_HOME/etc/auth)

    b.     Create the root certificate:

    First, you create a root certificate that serves as your root certificate authority. You use this root CA to sign the server certificates that you generate and distribute to your Splunk instances.

    Generate a private key for your root certificate:

    $SPLUNK_HOME/bin/splunk cmd openssl genrsa -aes256 -out myCAPrivateKey.key 2048

    When prompted, create a password for the key.

    When the step is completed, the private key myCAPrivateKey.key appears in your directory.

    Generate and sign the certificate:

    $SPLUNK_HOME/bin/splunk cmd openssl req -new -key myCAPrivateKey.key -out myCACertificate.csr

    When prompted, enter the password you created for the private key in $SPLUNK_HOME/etc/auth/mycerts/myCAPrivateKey.key.

    Provide the requested certificate information, including the common name if you plan to use common name checking in your configuration. A new CSR myCACertificate.csr appears in your directory.

    Use the CSR myCACertificate.csr to generate the public certificate:

    $SPLUNK_HOME/bin/splunk cmd openssl x509 -req -in myCACertificate.csr -sha512 -signkey myCAPrivateKey.key -CAcreateserial -out myCACertificate.pem -days 1095

    When prompted, enter the password for the private key myCAPrivateKey.key.

    A new file myCACertificate.pem appears in your directory. This is the public CA certificate that you will distribute to your Splunk instances.

    c.    Create the server certificate:

    Now that you have created a root certificate to serve as your CA, you must create and sign your server certificate.

    Generate a key for your server certificate:

    Generate a new RSA private key for your server certificate. In this example we are again using AES encryption and a 2048 bit key length:

    $SPLUNK_HOME/bin/splunk cmd openssl genrsa -aes256 -out myServerPrivateKey.key 2048

    When prompted, create a new password for your key. A new key myServerPrivateKey.key is created.

    You will use this key to encrypt the outgoing data on any Splunk Software instance where you install it as part of the server certificate.

    Generate and sign a new server certificate:

    Use your new server private key myServerPrivateKey.key to generate a CSR for your server certificate.

    $SPLUNK_HOME/bin/splunk cmd openssl req -new -key myServerPrivateKey.key -out myServerCertificate.csr

    When prompted, provide the password to the private key myServerPrivateKey.key.

    Provide the requested information for your certificate, including a Common Name if you plan to configure Splunk Software to authenticate via common name checking. A new CSR myServerCertificate.csr appears in your directory.

    Use the CSR myServerCertificate.csr and your CA certificate and private key to generate a server certificate.

    $SPLUNK_HOME/bin/splunk cmd openssl x509 -req -in myServerCertificate.csr -SHA256 -CA myCACertificate.pem -CAkey myCAPrivateKey.key -CAcreateserial -out myServerCertificate.pem -days 1095

    When prompted, provide the password for the certificate authority private key myCAPrivateKey.key.
    Make sure to sign this with your private key and not the server key you just created.

    A new public server certificate myServerCertificate.pem appears in your directory.

    d.    You should now have the following files in the directory you created:

        • myServerCertificate.pem
        • myServerPrivateKey.key
        • myCACertificate.pem

    Prepare your signed certificates for Splunk authentication:

    Once you have your certificates, you must combine the server certificate and your keys into a single file that Splunk software can use.

    a.   Create a single PEM file:
    Combine your server certificate and public certificate, in that order, into a single PEM file.

    cat myServerCertificate.pem myServerPrivateKey.key myCACertificate.pem > myNewServerCertificate.pem

    b.   Once created, the contents of the file myNewServerCertificate.pem should contain, in the following order:

        • The server certificate (myServerCertificate.pem)
        • The private key (myServerPrivateKey.key)
        • The certificate authority public key (myCACertificate.pem)

    PART TWO: Securing Splunk Enterprise

    What to do when you have your certificates. You can apply encryption and/or authentication using your own certificates for:

    1. Communications between the browser and Splunk Web
    2. Communication from Splunk forwarders to indexers
    3. Other types of communication, such as communications between Splunk instances over the management port

    1. Communications between the browser and Splunk Web:

    Assuming that you have already generated self-signed certificates or purchased third-party certificates.

    Make sure your certificate and key are available from your folder. In this example we are using $SPLUNK_HOME/etc/auth/mycerts/:

    • $SPLUNK_HOME/etc/auth/mycerts/mySplunkWebCertificate.pem
    • $SPLUNK_HOME/etc/auth/mycerts/mySplunkWebPrivateKey.key

    Open or create a local web.conf file in $SPLUNK_HOME/etc/system/local/web.conf, or in any other application location if you’re using a deployment server.

    Under the [settings] stanza, configure the path to the file containing the web server SSL certificate private key and the path to the PEM format Splunk web server certificate file.

    The following example shows an edited settings stanza:

    [settings] enableSplunkWebSSL = true privKeyPath = </home/etc/auth/mycerts/mySplunkWebPrivateKey.key > serverCert = </home/etc/auth/mycerts/mySplunkWebCertificate.pem >

    Restart your Splunk software: # $SPLUNK_HOME/bin/splunk restart splunkd

    You must now prepend “https://” to the URL you use to access Splunk Web.

    2. Communication from Splunk forwarders to indexers:

    Using your own certificates to secure Splunk communications involves the following procedures:

    · Configuring indexers to use a new signed certificate

    · Configuring forwarders to use a new signed certificate

    Configuring indexers to use a new signed certificate:

    Copy the server certificate and CA public certificate into an accessible directory on the indexer you want to configure.

    $SPLUNK_HOME/etc/auth/mycerts/

    Configure the inputs.conf file on the indexer to use the new server certificate.
    Add the following stanzas to the $SPLUNK_HOME/etc/system/local/inputs.conf file, or the appropriate directory of any app you are using to distribute your forwarding configuration:

    [splunktcp-ssl://9998]
    disabled=0
    [SSL]
    serverCert=/opt/splunk/etc/mycerts/myServerCertificate.pem
    #requireClientCert = true
    #sslAltNameToCheck = forwarder.local

    Note: Configure your indexers to use SSL on port 9998. Because you can continue to have the existing non-SSL port to use on 9997. Once we configure complete enterprise to use SSL on port 9998 and everything is reporting on 9998 port, we can then disable the 9997.

    Indexers are configured with the Root CA cert used to sign all certificates. This can be achieved by editing the file server.conf in $SPLUNK_HOME/etc/system/local on your indexer(s).

    [sslConfig]
    sslRootCAPath = /opt/splunk/etc/mycerts/myCACertificate.pem

    Restart the splunkd process:
    # $SPLUNK_HOME/bin/splunk restart splunkd

    Repeat the above steps on all the Indexers.

    Configure forwarders to use a signed certificate:

    Given we would be having huge number of forwarders; We need to use DS to push the certificates and the configuration files.
    I would recommend to test it with few set of forwarders before deploying into all the clients.

    Steps:
    In the DS, create an app ‘customer_cert_outputs’ (use your own naming) with all the cert

    files (.pem) in the /local folder. The app should also contain the outputs.conf file.

    Make sure to refer the correct app path in the outputs.conf file.

    [tcpout:group1]
    server=indexer01:9998, indexer02:9998
    disabled = 0
    clientCert = /opt/splunk/etc/apps/customer_cert_outputs/local/myServerCertificate.pem

    Push this app out to the forwarders! (Don’t forget to mark the app as “restart required” in the server class on the DS.)

    To verify your SSL connections in Splunk Web, try the following command:

    index=_internal source=*metrics.log* group=tcpin_connections | dedup hostname | table _time hostname version sourceIp destPort ssl

    You can also splunkd.log to validate and troubleshoot your configuration.

    Once we see the clients forwarding thru port 9998. We can leverage the whitelist/blacklist in the serverclass to push the app to all forwarders in a phased manner.

    3. Securing inter-Splunk communication:

    Distributed search configurations share search information, knowledge objects and app and configuration information over the management port.

    Communication between search heads and peers relies on public-key encryption. Upon startup, Splunk software generates a private key and public key on your Splunk installation. When you configure distributed search on the search head, the public keys are distributed by search heads to peers and those keys are used to secure communication. This default configuration provides built-in encryption as well as data compression that improves performance.

    It is possible to swap these generated keys out with your own keys, though the existing keys are generally considered adequate for most configurations.

    Click here to connect with a Splunk Specialist at TekStream or learn more about our Splunk Managed Services Here.

  • Make Unstructured Data Searchable with a Multikv Command

    Make Unstructured Data Searchable with a Multikv Command

    Jeff Rabine | Splunk Consultant

    Splunk works best with structured data. This blog post will cover how to make unstructured data searchable. In this real-world example, the customer wanted to use data in the second table of an unstructured log file. Changing the log format was not an option, and access to .conf files was not available, so all changes needed to happen at search time.

    Raw log sample:

    Raw log sample where we need to make unstructured data searchable.

    As you can see, there are two tables of data in the log. The first step is to remove the top table from the results since it’s unnecessary for this search. We will do that using the rex command to over-write _raw capturing only the data that we need.

    Two tables of data after running Splunk search.

    The next step is to use the multikv to break the tables into separate events. This command will attempt to create fields and values from the table however, in our case, we removed the headers from the table because the formatting of our table was not clean. This caused the multikv command to not work properly. Since we removed the headers, we will set them to noheader=t.

    Search result screen for using Multikv noheader=t command to break tables into separate events.

    Now, the last thing we need to do is create our field extractions, and then we can use the data however we please.

    Final image multikv after manipulating data.

    As you can see, we now have nice clean data!

    Other uses of the multikv command:

    Depending on your data, there are other ways to use the multikv command. Neither of these examples was able to make unstructured data searchable for our customer, but I recommend trying them with your data. Your success with the following examples will depend on how cleanly formatted your logs are.

    In our example, we stripped out the headers of the table to make unstructured data searchable. You may be able to leave the headers. That would save you from extracting the fields with the rex command. Also, by default, the command will attempt to process multiple tables within the log, so you might just have to use the multikv command. After running this search, check to see if the correct fields were extracted.

    index="fruitfactory" sourcetype="fruitfactory"
    | multikv

    You can also tell the command what row contains the headers of the table. This would allow you to always look for the headers on the first, second, etc row of the event. Again, check and see if the correct fields were extracted after running this command.

    index="fruitfactory" sourcetype="fruitfactory"
    | multikv forceheader=

    Want to learn more about unstructured data or using the multikv command? Contact us today!

  • Monitor Splunk Alerts for Errors

    Monitor Splunk Alerts for Errors

    Zubair Rauf | Senior Splunk Consultant – Team Lead

    In the past few years, Splunk has become a very powerful tool to help teams in organizations proactively analyze their log data for reactive and proactive actions in a plethora of use cases. I have observed almost every Splunker monitor Splunk Alerts for errors. Splunk Alerts use a saved search to look for events, this can be in real-time (if enabled) or on a schedule. Scheduled alerts are more commonplace and are frequently used. Alerts trigger when the search meets specific conditions specified by the alert owner. Triggered alerts call alert actions which can help owners respond to alerts. Some standard alert actions are to send an email, add to triggered alerts, etc. Other Splunk TAs also help users integrate external alerting tools like PagerDuty, creating JIRA tickets, and many other things using these tools. Users can also create their own custom alert actions which can help them respond to alerts or integrate with external alerting or MoM tools. There are times that they may fail due to different reasons and a user may not get the intended alert they set up. This can be inconvenient for users and if the alerts are used to monitor critical services, this can have a financial impact as well and can prove to be costly if alerts are not received on time. The following two searches can help users understand if any triggered alerts are not sending emails or the alert action is failing. Alert actions can fail because of multiple reasons, and Splunk internal logs will be able to capture most of those reasons as long as proper logging is set in the alert action script. Please note that the user running the searches need to have access to the “_internal” index in Splunk. The first search looks at email alerts and will tell you by subject which alert did not go through. You can use the information in the results of index=_internal host=<search_head> sourcetype=splunk_python ERROR | transaction startswith=“Sending email.” endswith=“while sending mail to” | rex field=_raw “subject”=(?P<subject>[^”]+)”” | rex field=_raw “-s(?<error_message>.*)swhilessendingsmailsto:s(?P<rec_mail>.*)” | stats count values(host) as host by subject, rec_mail, error_message Note: Please replace <search_head> with the name of your search head(s), wildcards will also work. Legend; host - The host the alert is saved/run on subject - Subject of the email - by default it is Splunk Alert: <name_of_alert> rec_mail - Recipients of the email alert error_message - Message describing why the alert failed to send email

    The second (below) search looks through the internal logs to find errors while sending alerts using alert actions to external alerting tools/integrations

    | transaction action date_hour date_minute startswith=“Invoking” endswith=“exit code” | eval alert_status = if(code=0, “success”, “failed”) | table _time search action alert_status app owner code duration event_message | eval event_message = mvjoin(event_message, “ -> “) | bin _time span=2h | stats values(action) as alert_action count(eval(alert_status=“failed”)) as failed_count count(eval(alert_status=“success”) as success_count latest(event_message) as failure_reason by search, _time | search failed_count>0 Note: Please replace <search_head> with the name of your search head(s), wildcards will also work. These two searches can be setup as their own alert, but I would recommend setting these up on an Alert Monitoring dashboard.  Splunk Administrators can monitor Splunk Alerts periodically to see whether any alerts are failing to send emails or any external alerting tools integrations are not working. Splunk puts a variety of tools in your hand but without proper knowledge, every tool becomes a hammer.

    To learn more and have our consultants help you with your Splunk needs, please feel free to reach out to us.

  • Splunk Issue: Indexers Failing to Rejoin the Cluster (Solved)

    Splunk Issue: Indexers Failing to Rejoin the Cluster (Solved)

    Yetunde Awojoodu | Splunk Consultant

    Indexers failing to rejoin the cluster can cause serious issues, but this blog will provide simple steps to help resolve the issue in your environment. First, indexers in a Splunk environment can be clustered or non-clustered. In an indexer cluster environment, there can be two or more indexers also called peer nodes. Each peer node indexes external data, stores them, and simultaneously sends and receives replicated data. These indexing and replication activities are coordinated by a cluster master. The cluster master is also responsible for managing the configuration of peer nodes, searching of peer nodes and remedial activities if a peer goes offline.

    A peer node will need to be connected to the cluster master and stay connected to receive instructions. There are however situations in which a peer node could become disconnected from the cluster master. A peer could go offline intentionally by issuing the CLI offline command or unintentionally as in a server crashing or due to intermittent or recurring network issues in the environment.

    When a peer gets disconnected from the cluster master and the master does not receive a heartbeat after a set period, the master begins bucket fixing activities to ensure the defined replication factor is met so that the cluster remains in a healthy state. Refer to Splunk docs if you are interested in learning more about what happens when a peer goes down.

    Depending on the reason for the disconnection, indexers in a cluster may go offline for a few minutes or hours. In my situation, a partial datacenter outage had caused multiple appliances to fail and resulted in failed connections among the Splunk servers. This caused about half of the indexers to lose connection to the cluster master for several hours.

    The datacenter issue was later determined to be a result of storage shortfalls and was resolved within 24 hours but once the datacenter was restored, however, we noticed the indexers failing to rejoin the cluster. The master would not allow them back into the cluster.

    Problem Indicators

    There were multiple errors in Splunk that pointed to issues with the indexers:

    i. Messages indicating failed connection from Cluster Master to the Indexers

    ii. Messages indicating indexers being rejected from joining the cluster

    iii. Cluster Master in an unhealthy state – Replication and Search factor not met

    iv. Most Splunk servers including search heads in red status

    v. No replication activities as seen on the Indexer Clustering Dashboard on the Cluster Master

    vi. Indexers with “BatchAdding” status on the Indexer Clustering dashboard

    Below is a screenshot of some of the error messages seen in Splunk:

    Indexer failing to join back cluster Failed to add peer error image.

    What Happened?

    We found that during the datacenter outage, the disconnected indexers continued to perform activities such as rolling hot buckets to warm using the standalone bucket naming convention rather than the naming convention for buckets in a clustered environment. Since the cluster master did not recognize the standalone buckets it didn’t stop those specific indexers failing to rejoin the cluster. More on this

    The screenshot below shows examples of standalone nonreplicated buckets:

    Indexer fails to join back cluster examples of standalone nonreplicated buckets.

    Below is another screenshot of what buckets originating from the local indexer in a cluster should look like:

    Indexer fails to join back cluster buckets originating from the local indexer in a cluster should look like.

    *Note that the buckets prefixed with “rb” are replicated buckets from other indexers in the cluster.

    Solution

    The solution is to rename each standalone bucket to cluster bucket convention. This was a manual effort that took us a few hours to complete but it may be possible to develop a script especially if there are several indexers failing to rejoin the cluster. In my scenario, we had a total of 9 indexers of which 5 were disconnected.

    Below are steps to resolve the issue:

    i. Identify the indexers that are unable to join the cluster

    ii. Put the Cluster Master in maintenance mode

    iii. Stop Splunk on one indexer at a time

    iv. Locate the standalone buckets in the indexed data directories on each indexer. The default location is $SPLUNK_HOME/var/lib/splunk/*/db/

    v. Append the cluster master GUID to the standalone buckets.

    vi. Start Splunk

    This process requires great attention to detail to avoid messing up the bucket names. I will recommend having other members of your team on a video conference to watch out for any errors and validate any changes made.

    How to Locate and Rename Each Bucket

    To locate the erroneous buckets, we developed a regex to match the expected format and issued a find command on the CLI to identify them.

    ➣ find /opt/splunk/var/lib/splunk/* -type d -name “db*” | grep -P “db_d*_d*_d*$”

    *Make sure to replace “/opt/splunk/var/lib/splunk/*” with your specific indexed data directory path

    On each indexer, go to each data directory in the results from the “find” command and scroll through to identify the bucket names missing the local indexer guid. Once found, append the correct local indexer guid to the bucket name as it appears in the other bucket names. Note that the guid to be appended is different for each indexer. It is the guid for the local indexer so make sure to copy the correct guid from another bucket on that indexer or check $SPLUNK_HOME/etc/instance.cfg file on that indexer for the correct guid to be appended. As a precaution, feel free to back up the buckets (or just rename to .old) before appending the guid and delete the old directories once the indexers are restored.

    Bucket Name Format without Guid – db_<newest_time><oldest_time><bucketid>

    Bucket Name Format with Guid – db_<newest_time><oldest_time><bucketid>_<guid>

    Once you have appended the correct guid to each standalone bucket, the bucket name will look like this as shown in a screenshot above:

    db_1640917434_1639072107_161_E56FC9B8-EACF-4D96-8B76-4E28FCF41819

    Remember to restart each indexer after the changes have been made and watch out for status changes and replication activities on the indexer clustering dashboard. Note that you may need to wait for a few hours to get the cluster back to a healthy state but not much should be required once the indexers have been restarted.

    If you experienced similar errors, as shown above, these simple steps should help resolve the issue in your environment.

    If you need additional assistance wrangling your Splunk indexer storage.

    You can always contact one of our Splunk consulting and managed service specialists.

  • Deleting the Unsupported Splunk Windows Universal Forwarder

    Deleting the Unsupported Splunk Windows Universal Forwarder

    By: Aaron Dobrzeniecki | Splunk Consultant

    Have you ever encountered an issue when you are trying to install a new version of Splunk over an older unsupported version of Splunk? Having an older unsupported version of Spunk Univeral Forwarder installed can cause issues with your data ingesting into your Splunk indexers. Please see the Splunk Compatibility Matrix here. In the situation below we encountered compatibility issues because we were in the middle of upgrading our Splunk environment to 8.x. The Splunk Universal Forwarder 6.5.2 is not compatible with 8.x indexers so the data from those forwarders would not ingest into Splunk. Without deleting the unsupported Splunk Windows Universal Forwarder you’ll have huge issues! We ran into an issue with a Windows Universal Forwarder that was on version 6.5.2 of Splunk, and we were trying to upgrade the Universal Forwarder to 7.3.3. (Since Splunk 7.3.3 has reached the end of support as well, you would want to install the latest version of the Splunk Universal Forwarder). When we tried to install the new version over the current version we received an error that the installation package for the current version was missing. Since Splunk 6.5.2 has reached the end of support and was removed from the website, we were unable to get the older install from Splunk.com because that version does not exist anymore. We were not able to get the 6.5.2 installation package to uninstall the Universal Forwarder from our machine. NOTE: If you have Splunk VPN you can access the older versions of Splunk. We have two options: Delete the unsupported Splunk Windows Universal Forwarder or grab the current version from behind the Splunk VPN. For this exercise, we are going to be ripping the Splunk agent from the Windows box because we do not have Splunk VPN access. Please follow the steps below:

    1. Open the Command Prompt as an Administrator

    2. Run: sc stop SplunkUniversalForwarder

    3. Run: sc delete SplunkUniversalForwarder

    This stops, then deletes, the Splunk Windows service. You may have to do this for a second Splunk service. Older Splunk Universal Forwarder software had two services, although when tested with 7.1.x, it installed only one service.

    4. You can find the internal service name by right-clicking on it in the Services Control Panel, select “Properties”, and look for the “Service Name” at the top of the dialog box.

    5. Run: rmdir /s /q “C:Program FilesSplunkUniversalForwarder”

    6. From the same Command Prompt, run:

    regedit

    This will open the Registry Editor.

    7. Search for “Splunk”. You should find an item under “HKEY_CLASSES_ROOTInstallerProducts<SOME GUID>”

    8. In the details, you’ll see a key for “ProductName”, and the value will be “Universal Forwarder”.

    By seeing this, you know you have got the right item.

    9. Right-click on the GUID in the left-hand pane and select “Delete” to delete the entire entry from the registry. Now, the Splunk installer should see your host as a new install.

    From here you can install the latest version of the Splunk Universal Forwarder for Windows. The reason we were unable to remove the Splunk program was due to the registry not being able to find the installation file for Splunk. (The 6.5.2 installation did not exist on the box anymore and we did not have a backup copy of the installation) After deleting the unsupported Splunk Windows Universal Forwarder from the registry we were able to move forward and make our Forwarder compatible with the rest of the Splunk environment.

    If you are looking for a Splunk Managed Service Provider, check out our Evaluation Checklist or fill out the form below to speak with one of our expert Splunk consultants.

  • Slice And Dice: Comparing Values Over Specific Times

    Slice And Dice: Comparing Values Over Specific Times

    Part One: Day Over Week

    Marvin Martinez | Splunk Consultant

    If you’re lost, you can look and you will find it: Time OVER time. Sometimes, data can’t just be visualized sequentially. Often, it is most useful to compare data across specific points in time. In this 4-part series, I will be outlining some interesting ways to help visualize data points across specific points in time, namely day over week (i.e. this past Thursday versus the last three Thursdays) and hour over week (this past Thursday at 1 p.m. to last three Thursdays at 1 p.m.). The first installment will focus on the day-over-week visualization that allows the user to quickly visualize the last four Thursdays (or any other day of the week) overlayed on top of each other to quickly determine any discrepancies between them.

    For example, let’s say you’re monitoring sales throughout the day. You notice that sales seemed to spike up at 8 p.m. yesterday, but you’re curious if it is spiking up at that same hour every Thursday or if the peaks are happening at different times and how big those discrepancies are.

    Splunk has some very handy, albeit underrated, commands that can greatly assist with these types of analyses and visualizations. Additionally, it can be difficult to clearly display the appropriate context and intent of the visualizations, so it is imperative to clearly delineate what the data points represent on the charts themselves. We’ll explore both situations in this article, including some sample SPL to help you get where you need to get with your own data.

    To achieve this, we’ll use the timewrap command, along with the xyseries/untable commands, to help set up the proper labeling for our charts for ease of interpretation.

    In the end, our Day Over Week Comparison chart will look like this. The chart shows each Thursday across the past four weeks, overlayed on top of each other. (Note that you could go back as far as your data lets you go. This is just how far back we went for the purpose of this article.)

    Line chart titled “Day Over Week Comparison” showing multiple data lines representing values for different Thursdays in late 2021, enabling side-by-side comparison of daily performance over time.

    This is the search that was used for the panel shown above. Each of our events has a TotalSales field that we are using as our value to chart.

    | index=”test” ….
    | eval Date = strftime(_time,”%m/%d”), Day = strftime(_time,”%A”), Hour=strftime(_time,”%H”)
    | fields _time, “TotalSales”, Hour, Day, Date
    | where Day=”Thursday”
    | timechart span=1h count(TotalSales) as TotalSales
    | timewrap 1w series=short
    | rename TotalSales _s0 as LatestDay, TotalSales _s1 as WeeksBack1, TotalSales _s2 as WeeksBack2, TotalSales _s3 as WeeksBack3, TotalSales _s4 as WeeksBack4
    | untable _time FieldName FieldValue
    | eventstats latest(_time) as LatestDate
    | eval WeekNum = substr(FieldName,-1)
    | eval FieldName = CASE(FieldName = “LatestDay”, “Latest Thursday”,1=1,”Thursday (” . strftime(relative_time(LatestDate,”-” . WeekNum . “w@h”),”%m/%d”) . “)”)
    | xyseries _time FieldName FieldValue
    | table _time “Thursday*” “Latest *”

    Let’s break this search down and explain what is going on here. The first four lines are setting up our data. We create fields to store the specific Date, Day, and Hour for our values as well as filter out only the information for the specific day we are looking to compare.

    The timewrap command requires a timechart command before it, so execute a timechart command to get the data the way you need it (in this case, spanned across an hour). Note that you are already only looking at a specific day across multiple weeks.

    Now execute the timewrap command, spanning one-week intervals and using the series=short option. This creates the resulting fields as “TotalSales_s0…” and so on. This is helpful since they can then be easily renamed in the next command to make it easier to understand which date each series represents. At this point, if you ran the search just up to the rename command after the timewrap, your visualized result should look something like this:

    Line chart displaying performance trends across an entire week for different weekday series, highlighting variations in behavior by time of day across dates in December 2021.

    This is almost there, but still not intuitive when viewing. Let’s work on that!

    The “| untable _time FieldName FieldValue” command will reformat the data as shown below, with a FieldName and FieldValue column, containing the field names and values, respectively. We can use this to rename our fields to make them easier to understand.

    Data table listing timestamped entries with associated field names and numerical values, organized for comparison between the latest day and three prior weeks.

    The following eventstats and eval commands do just that. Eventstats will determine what the latest date is in the remaining events. We will use this to help determine the actual date of the other line values. The eval commands grab the last number from the FieldName and then use a CASE statement to update the name of the field. If the FieldName is “LatestDay,” then we know it is the most recent day in our data set. Otherwise, we will update the field name to be the name of the day followed by a relative_time offset going back the WeekNum number of weeks.

    | eval WeekNum = substr(FieldName,-1)
    | eventstats latest(_time) as LatestDate
    | eval FieldName = CASE(FieldName = “LatestDay”, “Latest Thursday”,1=1,”Thursday (” . strftime(relative_time(LatestDate,”-” . WeekNum . “w@h”),”%m/%d”) . “)”)

    After these commands, your results should look something like this. Note that the FieldName is now intuitively named.

    Spreadsheet-style table comparing values by timestamp, with fields showing latest Thursday metrics versus previous Thursday dates and their respective values.

    From here, all we need to do is use the xyseries command to turn these field names back into columns for our chart.

    | xyseries _time FieldName FieldValue

    At this point, the chart will look pretty much the way we need it to.

    Repeat view of “Day Over Week Comparison” chart showing performance trends for different Thursdays, emphasizing line pattern consistency or deviation across hours

    However, we need this to be as easy to read as possible! Looking at the legend, the fields aren’t quite in the right order. Note how “Latest Thursday” is at the top but the other series do not follow sequentially in the right time order. We can fix that with the table command to control the ordering of our chart. Order the table command with _time, followed by the “Thursday” entries (use the * to denote a wildcard) and, finally, the “Latest *” field at the very end.

    | table _time “Thursday*” “Latest *”

    Now, your chart looks like this. Much better! The dates in the legend now show in ascending order and are easier to follow.

    Another instance of the “Day Over Week Comparison” chart, highlighting overlapping and diverging values across Thursday dates for hourly intervals.Figure 1: Dotted lines were added via dashboard panel options for fieldDashStyles and lineDashStyle

    In the next installment, we will create a panel that will allow us to compare one specific day from a prior week to the latest day and visualize the percentage changes between the two throughout every hour of that day. A sneak peek is shown below. Until next time!

    Comparison chart showing percentage change between the current week and three weeks prior, with green shaded area indicating positive or negative deltas and trend lines for each week plotted by hour.

    Visualizing data doesn’t have to be complicated.  Check out Part Two of our Slice and Dice Series and stay tuned for Part Three coming Spring 2023.

    Contact one of our exceptional Splunk Consultants today so we can put your data to work for you!

  • Troubleshooting ITSI Rules Engine: Expert Guide

    Troubleshooting ITSI Rules Engine: Expert Guide

    Brent Mckinney | Splunk Consultant

    In ITSI, the Rules Engine is the system responsible for processing notable events into episodes and executing actions. For this reason, it’s important to understand how it works, and how to troubleshoot if episodes are not being created in a consistent manner.

    ITSI Rules Engine workflow.

    First, a correlation search is built and scheduled, to create notable events. Correlation searches typically search the itsi_summary index for service health scores or KPI values. The results of the correlation search are stored in itsi_tracked_alerts. This index contains all notable events from any correlation searches.

    Next is the ITSI rules engine saved search. This search runs in real time, and the default Notable Event Aggregation Policy (NEAP) groups the notable events into episodes based on source. This is where the actual Rules Engine process begins, and by creating custom NEAPs, we can filter, group and act upon notable events from a correlation search.

    Finally, the episodes created by the NEAP are stored in itsi_grouped_alerts, and any actions defined should execute based on the criteria defined.

    Creating a NEAP.

    To begin creating episodes, ensure that your Correlation Search is enabled, and that notable events are being populated in the itsi_tracked_alerts index. The source field in this index will be your correlation search name.

    Once you confirm that events are flowing into itsi_tracked_alerts, you’ll want to create a NEAP, and ensure that you have “source” matches ”your correlation search“ under the “include the events if” section on the filtering criteria page.

    The goal with this section is to include all notable events that should be grouped and alerted in the NEAP. Under split episodes by, you can select how you wish for your notable events to be split into individual episodes. This can be any field in the itsi_tracked_alerts data, I typically split by service_name.

    For break conditions, you can configure when an episode should end. I typically do “if the flow of events is paused for 600 seconds”, the idea here being, if there are no notable events being created and flowed into the episode for 10mins, then the problem has been resolved, however it ultimately depends on the service.

    Once filled out, you can test your configurations by selecting preview on the same page. This should return all notable events from your correlation search, grouped into episodes based on your split by selection. If you are not seeing results here, ensure that your correlation search is indeed writing events to itsi_tracked_alerts, and that your filtering criteria is valid.

    Troubleshooting episodes not being created.

    If episodes are not being created, make sure that the service, correlation search, and NEAP are all enabled. Additionally, ensure that that the itsi_event_grouping search is enabled, and in the jobs panel, ensure that it is running. To restart the rules engine, you can disable this search for a few minutes, and then re-enable.

    Ensure that your correlation is picking up notable events. Without notable events, there is nothing for the Rules Engine to group. To do this, search the itsi_tracked_alerts index and filter source=<your correlation search>. If there are notable events here, then the issue is most likely due to the Rules Engine.

    Next, check that there are events being written to the itsi_grouped_alerts index. If you have notable events in itsi_tracked_alerts, but no episode info exists in the itsi_grouped_alerts index, then ensure the NEAP is correctly picking up events in the filtering criteria page of the NEAP. Use the preview option in the NEAP editor to ensure that events exist and should be grouped. If there are no results from preview, then check your filtering criteria. If there are results in preview, but no episodes are being created, then there is most likely issue with the rules engine itself.

    Troubleshooting steps

    1. Ensure the ITSI rules engine search is enabled and running (itsi_event_grouping). If needed, you can restart the rules engine by disabling this search for a few minutes, and reenabling it.
    2. Check the ITSI Event Analytics Monitoring dashboard for any glaring issues, including ensuring that only 1 Java process is running. Multiple java processes running can cause issues.
    3. In the SA-ITOA app, there is a itsi_rules_engine.properties file that holds configs specific to the functionality of the rules engine. One setting in particular, exit_condition_messages_contain is important to check.
    • exit_condition_messages_contain = unable to distribute to the peer,might have returned partial results,search results might be incomplete,search results may be incomplete,unable to distribute to peer,search process did not exit cleanly,streamed search execute failed,failed to create a bundles setup with server
    • This setting checks for specific error messages in the internal logs, and if found, stops the rules engine. It’s important to make sure that any ITSI Search Head is NOT generating any of these messages. If these messages are found, then the Rules Engine will stop, and thus episode creation and alerting will be affected.
    • To check if any of these messages are present, the following search can be run (make sure to filter on your ITSI SH hosts):
    • index=”_internal” source=”*splunkd*” “unable to distribute to the peer” OR “might have returned partial results” OR “search results might be incomplete” OR “search results may be incomplete” OR “unable to distribute to peer” OR “search process did not exit cleanly” OR “streamed search execute failed” OR “failed to create a bundles setup with server”

    Using custom ITSI index names?

    If you’re using custom index names outside of itsi_tracked_alerts, like my_org_itsi_tracked_alerts, ensure that all macros have been updated to include these index names.

    If you’re on ITSI 4.11 or lower and are using custom index names, you will need to take additional steps. In the SA-ITOA app, the itsi_rules_engine.properties file will need to be updated to include these custom index names, as the default index names are hardcoded in the java build of ITSI, and can cause delays in episode creations, or duplicate episodes. This has been raised to Splunk and will be updated to use a macro in a future release. Until then, the following stanza can be added in SA-ITOA/local/itsi_rules_engine.properties to include the custom index names.

    [default]
    index_name = <your custom itsi_grouped_alerts index name>

    # Search to retrieve missed events to backfill
    backfill_events_search = search (`itsi_event_management_index_with_close_events` ) OR ( `itsi_event_management_group_index`) NOT orig_sourcetype=snow:incident | stats first(_time) AS _time first(_raw) AS _raw first(source) AS source first(sourcetype) AS sourcetype count(eval(index=<your custom itsi_grouped_alerts index name>)) AS c_grouped by event_id | where c_grouped=0 | fields _time, _raw, source, sourcetype | sort 0 _time

    grouping_missed_events_search = search (`itsi_event_management_index_with_close_events` ) OR ( `itsi_event_management_group_index`) NOT orig_sourcetype=snow:incident | stats first(_time) AS _time first(_raw) AS _raw first(source) AS source first(sourcetype) AS sourcetype count(eval(index=<your custom itsi_grouped_alerts index name>)) AS c_grouped by event_id | where c_grouped=0 | fields _time, _raw, source, sourcetype

    Additional troubleshooting steps can be found in Splunk documentation or learn more about our Splunk Consulting Services.

     

  • Automate Data Gathering and Evaluation with AWS

    Automate Data Gathering and Evaluation with AWS

    Jay Almers | Senior Cloud Solutions Architect

     

    Whether you are creating usage and billing reports or taking inventory of your AWS account(s) in preparation for an application or service migration, data gathering and evaluation are imperative to making actionable, informed decisions. AWS provides some very powerful tools in their management console to assist their users in capturing the information necessary to make these kinds of decisions; however, searching for and obtaining data from multiple tools and services and combining them into an aggregate report can often be a tedious task.

    To make things more difficult, let’s complicate that process by capturing this same information from multiple accounts. Depending on the volume of data, the number of sources, and the complexity of manipulation you need to perform, the amount of effort needed for data gathering and evaluation of this information could be quite significant. To make things even more difficult, what happens to the data (and the resulting reports) if a number was off by one decimal place unknowingly introduced due to human error?

     

    “Anything you have to do more than twice has to be automated.”

    -Adam Stone, CEO of D-Tools

     

    Automation is used in countless industries, from automotive manufacturing to zoological research, to perform repetitive tasks and decrease the possibility of error due to human intervention. The world of Information Technology is no different. Using the data inaccuracy scenario described above, it is clear to see that the process of collecting large amounts of data from multiple sources in a single account would benefit from automation, if for no other reason than to decrease the amount of time required to generate reports. In a multi-account situation, the time savings are even greater.

    Another benefit of automation is its inherent ability to decrease the chances of introducing errors due to human intervention. That’s all well and good, but you may be wondering how we can automate the process of collecting this data from AWS without utilizing the management console and ultimately making your life easier. Enter the AWS Command Line Interface (CLI), an amazing tool that can be used for everything from service provisioning to data collection. With a little bit of programming and knowledge of how the AWS CLI works, we can automate the process of collecting information from multiple sources and data points in an efficient and repeatable manner without the need for tedious and error-prone human intervention.

    Screenshot of an AWS CLI command output displaying VPC details in JSON format.

    To provide a real-world illustration of how this type of automation can be used, I’ll provide some details from a recent engagement TekStream was a part of. Our client, a large organization with many different internal departments, wanted to migrate a large number of non-enterprise AWS accounts into their controlled Enterprise Master Account. In order to migrate these accounts into the correct organizational structure with the necessary services, controls, and policies applied, they needed to determine the service and application requirements as well as gain an understanding of other operational considerations such as dependencies, availability, security, and fault tolerance.

    Capturing this amount of information would have taken a tremendous amount of time if done manually; time that could be better spent on other areas of business. We developed a series of scripts and utilities which utilized the AWS CLI and a few supporting libraries for data parsing and manipulation. The scripts collected this invaluable information and created aggregate reports that simplified the process of comparing accounts and assisted the client in making actionable, data-driven decisions in preparation for migration.

    Two of the main benefits of programmatic data collection, aggregation, and parsing is using native iteration in the form of loops and conditional logic such as if/then/else statements.  For example, we needed to capture information about all the configured Virtual Private Clouds (VPC) in all available AWS regions. Manually, we would have needed to log into the console, change into each region, navigate to the VPC service, then copy and paste each VPC ID into the report. Then, for each VPC ID, we’d need to navigate to the Gateways, Subnets, Route Tables, Network ACL, DHCP Options, Security Groups, and VPC Peering sub-sections to collect all the required information needed to complete the report.

    Instead, once the script was developed, we could simply supply a list of account numbers and let the scripts iterate through all regions and service endpoints, building the reports for us – trimming the required effort from multiple hours of manual data gathering and evaluation to approximately 5 minutes.

    This is just one example of a countless number of use cases for employing automation to simplify your current business processes.

    If you would like more information on automation and how you may be able to leverage it to make your life a little easier,
    contact TekStream today!

  • GTA SAO Workspaces

    GTA SAO Workspaces

    Problem
    The SAO Agency has contractors that are frequently on and off boarding. Due to SAO’s security policies, laptops with specialized tools and security configurations need to be deployed to these resources. There are 4-5 computer images, with 2-3 different hardware profiles to support all the specific needs the contractor roles may require. The time it takes to manage this hardware, get them imaged and shipped is time consuming, and increases the time to get the resources onboarded.

    Key Pain Points
    • Time and cost to on and offboard contractor resources
    • Ensuring security configurations and timely updates of tools
    • Hardware costs for keeping inventory up to date, fixing, and managing accessories
    • Having to have a number of different hardware models with different resources (CPU, RAM, HDD), where having unused inventory drives up cost

    Challenges
    Not having AWS expertise inhouse, the customer was unable to perform the necessary AWS configuration to stand up AWS Workspaces

    Solution
    We leveraged AWS WorkSpaces which offers a number of benefits to address their challenges:

    Scalability and Flexibility: WorkSpaces can easily scale up or down. We are able to quickly provision or deprovision desktops for the SAO contractors without significant upfront investments in hardware

    Security and Compliance: WorkSpaces prioritizes security. Data is stored centrally in the AWS cloud, reducing the risk of data loss from local devices. It supports encryption for data at rest and in transit. We connected Workspaces to SAO’s Active Directory Domain for user access control to ensure that SAO’s configured Group Policies are enforced on the desktop

    Cost Efficiency: With AWS WorkSpaces, you pay on a monthly basis for the number of WorkSpaces in use. This eliminates the need for large upfront hardware investments and reduces ongoing maintenance costs that SAO had been spending

    Centralized Management: SAO Administrators can manage WorkSpaces centrally through the Management Console. They can define user policies, allocate resources, and enforce security settings across multiple WorkSpaces, making it easier to maintain and control the desktop environment

    High Performance: WorkSpaces offers different instance types to cater to various performance requirements. We can tailor the appropriate hardware configurations for the contractors workload, ensuring smooth and responsive desktop experiences

    Overall, AWS WorkSpaces provided SAO with enhanced flexibility, security, scalability, and cost-efficiency, enabling

  • Setting up MFA with SNS and Java

    Setting up MFA with SNS and Java

    Rimpi Mathur | Technical Architect

    To provide better security and avoid unauthorized access to your applications, you should enable multi-factor authentication (MFA). This blog explains how to set up MFA using AWS APIs and services.

    What is MFA?

    With identity theft and cybercrime on the rise, multi-factor authentication (MFA) is a good way to improve your account security. MFA adds an additional layer of identity validation along with the basic login credentials. It is a unique number that is valid for a short duration of time and is sent to a device of your choice. This number is typically sent to an email address or cell phone number, but it can also be accessed using a specialty app.

    Technology

    We will be using the following technologies to achieve our goal.

    • • AWS SNS API
    • • Java 1.8 or higher
    • • Eclipse or any other IDE
    • • Maven for code build

     

    First, let’s look at sending MFA using the AWS admin console.

    Sending text message to cell phone using Amazon Simple Notification Service


    • • AWS Console Settings


    1.  Under “Simple Notification Service,” click on Test Messaging (SMS).
    2.  Make sure your account is not in the SMS sandbox; in sandbox mode, you can send a maximum of 10 text messages. Submit a request for Service Limit Increase. This normally takes a day to be approved by AWS.
    3.  From the console, purchase an origination number. This is a 10-digit toll-free number that will be used for sending out messages. This number is assigned by AWS.
    4.  To send a message from the console click on “Publish Text Message.”
      AWS SMS mobile text messaging  setup dialog box.
    5. Enter all the information in each box.
    Publish SMS message, Details in AWS console settings.
    Destination phone number
    Country-specific attributes, Entity ID, Template ID in Java.

    Now that we know how to send an MFA code from the console, let’s integrate this into our code.

    We will see how we can send the MFA code post-login from our codebase.

    Generate MFA code using Java

    There are many ways of creating a  6-digit number. One of the simplest ways is to use the Random() method in Java.


    • • Code for sending messages using SNS.


     

      1. We will import six packages that are required for defining the settings in AWS.

    com.amazonaws.regions.Regions;

    com.amazonaws.services.sns.AmazonSNSAsync;

    com.amazonaws.services.sns.AmazonSNSAsyncClientBuilder;

    com.amazonaws.services.sns.model.MessageAttributeValue;

    com.amazonaws.services.sns.model.PublishRequest;

    com.amazonaws.services.sns.model.PublishResult;

      1. Sample code for creating a text message.

    There are three AWS attributes that need to be set: region, maximum cost, and SMS type.

    public void sendSMS(String message, String phoneNumber) {

    // Initializes the message, phone number, aws attributes, and sends the code.

    try {

    PublishResult result = initSnsClient()
         .publish(new PublishRequest()
    .withMessage(message)
    .withPhoneNumber(phoneNumber)
    .withMessageAttributes(initSmsAttributes()));

    } catch (Exception e)

    }

    // The AWS region you will use for sending text messages; this region should be the same region that you moved to production mode (from sandbox) in the initial setting from AWS console.

    private AmazonSNSAsync initSnsClient() {

    AmazonSNSAsync snsClient =  AmazonSNSAsyncClientBuilder.standard()

    .withRegion(Regions.US_EAST_2).build();

    return snsClient;

    }

    // Sets the max price for sending each text message.

    private Map<String, MessageAttributeValue> initSmsAttributes() {

    if(smsAttributes == null) {

    smsAttributes = new HashMap<String, MessageAttributeValue>();

    smsAttributes.put(“AWS.SNS.SMS.MaxPrice”, new MessageAttributeValue()

    .withStringValue(“0.10″))

    .withDataType(“Number”));

    // Sets the type to Promotional (non-critical) or Transactional (message sent with high priority).

    smsAttributes.put(“AWS.SNS.SMS.SMSType”, new MessageAttributeValue()

    .withStringValue(“Transactional “))

    .withDataType(“String”));

    }

    return smsAttributes;

    }

        1. This code can easily be called from any other class for sending the text message.

        • • Sending MFA code using E-mail


    An e-mail can be sent using the helper class JmsTemplate

    private void addMessageToQueue(final Email email) {

    try {

        jmsTemplate.send(new MessageCreator() {

    @Override

    public Message createMessage(Session session) throws JMSException {

    return session.createObjectMessage(email);

    }

    });

    }

    catch (Exception e) {

    throw e;

    }

    }

    }

    Contact us for more help setting up MFA with SNS and Java!