{"id":6563,"date":"2020-05-01T17:49:33","date_gmt":"2020-05-01T14:49:33","guid":{"rendered":"https:\/\/kifarunix.com\/?p=6563"},"modified":"2024-03-14T20:48:58","modified_gmt":"2024-03-14T17:48:58","slug":"create-kibana-visualization-dashboards-for-modsecurity-logs","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/create-kibana-visualization-dashboards-for-modsecurity-logs\/","title":{"rendered":"Create Kibana Visualization Dashboards for ModSecurity Logs"},"content":{"rendered":"\n
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<\/a> audit logs. Hence, before you can proceed, ensure that you have checked the tutorial by following the link below.<\/p>\n\n\n\n Process and Visualize ModSecurity Logs on ELK Stack<\/a><\/p>\n\n\n\n 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.<\/p>\n\n\n\n Kibana visualizations are based on Elasticsearch queries. By using a series of Elasticsearch aggregations<\/a> to extract and process your data, you can create charts that show you the trends, spikes, and dips you need to know about.<\/p>\n<\/blockquote>\n\n\n\n There are different types of Kibana visualizations that you can use with the most fequently used including;<\/p>\n\n\n\n You can create Visualizations on Kibana by navigating to Visualize<\/strong> menu.<\/p>\n\n\n\n Hence, click on the three menu lines at the top left corner on Kibana web interface > Visualize<\/strong> > Create visualization<\/strong>.<\/p>\n\n\n\n From there, you can now choose the type of Visualization you want to create.<\/p>\n\n\n\n To create Kibana Visualization for the ModSecurity Top 10 attacks, we will use a pie chart.<\/p>\n\n\n\n Therefore click Pie<\/strong> on the visualization window above.<\/p>\n\n\n\n Choose the your data source index. In this case, we use our modsec-*<\/strong> Elasticsearch index.<\/p>\n\n\n\n This opens up a default Pie chart with one slice as shown below;<\/p>\n\n\n\n Next, you need to define your Pie Chart Metrics and Buckets.<\/p>\n\n\n\n Under Data<\/strong> tab;<\/p>\n\n\n\n Under the Options<\/strong> tab, are the chart customizations options. We disabled the Donut<\/strong> format for the chart in this section and also enabled Show labels<\/strong>.<\/p>\n\n\n\n Click Update<\/strong> button at the bottom right corner to save you chart settings.<\/p>\n\n\n\n Once done setting up the chart, click the Save<\/strong> button at the top left to name your chart and save it. We call the chart Top 10 Attacks<\/strong>.<\/p>\n\n\n\n Similarly, we use the same approach above to create a new chart for the Top 10 user agents.<\/p>\n\n\n\n However, when selecting the data field, we select user_agent.keyword<\/strong> as per our Elasticsearch index field.<\/p>\n\n\n\n Next, let us create a visualization for the Top 10 Attacker source IPs and their count.<\/p>\n\n\n\n In this visualization, we will use Data table<\/strong> aggregation type.<\/p>\n\n\n\n To create Kibana Data table, navigate to Kibana Visualize<\/strong> menu > Create visualization<\/strong> > Data table<\/strong>.<\/p>\n\n\n\n Select the Elasticsearch datasource index.<\/p>\n\n\n\n This opens up a default table with just the Count<\/strong> aggregation metric enabled.<\/p>\n\n\n\n You can create your data table based on an existing saved search or a new search.<\/p>\n\n\n\n Under Data<\/strong> tab;<\/p>\n\n\n\n If you like, you can see other settings under Options<\/strong> tab.<\/p>\n\n\n\n Click the Save<\/strong> button at the top left to name your data table and save it.<\/p>\n\n\n\n You can also create Top 10 request URIs visualizations. For this, we use Pie<\/strong> chart and hence, the approach is the the same as above.<\/p>\n\n\n\n For the data field, we use Save and name your chart accordingly.<\/p>\n\n\n\n Once you have created your visualization charts or tables, you can now create your own dashboard where you can put together all the visualizations.<\/p>\n\n\n\n To add Kibana visualizations to Kibana dashboard;<\/p>\n\n\n\n Select the visualizations panel to add to the dashboard by clicking on it.<\/p>\n\n\n\n Click Save<\/strong> button at the top of the page to save your dashboard.<\/p>\n\n\n\n And there you go. You can add more visualizations as you wish.<\/p>\n\n\n\n Kibana visualization<\/a><\/p>\n\n\n\n Install Elastic Stack 7 on Fedora 30\/Fedora 29\/CentOS 7<\/a><\/p>\n\n\n\n Install and Configure Filebeat 7 on Ubuntu 18.04\/Debian 9.8<\/a><\/p>\n\n\n\n Install Elastic Stack 7 on Ubuntu 18.04\/Debian 9.8<\/a><\/p>\n\n\n\nCreate Kibana Dashboards for ModSecurity Logs<\/a><\/h2>\n\n\n\n
\n
\n
<\/figure>\n\n\n\n
Top 10 Attacks<\/h3>\n\n\n\n
<\/figure>\n\n\n\n
\n
Buckets<\/code><\/strong> are used to group data or sets of documents based on certain criteria.
Bucket aggregation<\/code><\/strong> is used to specify the slices to display in a Pie chart. Aggregation<\/strong> refers to the collection of documents or a set of documents obtained from a particular search query or filter.<\/li>\n\n\n\n
Metrics<\/code><\/strong> on the other hand refers to values extracted from the documents that are being aggregated. Example is the
Numeric metrics aggregations<\/code><\/strong> which output numeric values.<\/li>\n<\/ul>\n\n\n\n
\n
Count<\/code><\/strong> (returns a raw count of the elements in the selected index pattern).<\/li>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
Top 10 User Agents<\/h3>\n\n\n\n
<\/figure>\n\n\n\n
Top 10 Attacker IPs<\/h3>\n\n\n\n
Create Kibana Data Table<\/a><\/h4>\n\n\n\n
<\/figure>\n\n\n\n
\n
Count<\/code><\/strong>.<\/li>\n\n\n\n
<\/figure>\n\n\n\n
Top 10 Request URIs<\/h3>\n\n\n\n
request_uri.keyword<\/code><\/strong> as per our ES index fields.<\/p>\n\n\n\n
<\/figure>\n\n\n\n
Add Visualization Charts\/Tables to Kibana Dashboard<\/a><\/h2>\n\n\n\n
\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
Further Reading<\/h3>\n\n\n\n
Other Tutorials<\/h3>\n\n\n\n