Log Insight & NSX-v DFW

I was recently asked by a customer who is running NSX vSphere (NSX-v) and Log Insight, is there a way they can export data from Log Insight that will give them the unique source/destination/protocol/destinationPort from the DFW logs for a given ruleId over a given time period. This exported data could then be fed into a PowerNSX (Get it on GitHub) script to create the required firewall rules.

My initial response to the question was “buggered if I know, but I will send an email to some people that will know”.

The customer had setup some monitoring/logging rules in the DFW that they were using to get visibility into what traffic is going to and from a given set of workloads. Now you may ask, why not used the new Application Rule Manager that is available in the 6.3.x release of NSX-v, and the answer to that is they are running 6.2.5, so the feature is not available, so we fall back to using Log Insight which is already setup and configured.

With the help of Anthony Burke & Alan Castonguay, it turns out that this is relatively easy to achieve.

The first thing we need is the DFW ruleId that you want to filter the logs on. For this example we will use ruleId 1006

Now we head over to the Interactive Analytics screen in log insight.

In the search box, enter dfwpktlogs, select the time range, and add a filter for vmw_nsx_firewall_ruleid = 1006 and then click the search button.

A whole heap of log entries should appear now along with a lovely chart.

But the information is not really useful to us in this format, so lets tweak it a bit as shown below.

The order in which you select the Group By checkboxes, is the order in which they will be displayed, and subsequently exported to csv.

And what you’ll end up with is something which looks like the following

Now this still isn’t quite what we need, so its time to tweak the chart type as shown below.

Which now displays the chart data needed. Now all thats needed is to export the chart data as shown below.

The exported file can be in either CSV or JSON format. For this example, I am choosing CSV.

The saved file will look something similar to the following

Now you can use the data directly to create some firewall rules using your preferred method of programming language.

Leave a Reply