Tag: mm

  • 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!

  • 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!

  • OAuth2 Authentication Tokens in Splunk

    OAuth2 Authentication Tokens in Splunk

    By: Jon Walthour | Technical Architect

    Authentication tokens in Splunk allow you to access Splunk via the REST interface, usually serviced on port 8089 on a search head, without needing to pass a username/password combinations in the call. The type of tokens Splunk employs are JSON web tokens.

    To utilize an authentication token to access Splunk via API, you would use a curl command something like the following:

    curl -X GET -H "Authorization: Bearer <auth-token>" https://ualasiem.splunkcloud.com:8089/servicesNS/admin/search/search/jobs/export -d search="search index%3D_internal|head 3" -d output_mode=xml

    To set up and administer tokens, go to Settings > Tokens (under “Users and Authentication”). To administer tokens, you need to have the “edit_all_tokens” capability.

    Here is what you can do with the tokens in Splunk in terms of reporting and alerting:

    For reporting, here’s an example SPL to get you started. NOTE: All of these searches and alerts should be run from the Monitoring Console app on your Monitoring Console instance so that all search heads can be queried and reported on at once. However, they could be run from any search head by changing “splunk_server_group=dmc_group_search_head” to “splunk_server=local”:

    | rest splunk_server_group=dmc_group_search_head /services/ authorization/tokens | convert ctime(claims.exp), ctime(claims.iat), ctime(claims.nbr) | rename claims.aud as audience, claims.exp as expiration_date, claims.iat as issued_at_date, claims.idp as identity_provider, claims.iss as issuer, claims.nbr as not_before_date, claims.roles as roles, claims.sub as user, headers.alg as algorithm, headers.kid as kid, headers.ttyp as token_type, headers.ver as version, lastUsed as last_used_date, lastUsedIp as last_used_from_ip_address, title as token | eval last_used_date=if(last_used_date=0,"not yet used",strftime(last_used_date,"%m/%d/%Y %H:%M:%S")), last_used_from_ip_address=if(last_used_from_ip_address=""," not yet used",last_used_from_ip_address) | table token status user roles audience issued_at_date not_before_date expiration_date last_used_date last_used_from_ip_address issuer issued_at_date identity_provider splunk_server

    You can also find token-related setup information at:

    | rest splunk_server_group=dmc_group_search_head /services/ admin/Token-auth/tokens_auth

    An example alert you could use for expiring tokens, say those that are going to expire in the next 30 days:

    | rest splunk_server_group=dmc_group_search_head /services/ authorization/tokens | where ‘claims.exp’ < relative_time(now(),”+30d”)

    Additionally, with the “not before date” (claims.nbr) entry, it would be possible to set up multiple future-date, even overlapping, tokens for the same user. So, for example, you could set up two tokens for an API user today–one starting today for the next 90 days and one that started on day 89 and extended 182 days. This would give you two tokens spanning six months that had a two-day overlap period. Now, set an alarm on your calendar on days 89 and 90 to, on one of those days, go into the source system using the token to send API calls to Splunk and swap out the old token for the new one. You’d have two days to get the swap out made and potentially no loss of service.

    If you would like additional support with your authentication tokens in Splunk or any other Splunk issue please contact us right away.

  • 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!

  • 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!