Creating a timechart of method requests, views, and response times

Having the right single values displayed on a dashboard can be beneficial to understanding key metrics, but can also be limiting in providing true operational intelligence on how the different metrics of our website affect one another. By plotting values such as the number of method requests, the number of total views, and the average response times over a given time range, you can begin to understand if there is any correlation between these numbers. This can be very beneficial in understanding things such as if the average response time of pages is growing due to the number of active POST requests to the website or if one type of request is making up for the majority of the total number of requests at that given time.

In this recipe, you will create a Splunk search using the timechart command to plot values over a given time period. You will then graphically represent these values using a line chart.

Getting ready

To step through this recipe, you will need a running Splunk Enterprise server, with the sample data loaded from Chapter 1, Play Time – Getting Data In. You should be familiar with the Splunk search bar, the time range picker, and the Visualization tab. It is not required, but is advisable, that you also complete all the recipes up until this point.

How to do it…

Follow the given steps to create a timechart of method requests, views, and response times:

  1. Log in to your Splunk server.
  2. Select the default Search & Reporting application.
  3. Ensure that the time range picker is set to Last 7 days and type the following search into the Splunk search bar. Then, click on Search or hit Enter:
    index=main sourcetype=access_combined | eval GET_response=if(method=="GET",response,0) | eval POST_response=if(method=="POST",response,0) | timechart span=5m avg(GET_response) AS Avg_GET_Response, avg(POST_response) AS Avg_POST_Response, count(eval(method=="GET")) AS GET_Total, count(eval(method=="POST")) AS POST_Total, count AS Total_Visits
  4. Splunk will return a time series chart of values for the average response time of GET and POST requests, the count of GET and POST requests, and the total count of web page visits:
    How to do it…
  5. Click on the Visualization tab and select Line from the drop-down listing of visualization types to visualize the data as a line chart:
    How to do it…
  6. Save this report by clicking on Save As and then on Report. Name the report cp03_method_view_reponse and click on Save. On the next screen, click on Add to Dashboard.
  7. You will now add this report to the Website Monitoring dashboard. Select the button labeled Existing, and from the drop-down menu that appears, select the Website Monitoring dashboard. For the Panel Title field value, enter Website Response Performance and select Report in Panel Powered By field; then, click Save.
  8. The next screen will confirm that the dashboard has been created and the panel has been added. Click on View Dashboard to see for yourself. The line chart visualization should now be positioned on the dashboard below the previously added panels.
  9. Arrange the dashboard so that the line chart panel is on the right-hand side of the column chart panel created in the previous recipe. Click on the Edit button, and from the drop-down menu, select Edit Panels. Move the line chart panel accordingly.
  10. Finally, click on Done to save the changes to your dashboard.

How it works…

Let's break down the search piece by piece:

Search fragment

Description

index=main sourcetype=access_combined

You should now be familiar with this search from the earlier recipes in this book.

| eval GET_response=if(method=="GET",response,0)

Using the eval command, we create a new field called GET_response, whose value is based on the return value of the if function. In this case, if the method is GET, then the value returned is the value of the response field; otherwise, the value returned is 0.

| eval POST_response=if(method=="POST",response,0)

Using the eval command, we create a new field, called POST_response, whose value is based on the return value of the if function. In this case, if the method is POST, then the value returned is the value of the response field; otherwise, the value returned is 0.

timechart span=5m avg(GET_response) AS Avg_GET_Response, avg(POST_response) AS Avg_POST_Response, count(eval(method=="GET")) AS GET_Total, count(eval(method=="POST")) AS POST_Total, count AS Total_Visits

Using the timechart command, we first specify a span of five minutes. Next, we calculate the average value for the given span of GET_response and POST_response. Next, we count the total number of GET and POST events. Finally, the total number of events, both GET and POST, are counted. Note that we make use of the AS operator to rename the fields so that they are meaningful and easy to understand when displayed on our chart.

The Visualization tab takes the time series output of the timechart command and overlays the given visualization. In this case, you overlaid the line chart visualization.

There's more…

In this recipe, we looked at the values represented as a whole across our web server environment. However, in instances like ours, where web traffic is balanced across multiple servers, it is a good idea to split the values based on their respective hosts.

Method requests, views, and response times by host

It is very easy to obtain a more granular view of events split by the host where the events are occurring. All we need to do is add the by clause to the end of our previous Splunk search, as follows:

index=main sourcetype=access_combined | eval GET_response=if(method=="GET",response,0) | eval POST_response=if(method=="POST",response,0) | timechart span=5m avg(GET_response) AS Avg_GET_Response, avg(POST_response) AS Avg_POST_Response, count(eval(method=="GET")) AS GET_Total, count(eval(method=="POST")) AS POST_Total, count AS Total_Visits by host

As simple as this is, we can now visualize the values broken down by the host on which these values originated. In a distributed environment, this can be most crucial in understanding where latency or irregular volumes exist.

See also

Following are some recipes that will give you more information:

  • The Charting the number of method requests by type and host recipe
  • The Using a scatter chart to identify discrete requests by size and response time recipe
  • The Creating an area chart of the application's functional statistics recipe
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.108.241