concept analysis layer in category system administration

appears as: An alysis layer, n analysis layer, alysis layer, nalysis layer, The alysis layer
Securing DevOps

This is an excerpt from Manning's book Securing DevOps.

  • An analysis layer to inspect the content of logs, detect fraud, and raise alerts
  • In the pipeline architecture that we followed all through chapter 7, the analysis layer plays a central role (see figure 8.1). It’s responsible for consuming all log events coming from the streaming layer and deciding what to do with them. Some analysis modules will be tasked with storing those raw logs in databases, some will compute metrics and statistics for telemetry purposes, and some will be tasked with detecting anomalies and fraud. It’s this last category of analysis module that we’ll focus on in this chapter.

    Figure 8.1 The three types of fraud-detection modules described in this chapter are located inside the analysis layer, at the center of the logging pipeline discussed in chapter 7. Each module performs a specific type of detection, sends alerts to operators, and writes alerts to databases.

    c08_01.png

    An analysis layer must follow a set of steps to process each log event passing through the pipeline. We can summarize them as follows:

    Listing 8.3 Source code of the NGINX input plugin
    require "io"
    local fn  = read_config("input_file")
    local clf = require "lpeg.common_log_format"
    local cnt = 0;
    local msg = {    #1  
     Timestamp = nil,    #1  
     Type = "logfile",    #1  
     Hostname = "localhost",    #1  
     Logger = "nginx",    #1  
     Fields = nil    #1  
    }    #1  
    local grammar = clf.build_nginx_grammar(    #2  
     '$remote_addr - $remote_user [$time_local] "$request"    #2  
     $status $body_bytes_sent "$http_referer" "$http_user_agent"')    #2  
    
    function process_message()
     local fh = assert(io.open(fn, "rb"))    #3  
     for line in fh:lines() do    #3  
     local fields = grammar:match(line)    #4  
     if fields then    #4  
                msg.Timestamp = fields.time
                fields.time = nil
     msg.Fields = fields    #5  
     inject_message(msg, fh:seek())    #6  
                cnt = cnt + 1
            end
        end
        fh:close()
        return 0
    end
    
    #1   Definition of the standardized message that will be passed into the analysis layer
    #2   nginx parsing variable predefined in the LPEG module
    #3   Reads the input file and processes each line
    #4   Parses a given line according to the local grammar and gets back a list of fields
    #5   Stores the fields in the standardized message
    #6   Hindsight primitive to inject the standardized message into the analysis queue
  • The analysis layer is the brain of the logging pipeline where all the complex processing of log events occurs.