Author: dystrick

  • Populating User Data for the Chargeback App

    Populating User Data for the Chargeback App

    By: Jeff Rabine | Splunk Consultant

    The Chargeback App is designed to help you identify how many SVCs your organization is using by Business Units and Departments. Recently I had a customer that wanted to define a Business Unit as a Vice President and a Department as a Director who reports to the VP. This is completely doable if you are ok with using the original field names that the chargeback app uses. The hardest part about configuring the Chargeback app is getting the data collected and formatted for the chargeback app to use. This blog post is not specifically about the Chargeback App. This blog is about collecting, formatting and populating the user data needed for the chargeback_user_2_bunit_csv_lookup.

    The challenge I had with collecting the user data is the data was not all in one place. I had an index that contained user data, and I had a CSV that identified Directors and VPs. What I needed though was a list of users and their associated Director and VP.

    I have formulated an example that contains less than 20 users, but this example is working in a production environment that contains over 50,000 users.

    In my example I use these two CSVs:

    Employee_List.csv

    Populating user data employee list csv

    management.csv

    A small table mapping VP IDs to Director IDs, used to enrich employee data for business unit association in chargeback workflows.

    The first step is to combine the two data sources and export them as a new CSV. We do this by using the lookup command.

    Screenshot of a Splunk search using lookup commands to merge employee data with management.csv for VP and Director mapping, displaying a preview of the enhanced employee list.

    Now that we have the data in a single CSV we can iterate through it to figure out who everyone’s VP and Director is. We do this by using the same lookup over and over as shown below. In this example, we only have to do it three times. In this real-world example, I did this eight times to fully populate the data.

    Splunk screenshot showing the use of nested lookup logic to retrieve manager hierarchy layers (Manager1 and Manager2) and align them with VP and Director values across employee records.

    As you can see, we now have much more data, but it is a mess. So lastly, we will coalesce the Director and VP data and we will rename the fields to match the Chargeback App requirements.

    Splunk interface showing a fully enriched user dataset with business unit and department IDs resolved via VP and Director coalescing logic, ready for use in the Chargeback App.

    As you can see, we now can identify the biz_unit or (VP) and biz_dep or (Director) for all our users.

    I hope this article will give you some ideas to when populating user data for the Chargeback app or help you iterate through a lookup multiple times to perhaps create an organizational chart. Happy Splunking!

    Want to learn more about lookups or the Chargeback App? Contact us today!

  • Tuning Your AWS WAF Configuration in Terraform

    Tuning Your AWS WAF Configuration in Terraform

    How to Implement Bot Control, Scope-down Statements, Allow US-only traffic, and/or Whitelist Exceptions to Rules Based on Whitelisted IPs or Header Information

    By: Brandon Prasnicki | Senior Cloud Architect

    AWS WAF is a Web Application Firewall that helps protect your web applications or APIs against common web exploits and bots that may affect availability, compromise security, or consume excessive resources. In this article, I describe and show the AWS WAF configuration in Terraform for a few use cases that may come in handy for your implementation.

    The first is bot control. Reducing bot traffic is rather simple when using WAF in AWS.  There is a managed rule you can use and documentation on how to create exceptions to allow certain traffic. Sometimes implementing the rules with Terraform can be a little tricky; this article contains an example use case you can use to help with your implementation.

    Amazon AWS describes this feature here and has documentation about the AWSManagedRulesBotControlRuleSet WAF rule here.

    Here are the steps on how the solutions were implemented.

    First, adding the rule was as straightforward as any other managed rule addition following the link below (The terraform is also included at the bottom of this article)

    With this enabled, we can quickly see bot traffic being rejected by navigating to:

    AWS WAF Bot Control diagram.

    And also:

    AWS WAF overview.

    And scrolling to the bottom of sampled requests and selecting the ManagedRulesBotControl block metric:

    AWS WAF ManagedRulesBotControl screenshot.

    Some of these blocks are false positives and may require whitelisting. For this, I have an IP set that I am using for known hosts and clients.

    Known hosts and clients IP screenshot.
    AWS WAF IP sets.

    I added the IPs to the IP set and used this IP set to whitelist rule for known hosts:

    IPs added to the IP set and used this IP set to whitelist rule.

    This whitelist IP set list was also used to whitelist IPs of non-US users to bypass the ‘Non US’ Geo Code Match Statement (DisallowNonUSTraffic seen in the Terraform below).

    However, not all requests were coming from known server hosts. Some requests were coming from client machines’ Tableau Desktop applications where the IPs were not static or always known. For this, I created a scope-down statement to grab the header information and allow anything that starts with ‘Tableau Desktop’ for the user-agent.

    Here is a screenshot of what this looks like in the console following this breadcrumb:

    AWS WAF - Web ACLs - ManagedWAFv2 - AWSManagedRulesBotControlRuleSet.

    Then you can click edit in this rule set to add a ‘Not Scope-down statement’ that will appear like this:

    NOT Scope-down statement.

    On the left you can see the blocked request with header information alongside the rule:

    Blocked request with Header info.

    Here is the Terraform for the IP set for whitelisting:

    Terraform for the IP set for whitelisting.

    Below is the entire Terraform for the web ACL.

    Here you will see:

    1. The implementation of the out-of-the-box AWSManagedRulesKnownBadInputsRuleSet_rule, AWSManagedRulesAmazonIpReputationList and AWSManagedRulesWindowsRuleSet.
    2. The exception rule to allow any whitelisted IPs.
    3. Disallowing any non-US traffic (not already included in whitelisted IPs).
    4. The web ACL with the whitelisted IP set referenced along with the scope-down statement in the AWSManagedRulesBotControlRuleSet.
    5. The scope-down statement to allow the Tableau Desktop communication.
    Terraform code defining an AWS WAFv2 Web ACL with two managed rule groups: KnownBadInputsRuleSet and AmazonIpReputationList, including CloudWatch metric configuration and override actions.
    Continuation of Terraform WAF rules including WindowsRuleSet, a whitelist IP set rule, and a geo-blocking rule for non-US traffic, each with visibility configuration and action settings.
    Terraform code configuring a bot control rule using AWSManagedRulesBotControlRuleSet with an exception for requests from Tableau Desktop identified by user-agent, including nested scope-down statements and visibility configuration.

    (Click here to download PDF of the code)

    These are just a few examples that can help manage your AWS WAF configuration in Terraform. The analysis of what rules to use and how to use match statements and scope-down statements might be the hardest part.

    TekStream can advise and help you implement these features and of course, assist with your implementation project or even support you in a ‘Consulting as a Service’ manner. Reach out today to see how we can help!

  • Top 4 Common Issues when Configuring Splunk Connect for Syslog (SC4S)

    Top 4 Common Issues when Configuring Splunk Connect for Syslog (SC4S)

    By: Greg Becker | Senior Splunk Consultant

    Splunk Connect for Syslog (SC4S) is a containerized version of syslog-ng that has out-of-the-box configurations for many known Sources, and it’s also supported by Splunk. The implementation is different than a classic syslog-ng install that is typically installed on a host which receives syslog traffic and then it writes out logs to a filesystem to then be picked up by a Splunk Universal Forwarder and then sent to a Splunk indexing tier. SC4S uses HTTP Event Collector (HEC) to send events directly to the receiving Splunk instance without the need to write the logs to disk. We help customers with issues when configuring Splunk Connect for syslog (SC4S) implementations and have noticed a few common areas where missteps can occur.

    Here are the top 4 issues when configuring Splunk Connect for syslog:

    • 1. Read through the entire set of docs
    • 2. Decide if you’ll use out-of-the-box indexes
    • 3. Important HEC token settings
    • 4. What to do if your Source isn’t listed

    1. Read the docs

    The most common issue that I see is that users don’t read the docs that are available before attempting to install and configure SC4S. There is a ton of great information out there. Sometimes it takes a few passes through the docs to understand various concepts, but the developers have done a great job of getting excellent material out there. Nearly 10/10 times when I’m helping a customer this is the first place I’ll check to see (or confirm) that the necessary configs are spelled out well. There are document sections for based configurations (for various container flavors), quick start guides, all the OOTB sources, troubleshooting, FAQ and much more.

    Check out the docs here and make sure that you select the version that you are currently using:

    https://splunk.github.io/splunk-connect-for-syslog/main/

    2. Out-of-the-box or custom indexes

    SC4S is pre-configured to map each sourcetype to a typical index. For new installations, it is best practice to create the indexes in Splunk when using the SC4S defaults. SC4S can be easily customized to use different indexes if desired.

    When you decide to use custom indexes or maybe you’ve already been adding data to custom indexes prior to implementing SC4S, you can easily override the default index values for the source by editing a configuration file called splunk_metadata.csv which contains a mapping using the key value for a source and then specifies what metadata field to overwrite, index in this case and then the value for index. Here is a typical example entry below.

    juniper_netscreen,index,ns_index

    See the configuration pages (in the docs that you’re supposed to read) here:

    https://splunk.github.io/splunk-connect-for-syslog/main/configuration/#sc4s-metadata-configuration

    3. Important HEC token settings

    It is very important that you understand the configuration choices that you make when creating your HEC token on the Splunk receiving instance. There is a lot of info in the docs regarding endpoints and loadbalancer settings but the settings that are most often set incorrectly are for the indexes. Ensure the token has access to place events in main, em_metrics, and all indexes used as event destinations.

    NOTE: It is recommended that the “Selected Indexes” on the token configuration page be left blank so that the token has access to all indexes, including the lastChanceIndex. If this list is populated, extreme care must be taken to keep it up to date, as an attempt to send data to an index not in this list will result in a 400 error from the HEC endpoint. Furthermore, the lastChanceIndex will not be consulted in the event the index specified in the event is not configured on Splunk. Keep in mind just one bad message will “taint” the whole batch (by default 1000 events) and prevent the entire batch from being sent to Splunk.

    Check the docs here:

    https://splunk.github.io/splunk-connect-for-syslog/main/gettingstarted/#configure-the-splunk-http-event-collector

    4. What to do if your source isn’t listed

    SC4S comes pre-configured to support over 50 different Vendors and many more Sources including data formats such as CEF and LEEF. You can refer to the docs to check if the Source you want to onboard is already included, however if it’s not, you can simply head over to the GitHub project for SC4S and create a new “Issue” and provide a redacted packet capture (PCAP) of the source as well as any information that you have about the Vendor and then Splunk will develop the appropriate parser for the Source and include it in the next release. This process not only helps you, but it also potentially helps other customers that may want to onboard that Source as well.

    Sources:

    https://splunk.github.io/splunk-connect-for-syslog/main/sources/

    Create a new Issue:

    https://github.com/splunk/splunk-connect-for-syslog/issues

    SC4S can be a very straightforward and simple way to implement syslog data collection. If you can follow these guidelines and avoid the gotchas you won’t have any issues when configuring Splunk Connect for syslog.

    If you have any additional needs or questions please contact TekStream and we’d be happy to assist you. 

  • Troubleshooting Null Field Values and Trailing Spaces

    Troubleshooting Null Field Values and Trailing Spaces

    By: Jeff Rabine | Splunk Consultant

    In my career as a Splunk Consultant, I have run across numerous occasions where I was thrown off by what I thought were null field values or trailing spaces where I didn’t expect spaces to exist. This can be confusing and even lead to inaccurate results. I will do my best to demonstrate these to you but in a real-world scenario, it’s never as obvious as a blog post.

    First here is an example of a search that is counting IP Addresses with an “Unknown” status. As you can see the results show zero:

    Empty String and Trailing example.

    Without knowing the data, the person writing this search could easily be done here. However, when we take a closer look, we notice there are 9 events with blank entries for Known_Bad_IP. But how could that be?!  We did a fillnull!

    Field values and trailing known for bad IP.

    The fillnull did not work because the fields are not null they contain empty strings. In this case, we can fix this by adding a replace command. To replace these empty string fields with Unknown:

    Field values or trailing spaces.

    As you can see now the search is working as expected.

    In my next example, we are coalescing IP addresses from two sources. As you can see, we are sorting the IP_Address column but it’s not sorting correctly.

    Empty string and trialing coalescing IP addresses.

    If we do an eval we can count the length of the field and as you can see, we have 10 character IP Addresses that are counting out as 11 characters.

    Empty string and trailing eval character length.

    Now if we look at the raw data, we can see that for some reason there is a trailing space on some but not all the IP addresses.

    Empty string and trailing space on some IP addresses.

    To fix this issue we would need to either fix the existing field extraction or add a new inline field extraction. Another option would be to use the trim command to trim the trailing space.

    Empty string and trailing inline field extraction.

    Empty string and trailing inline field extraction.

    Trim:

    Again, these are just lab examples of field values or trailing spaces. I experienced similar issues in the real world, but the errors were hiding in millions and billions of events. Sometimes you will run into cases where reports or field extractions are accurate 99.9% of the time but once a month a log source comes in that doesn’t work with your field extraction and causes the report to have inaccuracies. I hope this article will remind you to know your data and never assume anything. Happy Splunking!

    Want to learn more about any of these commands?  Contact us today!

  • Creating Custom Splunk Commands to Change Cron Schedules

    Creating Custom Splunk Commands to Change Cron Schedules

    By: Antonio Patino Noguez | Splunk Consultant

    In a customer environment, we noticed search latency at the top of every hour. After troubleshooting, I noticed that scheduled searches were set to run at the same time. Although it is simple to change the cron schedule for these searches through Splunk web, there were way too many searches, making the process painful. Using some filters and a REST call in a search, I could grab different batches of scheduled searches – but then I wondered, how can I change the cron schedules of these batches via search?  Splunk gives us the ability to create custom search commands. To create a custom command, you need to define the command in a commands.conf file. After the line of SPL is determined to be a custom command, Splunk checks the commands.conf and runs the corresponding Python script. Splunk passes each pipe of SPL through the script through STDIN and writes them out through STDOUT. Splunk then returns to the main search and completes the search. So, first things first, I needed to create both a commands.conf file and a Python script. By opening the text editor of my choice, I simply defined my command in a stanza and filled out the necessary attributes.  Here is an example of that:            [custom_command]            filename=cron_python.py            chunked=true            python.version=python3 Next, I need to create my Python script. The goal here was to collect all the scheduled searches that my search returned and iterate through them while changing their scheduled time to run. Leveraging the Splunk SDK, I have the following loop in my script:        for splrecord in records:            title = splrecord[‘title’]            cron_schedule = splrecord[‘cron_schedule’]            newtracker_update = service.saved_searches[str(title)]            #kwargs = {“cron_schedule”: self.cron_schedule}             kwargs = {                “cron_schedule”: self.cron_schedule,            } Now it’s time to bundle these files in a custom app. One important thing to remember to add to the app is the splunklib library. This is so the Python script can leverage the Splunk SDK. Since I gathered the schedule searches in “batches” via SPL, I could leverage my custom command to change the cron schedules just by running my search. It works like magic! In conclusion, creating custom commands can really help tackle specific tasks that may not be easily handled with out-of-the-box Splunk enterprise. This allows for flexibility to handle virtually all issues that may arise in your Splunk environment. For further reading, here are The 3 Most Common Splunk Issues and How to Solve Them.

    Got a unique Splunk issue? TekStream can help you solve it. Contact us today. 

  • Leveraging Accounts Payable Automation to Address and Overcome Challenges

    Leveraging Accounts Payable Automation to Address and Overcome Challenges

    By: Andrew Blackman | Founder & CEO of EZ Cloud, a TekStream Partner

    Accounts Payable (AP) is an integral part of the way organizations operate. While recognized as a support in maintaining profitability, AP departments have traditionally completed processes manually. Why though? It can be inefficient, prone to error, and can be costly. Unfortunately, many companies experience the same AP challenges:
    • • While your particular business processes have evolved and progressed, your accounts payable methodology may still rely heavily on paper. Even if invoices are received via email, many organizations still require that invoices to be printed, processed, approved, and stored manually. This further complicates an already tedious process.
    • • Paper dependency exists even though companies have an ERP system (or multiple ERP systems, including but not limited to E-Business Suite, PeopleSoft, and JD Edwards). ERPs are meant to handle the accounts payable process in an efficient manner.
    • • Employees may only be proficient in one system and not others. Who has time to learn yet another system?
    • • Other employees need to process or approve invoices, but they don’t have ERP authorization.
    Maintaining the accounts payable methodology the same way “it’s always been done” is a risk. However, maintaining manual processes may be stifling organizational growth. AP is a historically manual and time-consuming process that often contributes to delays. While other aspects of business have been made more efficient through the use of automation, often, AP departments have still had to rely on manual processes. Accounts Payable automation offers an improved user experience and rich toolset to streamline invoice data entry, focusing on the automation of invoice data input.  This high level of automation will lower the number of data elements keyed, which in the end reduces the number of possible clerical errors. Leadership is seeing a greater need to keep up with the times and transition to leveraging Accounts Payable automation technology in improving their tech stack. An organization having visibility into AP via an automated system is incredibly helpful for promoting growth and development. Investments previously made in other areas of your business can be leveraged.
    • • Integration points, based on standard defined points within your ERP, quickly retrieve the purchase order and vendor information. From there, it will match the data to the invoice often before a user has any visible interaction with the invoice.
    • • Any current validation routines present in your ERP are honored, as data is validated before its delivery to the ERP for ingestion.
    • • Any existing approval hierarchies from the ERP can be reused for workflow approvals which can often be simply approved via email.
    • • Your existing corporate security model and infrastructure can be used to enforce authentication and authorization of invoice information.
    • • Invoice-related documentation can be attached to the invoice, and subsequently viewed in the ERP.
    Integrating with your existing ERP(s), EZ Cloud’s Accounts Payable automation solution supports your current workflow needs while digitizing and automating processes. Recognizing that no ERP is ever deployed “out of the box,” EZ Cloud and TekStream work together to tailor the solution to your specific needs. Once manual processes are left behind, your AP department will quickly thank you!

    Contact TekStream today to learn more about how our team can help to solve challenges in the accounts payable process.

  • Phishing Playbook Template Walkthrough

    Phishing Playbook Template Walkthrough

    By: Forrest Lybarger | Senior Splunk Consultant

    Your analysts should spend more time doing analysis and investigation. Our Splunk SOAR (Cloud) Phishing playbook template walkthrough offers a visual platform for generating a playbook without writing code, so you can automate security procedures.

    Below is a picture of the top-level phishing playbook template. I used comment blocks to note what should happen where in the playbook because playbook blocks require an existing playbook to name them and don’t allow notes. It is intended to give guidance on the process flow. Making templates for the sub-playbooks is largely unnecessary since those can vary between customers, and most are simple linear playbooks. I will cover the playbook going top to bottom.

    Top-level Splunk playbook screenshot.

    Email Extraction:

    Extract block for email file. This could change depending on how the phishing emails are being sent to Phantom. Extract IOC is a common method of parsing. The output will be various artifacts, for example, Email, URL, and Domain. Use extract IOC for .eml files.

    Precheck:

    Check email against a list of checks for whitelisting and blacklisting. This will save time and resources. Use custom lists to store whitelisted and blacklisted values like domains and IP addresses. Many internal emails can be whitelisted this way, especially if users are the ones flagging phishing emails.

    Whitelisted:

    Build a sub-playbook to process whitelisted events. It can perform many actions, including sending a notification email to the submitter or ticket creation coupled with immediate closure for record keeping. Talk to the customer about what they want to do.

    Blacklisted:

    Add a sub-playbook here to process blacklisted emails. Example actions to run: notification emails, ticket creation, isolation/triage. Talk to the customer about what they want to be done here.

    Other:

    Below, the playbook will branch out into multiple sub-playbooks to evaluate whichever items the consultant or customer deems helpful in determining the risk score of the email. They are broken up to maintain the readability of the top-level playbook while giving a detailed view of how the process works. A ticket in a 3rd party system like ServiceNow or JIRA can be opened here to record operations runs and their results (if the customer uses such a service). Don’t put all these sub-playbooks into a single playbook; that would be less readable and could result in one small part of the playbook interfering with more parts. Isolate them to improve readability and make maintenance easier.

    Domain Evaluation:

    Evaluate the domain artifacts created by using extract IOC. Discuss with the customer what API they will use to perform these checks. I recommend steering them toward any API that has an app on Phantom.

    If the API they choose doesn’t have an app, then the consultant will have to code the API call themselves. Not only is this time-consuming, but once the consultant rolls off the project, someone else will have to maintain that code. The customer will likely not have control over the changes made to the API, so if the API changes, whoever maintains the code will have to edit it. Phantom apps are maintained by Splunk or the API developer, so the customer won’t have to do much maintenance.

    URL Evaluation:

    Evaluate URL artifacts in a sub-playbook by sending the URLs as inputs. Again, try to use an API with an existing Phantom app. If the API doesn’t have an entry for the URL, a submission should be run. Waiting for this submission to be finished will take time (5-15 min), so it would be better to just submit it in the playbook and have a manual review check for the score later when it’s done processing. Otherwise, custom code will have to be run to wait for the results, which will stall the whole playbook and could cause a backlog of emails.

    IP Evaluation:

    Evaluate the IP address of the email sender. When parsing .eml files with extract IOC, the IP address can be found in the Authentication-Results field in the email artifact. An ipv4 extract block can get the IP address without custom code. Customers might want multiple kinds of data to be evaluated here, like geolocation and reputation. Splunk has its own app for IP geolocation, which gives different fields for latitude, longitude, city, state, country, address, etc. A custom list will come in handy to whitelist/blacklist locations.

    File Evaluation:

    Use a sub-playbook to evaluate and/or detonate any attached files. Ignore image files since they won’t run anything and will be too common to process them all. Search for pre-existing entries using the hash included in the vault artifact corresponding to the file. If there isn’t an existing entry, submit the file; similar to the URL submissions, it is better to have the manual review check the score after the submission is done processing.

    Score Assessment:

    Using results from the branching eval playbooks, determine an overall score or a group of scores to be evaluated against thresholds in the following decision block. Example methodologies: weighted average, highest, weighted average of highest values. Use custom lists for weights.

    Post check:

    Evaluate the risk of the email by comparing it to thresholds inputted into this block. There are many different options to go with, but it will probably be best to start with low thresholds and increase them depending on volume and accuracy.

    Safe:

    Use another sub-playbook for processing emails determined to be safe. Example actions: send notification emails, open/close tickets, etc. Discuss these actions with the client.

    Dangerous:

    Use another sub-playbook for processing emails determined to be dangerous. Example actions: send notification emails, open/close tickets, etc. Discuss these actions with the client.

    Want to learn more about creating a phishing playbook template in Splunk SOAR (Cloud)? Contact us today!

  • Configuring Splunk-Connect-for-Syslog with HTTP Event Collector Using Podman

    Configuring Splunk-Connect-for-Syslog with HTTP Event Collector Using Podman

    By: Oluwaseun Oke

    Splunk Connect for Syslog is an open source packaged solution for getting data into Splunk. It is based on the syslog-ng open source Edition (Syslog-NG OSE) and transports data to Splunk via the Splunk HTTP event collector (HEC) rather than writing events to disk for collection by a Universal Forwarder.

    According to Splunk.github.io “Splunk Connect for Syslog is a containerized distribution of syslog-ng with a configuration framework designed to simplify getting syslog data into Splunk Enterprise and Splunk Cloud. Our approach is to provide a runtime-agnostic solution allowing customers to deploy using the container runtime environment of choice.”

    Diagram titled “The Magic of SC4S Log-Path Filters” showing Cisco ASA firewall events flowing via TCP/UDP port 514 into SC4S (Splunk Connect for Syslog), which applies a Cisco ASA filter and sends data to Splunk using the HEC (HTTP Event Collector) protocol. Emphasizes the process: Identify > Parse > Format.

    For this demo we are going to use two (2) servers; Podman/SC4S server and Splunk (all-in-one) server.

    Podman: Podman is a daemonless, rootless container engine developed which allows containers to be run by non-root users. The best recommendation is to use CentOS 8. As such there are certain configurations that are necessary to be ensure a seamless installation.

    Splunk (aio): We can use the regular amazon linux instance or Centos 8 but we will be using the regular Amazon linux for this demo

    Splunk Installation
    Install Splunk and have it running using regular Splunk installation.
    Configuring SC4S using Podman.

    Podman Configuration

    Please run the following commands below to update the Centos 8 with the necessary updates (please note that this only necessary for Centos 8) on the sc4s/podman server.

    # cd /etc/yum.repos.d/
    # sed -i ‘s/mirrorlist/#mirrorlist/g’ /etc/yum.repos.d/CentOS-*
    # sed -i ‘s|#baseurl=https://mirror.centos.org|baseurl=https://vault.centos.org|g’ /etc/yum.repos.d/CentOS-*

    After which we are going to swap the centos-linux-repos to the centos-stream-repos (Appstream) for Centos 8 which is used for setting up the Podman and we are going to sync it the Appstream repos we are replacing.

    # dnf –disablerepo ‘*’ –enablerepo=extras swap centos-linux-repos centos-stream-repos
    # dnf distro-sync

    Terminal output showing the CentOS 8 system swapping out centos-linux-repos for centos-stream-repos using the dnf package manager. Confirms installation and removal details.

    ******Switch to your Splunk Server****

    Create Indexes

    SC4S is pre-configured to map each sourcetype to a typical index. Since this is a new installation, it is best practice to create them in Splunk when using the SC4S defaults as shown below. Please note that SC4S can be easily customized to use different indexes if desired.

    • • email
    • • epav
    • • epintel
    • • infraops
    • • netauth
    • • netdlp
    • • netdns
    • • netfw
    • • netids
    • • netlb
    • • netops
    • • netwaf
    • • netproxy
    • • netipam
    • • oswin
    • • oswinsec
    • • osnix
    • • print
    • • em_metrics (Optional opt-in for SC4S operational metrics; ensure this is created as a metrics index)

    Please go to the Splunk web and confirm if the indexes have been created.

    Splunk index list interface showing various system indexes such as _thefishbucket, em_metrics, email, and others. Each row includes edit options, index type, source type, storage path, and status indicators.

    Configure the Splunk HTTP Event Collector

    We are going configure the Splunk HTTP Event Collector by creating a HEC token and make it global to help stream the data from the SC4S/Podman container to the Splunk Server indexers. It is strongly recommended that SC4S traffic be sent to HEC endpoints configured directly on the indexers rather than an intermediate tier of HWFs. It is recommended that the “Selected Indexes” on the token configuration page be left blank so that the token has access to all indexes, including the “lastChanceIndex. If this list is populated, extreme care must be taken to keep it up to date, as an attempt to send data to an index not in this list will result in a 400 error from the HEC endpoint.

    Switch to the SC4S/Podman Server to begin the installation of the Podman container

    Need to enable and the update the powertools to help with the installation of the “Podman”

    # sudo dnf config-manager –set-enabled powertools

    # sudo dnf -y update

    We going to confirm if we have the container-tools needed to install Podman

    # sudo dnf module list | grep container-tools

    Terminal output of sudo dnf module list | grep container-tools, listing multiple versions of the container-tools module for RHEL 8. Each version includes tooling like podman, buildah, and skopeo.

    After the confirmation, we can now install Podman

    # sudo dnf install -y @container-tools 

    Always confirm the installation by checking the Podman version by running:

    # podman version

    Terminal output showing the installed Podman version. Lists version 4.0.2, API version, Go version, build timestamp, and OS architecture.

    CONGRATS!!!!!!

    Now we would want to confirm that we can check the version of the OS from Podman:

    # podman run -it –rm alpine sh

    / # cat /etc/os-release

    Terminal session of running an Alpine Linux container using Podman. Shows successful image pull and startup. Inside the container, the /etc/os-release file is displayed, confirming Alpine Linux v3.15.4.

    Now you can get out of the Podman container  to the OS level by typing:

    # exit

    Implement a Container Runtime and SC4S

    The following script can be saved in a GitHub repository which can be called with “wget” in the cli:

    #!/bin/bash
    # 14/03/2022 John Barnett
    # Script created on / for CentOS 8
    # 21/07/2021 – Added TLS Remix, added TLS listener – note creates a default cert below so edit / remove as required
    # 14/03/2022 – Updated default container pull to version 2
    ### Based on quick start here – https://splunk.github.io/splunk-connect-for-syslog/main/gettingstarted/podman-systemd-general/
    # Set URL and Tokens here
    # SplunkCloud Example
    # HEC_URL=”https://http-inputs-MYSTACKNAME.splunkcloud.com”
    HEC_URL=”https://3.134.109.163:8088″
    HEC_TOKEN=”e5f1032d-b0a2-4cd2-8010-2411ce6b7552″
    #hostnamectl
    #hostnamectl set-chassis server
    #hostnamectl set-location rack1
    #hostnamectl set-hostname sc4sbuilder
    hostnamectl

    ################################################################################
    ########### Dont edit below here, unless you know what you are doing ###########
    ################################################################################
    red=`tput setaf 1`
    green=`tput setaf 2`
    yellow=`tput setaf 3`
    reset=`tput sgr0`
    echo “${yellow}Check date and TZ below!${reset}”
    date
    echo “${yellow}Updating Firewall Rules${reset}”
    #Show original state
    firewall-cmd –list-all
    #Splunk ports
    firewall-cmd –zone=public –add-port=514/tcp –permanent # syslog TCP
    firewall-cmd –zone=public –add-port=514/udp –permanent # syslog UDP
    firewall-cmd –zone=public –add-port=6514/tcp –permanent # syslog TLS
    firewall-cmd –zone=public –add-port=5425/tcp –permanent # syslog
    firewall-cmd –zone=public –add-port=601/tcp –permanent # syslog
    firewall-cmd –reload
    #Check applied
    firewall-cmd –list-all
    dnf install -y conntrack podman
    echo “
    ## Edited with JB Splunk Install script by magic
    net.core.rmem_default = 17039360
    net.core.rmem_max = 17039360
    ” >> /etc/sysctl.conf
    sysctl -p
    echo “
    ## Created with JB Splunk Install script by magic
    [Unit]
    Description=SC4S Container
    Wants=NetworkManager.service network-online.target
    After=NetworkManager.service network-online.target
    [Install]
    WantedBy=multi-user.target
    [Service]
    Environment=”SC4S_IMAGE=ghcr.io/splunk/splunk-connect-for-syslog/container2:2″
    # Required mount point for syslog-ng persist data (including disk buffer)
    Environment=”SC4S_PERSIST_MOUNT=splunk-sc4s-var:/var/lib/syslog-ng”
    # Optional mount point for local overrides and configurations; see notes in docs
    Environment=”SC4S_LOCAL_MOUNT=/opt/sc4s/local:/etc/syslog-ng/conf.d/local:z”
    # Optional mount point for local disk archive (EWMM output) files
    Environment=”SC4S_ARCHIVE_MOUNT=/opt/sc4s/archive:/var/lib/syslog-ng/archive:z”
    # Uncomment the following line if custom TLS certs are provided
    Environment=”SC4S_TLS_MOUNT=/opt/sc4s/tls:/etc/syslog-ng/tls:z”
    TimeoutStartSec=0
    ExecStartPre=/usr/bin/podman pull $SC4S_IMAGE
    ExecStartPre=/usr/bin/bash -c “/usr/bin/systemctl set-environment SC4SHOST=$(hostname -s)”
    ExecStart=/usr/bin/podman run \
    -e “SC4S_CONTAINER_HOST=${SC4SHOST}” \
    -v $SC4S_PERSIST_MOUNT \
    -v $SC4S_LOCAL_MOUNT \
    -v $SC4S_ARCHIVE_MOUNT \
    -v $SC4S_TLS_MOUNT \
    –env-file=/opt/sc4s/env_file \
    –health-cmd=”/healthcheck.sh” \
    –health-interval=10s –health-retries=6 –health-timeout=6s \
    –network host \
    –name SC4S \
    –rm $SC4S_IMAGE
    Restart=on-abnormal
    ” > /lib/systemd/system/sc4s.service
    sudo podman volume create splunk-sc4s-var
    sudo mkdir /opt/sc4s/
    mkdir /opt/sc4s/local
    mkdir /opt/sc4s/archive
    mkdir /opt/sc4s/tls

    echo “
    ## Created with JB Splunk Install script by magic
    # Output config
    SC4S_DEST_SPLUNK_HEC_DEFAULT_URL=$HEC_URL
    SC4S_DEST_SPLUNK_HEC_DEFAULT_TOKEN=$HEC_TOKEN
    #Uncomment the following line if using untrusted SSL certificates
    SC4S_DEST_SPLUNK_HEC_TLS_VERIFY=no
    # TLS Config, for McAfee etc
    SC4S_SOURCE_TLS_ENABLE=yes
    SC4S_LISTEN_DEFAULT_TLS_PORT=6514
    #SC4S_SOURCE_TLS_OPTIONS=tls1.2
    #SC4S_SOURCE_TLS_CIPHER_SUITE=ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
    ” > /opt/sc4s/env_file
    echo “${yellow}Generating Cert for TLS${reset}”
    openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -subj “/C=NZ/ST=NI/L=Home/O=SC4S Name/OU=Org/CN=sc4sbuilder” -keyout /opt/sc4s/tls/server.key -out /opt/sc4s/tls/server.pem
    echo “${yellow}Your /opt/sc4s/env_file looks like this${reset}”
    cat /opt/sc4s/env_file
    echo “${yellow}Starting SC4S – This might take a while first time as the container is downloaded${reset}”
    sudo systemctl daemon-reload
    sudo systemctl enable –now sc4s
    # Send a test event
    echo “Hello MYSC4S” > /dev/udp/127.0.0.1/514
    sleep 10
    sudo podman logs SC4S
    sudo podman ps
    # Sleep to allow TLS to come up
    sleep 20
    netstat -tulpn | grep LISTEN
    #### Use command below and then type to test
    #openssl s_client -connect localhost:6514
    #### Use command below for full tls test if required (adjust as needed)
    #podman run -ti drwetter/testssl.sh –severity MEDIUM –ip 127.0.0.1 sc4sbuilder:6514

    Terminal session showing SC4S startup, system port listening status via netstat -tulpn | grep LISTEN, and a podman container for SC4S running. Additional commands for TLS testing and container-based SSL validation are listed.

    After the installation and configuration, we should be able to see the data coming in on the Splunk Server.

    Screenshot of a Splunk search interface showing indexed SC4S logs. The event table includes timestamps, host, source, source type, and log messages such as HEC test events and syslog-ng configuration notices.

    Steps to Creating a custom Index and Filtering

    Custom Index creation

    1. Create the custom index in Splunk before editing sc4s
    2. Move to the sc4s directory: cd /opt/sc4s/local/context
    3. Create a file “splunk_metadata.csv” to create custom indexes and events and place the following in file: vi splunk_metadata.csv
      name of the application, index, name of the index (example is shown below)
      vi splunk_metadata.csv
      test_sourcetype, index, org_test_index
      test_sourcetype, source, mytest
    4. Save the file and restart sc4s service
      # systemctl restart sc4s
    5. Check the status of sc4s to confirm the update made to the splunk_metadata.csv file
      # systemctl status sc4s

    Filtering
    Use case: Exclude a host “sc4s_vendor_product

    1. Move to the sc4s directory: cd /opt/sc4s/local/context
    2. This will involve 2 conf files in the “context” directory: “vendor_product_by_source.conf” and vendor_product_by_source.csv.
      First edit the “vendor_product_by_source.csv” specify the filter and field name

    vi vendor_product_by_source.csv

    f_null_queue,sc4s_vendor_product,"null_queue"

    and save the file

    vi vendor_product_by_source.conf
         filter f_null_queue {
               host(‘192.168.12.1’)
         };

    and save file

    1. Restart sc4s service
      # systemctl restart sc4s
    2. Check the status of sc4s to confirm the update made to the splunk_metadata.csv file
      # systemctl status sc4s

    Use case: Exclude events with the word “deny”

    1. Move to the sc4s directory: cd /opt/sc4s/local/context
    2. This will involve 1 conf file in the “context” directory: “vendor_product_by_source.conf”

    vi vendor_product_by_source.conf

    filter f_null_queue {
         message(‘deny’)
    };

    1. Save the file and restart sc4s service
      # systemctl restart sc4s
    2. Check the status of sc4s to confirm the update made to the splunk_metadata.csv file
      # systemctl status sc4s

    Additional Resources

    Splunk Connect for Syslog
    TechGlimpse Blog
    TekStream Resources
    Splunk
    Podman

    HAPPY SPLUNKING!!!!!!!!!!!!!

  • Automating the Deployment of a Highly Available Hosting Environment in WordPress

    Automating the Deployment of a Highly Available Hosting Environment in WordPress

    By: Jay Almers | Senior Cloud Solutions Architect

    Recently, TekStream was engaged by a customer to develop an automated method of building out a highly available hosting environment that could serve multiple WordPress websites.  The solution should be implemented with Infrastructure as Code (IaC) for simplicity of management and disaster recovery purposes.  Additionally, the customer requested a method for the creation and maintenance of WordPress websites on this hosting environment.  If you read our blog post about automating the process of gathering and evaluating data in your AWS accounts, you know that we are fans of utilizing automation whenever possible to perform repetitive tasks.  After our initial discovery sessions, it was apparent that this project was the perfect candidate for automation using CloudFormation Stacks for provisioning the infrastructure and Ansible for the configuration and management of software.

    WordPress is an open-source Content Management System (CMS) that is written in PHP and uses a MySQL database for the storage of content and settings. In order for us to build out the necessary infrastructure to support these WordPress sites, we needed to ensure all the software’s requirements were satisfied.

    A team consultation with the customer drove the decision to implement a LAMP stack for this project based on their own familiarity and skill set. “LAMP” is an acronym that is commonly used to refer to the combination of technologies for the creation and delivery of web-based applications, in this case, Linux, Apache, MySQL, and PHP. The Word Press sites would be served on a cluster of EC2 instances running Amazon Linux, Apache 2.4, and PHP 7.4. The database was served by a cluster of Amazon Aurora MySQL instances.

    The database was served by a cluster of Amazon Aurora MySQL instances.

    With our list of requirements defined, the TekStream team began developing our Infrastructure as Code “stack” to provision all the backing environment. Using the CloudFormation interface, our customer inputs values for various parameters that the system uses when building out the infrastructure such as desired IP address ranges, the primary fully qualified domain name (FQDN) that will be used for the Cloud Front distribution, number of EC2 instances to provision, and the instance class size for the database cluster to name a few. Execution of this stack results in a new Virtual Private Cloud (VPC) containing multiple EC2 instances in private subnets spanning several Availability Zones (AZ). The EC2 instances are load balanced by an Application Load Balancer (ALB), fronted by a Cloud Front distribution which caches the sites and delivers them from a global network of edge locations and takes advantage of shared persistent storage mounts provided by EFS. Additionally, a cluster of RDS instances that is configured for fault tolerance and automatic failover, provide our environment with a highly available database system. If provisioned manually, all components of this system would take a significant amount of time and effort to configure and implement. Without Infrastructure as Code and CloudFormation, this 15-minute process could take hours to complete with potentially varying results.

    Ansible is an open-source product of Red Hat.

    Now that our environment has been successfully provisioned, we can now move on to the next part of this project.  Ansible is an open-source product of Red Hat that is used for automating the provisioning, configuration, and deployment of software and systems.  Ansible is a phenomenal utility that is capable of automating processes and procedures on a single device such as a Cisco router to a fleet of thousands of servers.  For this project, we are using Ansible to establish an SSH connection to the instances in our EC2 cluster and then executing a series of commands on our behalf.  Our EC2 instances, or “hosts”, are defined in our Ansible configuration as an “inventory”.  The group of instructions that tell Ansible what to do, and how to do it, is called a “playbook”.  The idea is that any time the customer needs to create a new WordPress website, they will run this playbook and all the tedium and error-prone configuration is handled for them.  When the playbook is first run, the user is prompted for customization of the configured parameters such as site title, URL, administrative username, etc.  After all parameters have been provided, either by accepting the default values or by entering overriding information, the playbook begins iterating through each configured host in the inventory.  First, Ansible connects to the EC2 instance with SSH and verifies the existence of specific packages and ensures they are up to date using the Operating System’s native package manager.  Next, a local VirtualHost configuration template is populated with the appropriate details provided by the customized parameters when the playbook was first executed.  This customized template is then stored on the persistent EFS storage as an Apache configuration file.  Ansible then creates the directory defined in the configuration file as the DocumentRoot on the persistent EFS storage, where the WordPress core files will be downloaded and stored.  It then executes several commands using the utility WP-CLI to configure and install the WordPress site with the customized parameters collected at runtime.  Since each EC2 instance in our cluster is configured to look in our shared storage mounts for VirtualHost configuration files and site DocumentRoot directories, Ansible only needs to install and configure our sites on a single host.  However, Apache needs to be restarted on each host to take advantage of any changes to configuration that may have occurred.  The final step in this process, connects to each remaining host in the inventory and restarts Apache.  When the whole process is complete, the user is then provided a summary of the tasks that were run as well as the administrative information needed to log into the WordPress admin dashboard.

    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!

  • Splunk Indexer Cluster Run Times

    Splunk Indexer Cluster Run Times

    By: Aaron Dobrzeniecki | Senior Splunk Consultant

    Have you ever wondered how you can check your indexer cluster run times are performing? Of course, there are a multitude of dashboards and statistics you can pull from the Monitoring Console to use to show the health of your indexer cluster run times. While working on a project for one of our large Splunk customers, my colleague, Antonio Patinonoguez, and I produced the idea to create a simple synthetic search for each of our indexer clusters. From these saved searches, we can pull out the total_run_time each time the searches run and find the indexer cluster run time each time the search runs. Below are the details:

    Let us say for example your environment has 3 different indexer clusters and we want to see the run time for our synthetic searches over time to see when we receive extremely high spikes in run time. You will create a saved scheduled search that runs every minute looking back 1 minute. Please see the simple search below:

    **NOTE** You need to have your splunk_server match your indexers naming format. index=_internal splunk_server=*idx1_cluster* lhead 100

    You can create a scheduled search for each of your indexer clusters or if you have one cluster, you can create it for each indexer. This is just a simple search, searching the internal logs that were indexed on the indexer cluster, returning the first 100 events.

    Configuration screen for a Splunk report scheduled using Cron expression to run every minute with highest priority.

    Once enough time has passed (maybe a few days of collecting metrics), you can take the below search and see your synthetic search run times over X amount of time in the past. The run times are stored in the _audit index which will keep data for 30 days by default. Please see the screenshots below of the current searches we have set up in this environment.

    index=_audit savedsearch_name IN (“idxclust1_synthetic_search_test”, “idxclust2_synthetic_search_test”, “idxclust3_synthetic_search_test”) | stats  latest(total_run_time) by savedsearch_name

    With our help, you can also build a dashboard as shown in the screenshot below. The top panel is the following search, this gives us the absolute latest run time for our scheduled synthetic search in seconds. As you can see, indexer cluster 1 has an exceedingly high run time for our synthetic search at 71.5 seconds. For one simple search like we have for this, the desired results are what cluster 2 and 3 are currently at. We do not want high run times.
    What might cause high run times you ask? There could be an exceptionally LARGE number of searches stemming from that certain indexer cluster causing extreme amounts of CPU usage. There could also be long-running or bad searches that are taking up too much memory. Numerous issues could be the cause of high run times.

    The top panel in this screenshot is the search below, there is a total_run_time field that pulls out the total time it took the synthetic search to run. Having a low search run time can show that your indexers are processing searches in a healthy manor.

    The second panel in this screenshot is the timechart of the last X amount of time in the past. We have added a time-picker to our dashboard for this.

    Splunk dashboard displaying run times by minute and historical trends across three panels, highlighting performance variability.

    This dashboard we created helps us dig into and troubleshoot when indexer clusters have high synthetic search run times. In the screenshot below you will see my mouse on the largest point on the graph for indexer cluster 1. By clicking on this point, we open two more panels that show:

    1. Thirty minutes before and after where I clicked on the graph (with a dotted line showing where I clicked); the max historical searches by search head cluster/search heads in the environment.
    2. Thirty minutes before and after where I clicked on the graph (with a dotted line showing where I clicked); the max active searches on that specific indexer cluster.

    Graph zoomed in on a specific spike in run time on June 20, 2022 at 10:05 AM showing 171.75 seconds.
    Line graph showing max historical searches by different search head clusters over time on June 20, 2022.
    Line chart displaying peak active searches on the indexer farm, highlighting a sharp increase around 10:05 AM.

    From these two panels, you can click on any point on either panel which will open a separate dashboard related to the panel you clicked. This dashboard is interactive and provides a LOT of vital information regarding how well your indexer clusters/indexers are performing, as well as ALL the long-running searches happening on a specific search head clusters (Just by clicking a point on the max hist searches by search head cluster panel!). For more help Wrangling your Splunk indexers check out this blog.

    For more information about our incredible Indexer Cluster Metrics dashboard, please reach out to the TekStream Solutions Splunk team!