Overview
Motivation
...
- Suppose the user wants to take in a stream of Apache Access log data (CLF format) to generate several histograms of status codes and referrers (partitioned by time) and then wants to be able to query ranges of timestamps for aggregated histogram data.
- Another such example would be if a user wanted to figure out which IP addresses were trying to access a given service, and the user had the related Apache Access Log data stored in a table — partitioned by time. The application could be configured to read in the IP addresses from the table and compute a unique aggregation on each set of IP addresses for each time interval. After that, the user could once again query the aggregated data while specifying relevant timestamps.
Requirements
Read in multiple data formats from a generic source
Example: read in from stream of CLF data
Data Quality should be assessed in batch and the results should be computed in periodic intervals (i.e. each hour)
Map Reduce program that will take in log data as input, apply an aggregation function, and store the results of the aggregation in the table.
The table should be partitioned by time
Allow the user to query aggregated data over various time intervals.
Library of aggregation functions
Allow the aggregation function logic to be pluggable (allow users to plug in their own aggregation functions)
Allow the source type and input data format to be configurable
- UI
Determine when there are anomalies/suspicious patterns (using the aggregated data).
Explore if it’s possible to attach a level of confidence to these findings
Alert the user via email when such things occur
Examples:
Suppose 90% of the status codes are consistently 200’s and all of a sudden, in the adjacent time interval, 70% of the status codes coming in are a mix of 404’s and 500’s. We would want to be able to determine that this is a situation worth alerting the user via email over.
Suppose the frequencies of referrers over a standard length time interval are fairly equally distributed up until a certain interval at which point the frequencies are largely skewed towards one referrer. We would want to be alert the user that this referrer is likely a bot (possibly even with a confidence level)
Design
Implicit Table Schema
...
Service for combinable aggregations (example: frequency/histogram)
Handler for retrieving aggregations
- Returns a JSON of aggregated values
- Request format: /v1/source/{sourceID}/fields/{fieldname}/aggregations/{aggregationName}?startTimestamp={start_ts}&endTimestamp={end_ts}
- Path param: source ID
- Path param: field name
- Path param: aggregation type
- Query param: start timestamp
- Query param: end timestamp
- The service will return a JSON containing the aggregated values that were queried. Here is an example of the format of something the service might return if the user wants to see a discrete values histogram over a given time range:
...
Hander for retrieving the fields that have been aggregated over for a given sourceID.
Returns a JSON of field names
Request format: /v1/source/{sourceID}/fields/?startTimestamp={start_ts}&endTimestamp={end_ts}
- Path param: source ID
- Query param: start timestamp
- Query param: end timestamp
- The service will return a JSON containing the available field names for the given parameters (sourceID, time interval). Here is an example of the format of something the service might return if the user wants to see the available aggregation functions for stream1 between timestamps 1423371600 and 1423372900
Code Block |
---|
{ "content_length":[ { "name":"median", "combinable":false }, { "name":"max", "combinable":true } ] } |
Handler for retrieving the aggregation types for a given sourceID, fieldName, and time interval.
Returns a JSON of aggregation types
Request format: /v1/source/{sourceID}/fields/{fieldname}/aggregations?startTimestamp={start_ts}&endTimestamp={end_ts}
Path param: source ID
Path param: field name
Query param: start timestamp
Query param: end timestamp
...
This is important because it dictates the structure of users’ custom aggregation functions.
Interfaces
|
|
Application API Usages
Usage of void add(DataQualityWritable value) and byte[] aggregate()
|
Usage of T retrieveAggregation() and void combine(byte[] values)
|
...
Below is code demonstrating how a discrete values histogram aggregation function would look like using the aforementioned APIs.
|
...