-
Open the DataCollector and create a new pipeline.
-
Note: If you'd like, feel free to download a previously created pipeline that has been configured with the contents of this tutorial. In the DataCollector Main Screen, select Import Pipeline to begin
-
Drag the 'Directory' origin stage into your canvas.
-
Go to the Configuration Settings below and Select the Files tab
-
Enter the following settings :
- Data Format - Log
- Files Directory - the absolute file path to the directory containing the sample .log.gz files
- File Name Pattern -
*.gzthis will pick up all .gz files in this folder, you can use any wildcard to narrow down your selection - Files Compression - Compressed File
-
In the Post Processing tab make sure File Post Processing is set to None.
Note: This dropdown also lets you delete source files after they have been processed. You may want to use this in your production systems once you have verified your pipelines are configured correctly.

- In the Log Tab set the Log Format option to Combined Log Format.
*Note:The Data Collector already knows the format of the Combined Log Format and a few other log types, and has built in RegEx patterns to decode them. If you are working with custom log formats choose either Regular Expression or Grok Pattern from the dropdown and define your own format. *

-
Drag and drop an 'Expression Evaluator' processor into the canvas.
-
In its Configuration, select the Expressions Tab
-
Under Field Expressions add an output field called /geo and set the field expression to
${emptyMap()}This creates a Map data structure to hold the value of the geo object that we will populate later
#### Converting Fields
By default the Data Collector will read the fields in the log file as string values, this works for most fields however we know that Web Server logs contain numeric values for Response Code, Bytes Transferred and a Date Time stamp. Let's convert these fields into the right data types.
-
Drag and drop a 'Field Converter' stage into the pipeline.
-
Go to its Configuration and select the 'Conversions' tab.
-
Click the
+button to add another conversion. -
In the new row, set Fields to Convert to
/responseand set Convert to Type as INTEGER. -
Click the
+button to add another conversion. -
In the new row, set Fields to Convert to
/timestampand set Convert to Type as DATETIME. Set Date Format to Other and in the Other Date Format textbox typedd/MMM/y:H:m:s ZYou can use Java DateTime format specifiers to change the format to suit your needs
-
Download a copy of the MaxMind free GeoIP2 Lite City Database. Move the downloaded file to the StreamSets Resources Folder and unzip it there.
-
Back in the Data Collector, drag and drop the 'GeoIP' Stage into the Canvas
-
Go to its Configuration and select the Geolocations tab.
-
Under 'Input Field Name' type
/clientipand set its corresponding 'Output Field Name' to/cityand selectCITY_NAMEunder 'GeoIP2 Field'. -
Hit
+to add another field, set 'Input Field Name' to/clientipand set 'Output Field Name' to/latand 'GeoIP2 Field' toLATITUDE -
Hit
+again to add the last field, set 'Input Field Name' to/clientipand set 'Output Field Name' to/lonand 'GeoIP2 Field' toLONGITUDE
-
Finally lets specify a destination, drag and Drop a 'ElasticSearch' stage to the Canvas.
-
Go to its Configuration and select the 'General' Tab. In the drop down for 'Stage Library' select the version of ElasticSearch you are running.
-
Go to the 'ElasticSearch' Tab and in the 'Cluster Name' textbox enter the name of your cluster as specified in elasticsearch.yml
-
In the 'Cluster URI' field specify the host:port where your ElasticSearch service is running
-
In 'Index' and 'Mapping' textboxes write
logs. This is the index and mapping we setup earlier in this tutorial. -
Finally before we do anything with the Pipeline click on any blank spot on the canvas, go to Configuration and the 'Error Records' tab. And under 'Error Records' select 'Discard(Library:Basic)'. This effectively tells the system to discard any erroneous data. In a real production system you can choose to send error records to a number of different systems.
The preview mode lets you interactively debug your stage configurations.
-
Once the pipeline has been setup Hit the 'Start' button to execute the pipeline.
-
At this point the system should start reading off the origin directory and sending data into ElasticSearch.
- You can fireup a Kibana Dashboard to view the results of the import into ElasticSearch
- In Part 2 of this tutorial we will see how to write custom Python code to enhance our log data. We will also setup Metric Alerts as we prepare the pipeline for production use.









