Create Kibana Visualization Dashboards for ModSecurity Logs

|
Last Updated:
|
|

In this tutorial, you will learn how to create Kibana visualization dashboards for ModSecurity logs. This tutorial is a continuation of our previous tutorial on how to process and visualize ModSecurity Logs on ELK Stack where we covered various grok filters/regular expressions for extracting various fields from the ModSecurity audit logs. Hence, before you can proceed, ensure that you have checked the tutorial by following the link below.

Process and Visualize ModSecurity Logs on ELK Stack

Create Kibana Dashboards for ModSecurity Logs

Once you have created and verified your ModSecurity logstash filters, proceed to create visualization dashboards for your ModSecurity logs based on the fields extracted by your filters.

Kibana visualizations are based on Elasticsearch queries. By using a series of Elasticsearch aggregations to extract and process your data, you can create charts that show you the trends, spikes, and dips you need to know about.

There are different types of Kibana visualizations that you can use with the most fequently used including;

  • Line, area, and bar charts — Compares different series in X/Y charts.
  • Pie chart — Displays each source contribution to a total.
  • Data table — Flattens aggregations into table format.
  • Metric — Displays a single number.
  • Goal and gauge — Displays a number with progress indicators.
  • Tag cloud — Displays words in a cloud, where the size of the word corresponds to its importance.

You can create Visualizations on Kibana by navigating to Visualize menu.

Hence, click on the three menu lines at the top left corner on Kibana web interface > VisualizeCreate visualization.

From there, you can now choose the type of Visualization you want to create.

new visualization

Top 10 Attacks

To create Kibana Visualization for the ModSecurity Top 10 attacks, we will use a pie chart.

Therefore click Pie on the visualization window above.

Choose the your data source index. In this case, we use our modsec-* Elasticsearch index.

This opens up a default Pie chart with one slice as shown below;

default pie chart settings

Next, you need to define your Pie Chart Metrics and Buckets.

  • Buckets are used to group data or sets of documents based on certain criteria. Bucket aggregation is used to specify the slices to display in a Pie chart. Aggregation refers to the collection of documents or a set of documents obtained from a particular search query or filter.
  • Metrics on the other hand refers to values extracted from the documents that are being aggregated. Example is the Numeric metrics aggregations which output numeric values.

Under Data tab;

  1. Choose the Metrics aggregation type. We use the default one here, Count (returns a raw count of the elements in the selected index pattern).
  2. On the Buckets, click Add > Split slices.
  3. Select the type of Bucket Aggregation. Choose Terms (enables you to specify the top or bottom n elements of a given field to display, ordered by count or a custom metric).
  4. Select the field from which data should be extracted. In this case, we select attack.type.
  5. Order by Count Metrics.
  6. Set Descending order and set the size to 10.
chart data settings

Under the Options tab, are the chart customizations options. We disabled the Donut format for the chart in this section and also enabled Show labels.

Click Update button at the bottom right corner to save you chart settings.

Once done setting up the chart, click the Save button at the top left to name your chart and save it. We call the chart Top 10 Attacks.

top 10 attack types chart

Top 10 User Agents

Similarly, we use the same approach above to create a new chart for the Top 10 user agents.

However, when selecting the data field, we select user_agent.keyword as per our Elasticsearch index field.

Top 10 user agents

Top 10 Attacker IPs

Next, let us create a visualization for the Top 10 Attacker source IPs and their count.

In this visualization, we will use Data table aggregation type.

Create Kibana Data Table

To create Kibana Data table, navigate to Kibana Visualize menu > Create visualization > Data table.

Select the Elasticsearch datasource index.

This opens up a default table with just the Count aggregation metric enabled.

default data table

You can create your data table based on an existing saved search or a new search.

Under Data tab;

  1. Under Metrics, select an aggregation type. Again, we use the default one here, Count.
  2. Under the Buckets, this is where we add the columns to be displayed on the table. Hence, click Add > Split rows.
  3. Select the Bucket Aggregation type. Choose Terms (enables you to specify the top or bottom n elements of a given field to display, ordered by count or a custom metric).
  4. Select the field from which data should be extracted. In this case, we select src_ip.keyword as per our ES index fields.
  5. Order by Count Metrics.
  6. Set Descending order and set the size to 10.

If you like, you can see other settings under Options tab.

top 10 source ips

Click the Save button at the top left to name your data table and save it.

Top 10 Request URIs

You can also create Top 10 request URIs visualizations. For this, we use Pie chart and hence, the approach is the the same as above.

For the data field, we use request_uri.keyword as per our ES index fields.

Save and name your chart accordingly.

Create Kibana Visualization Dashboards for ModSecurity Logs

Add Visualization Charts/Tables to Kibana Dashboard

Once you have created your visualization charts or tables, you can now create your own dashboard where you can put together all the visualizations.

To add Kibana visualizations to Kibana dashboard;

  1. On Kibana menu, Click DashboardCreate dashboard.
  2. Add an existing visualizations we already created above.
add existing dashboards

Select the visualizations panel to add to the dashboard by clicking on it.

kibana modsecurity visualization dashboard

Click Save button at the top of the page to save your dashboard.

And there you go. You can add more visualizations as you wish.

Further Reading

Kibana visualization

Other Tutorials

Install Elastic Stack 7 on Fedora 30/Fedora 29/CentOS 7

Install and Configure Filebeat 7 on Ubuntu 18.04/Debian 9.8

Install Elastic Stack 7 on Ubuntu 18.04/Debian 9.8

How to Debug Logstash Grok Filters

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
gen_too
Co-founder of Kifarunix.com, Linux Tips and Tutorials. Linux/Unix admin and author at Kifarunix.com.

Leave a Comment