Code Monkey home page Code Monkey logo

logparser's Introduction

logparser

AWS ELB 로그를 읽어와 분석합니다.

Install

pip install -e .

Usage

get_log

ELB 로그 파일이 있는 곳을 log_dir 로 지정하여 로그 파일을 읽습니다. 로그 파일의 확장자는 .gz입니다.

from logparser import get_log
import os    

log_dir = os.getcwd()
log_files = get_log(log_dir)

logparse

분석에 사용할 수 있도록 로그를 파싱합니다.

from logparser import logparse
import os

logs = logparse(log_files)

Options

아래와 같은 기능을 사용할 수 있습니다.

  • count(logs) : 로그 개수를 확인합니다.
  • sequence(logs, field, reverse=False) : field별 값의 로그 수를 세고, 로그 수를 기준으로 정렬합니다.
    • field : string
    • reverse: boolean
  • find(logs, field, find_value): field의 특정 값으로 로그를 찾습니다.
    • field : string
    • find_value : string
  • period(logs, startdate, enddate) : 특정 기간에 해당하는 로그를 찾습니다.
    • startdate, enddate : datetime

field 종류는 다음 링크 를 확인하세요.

Example

from logparser import get_log, logparse, find
import os

log_dir = os.getcwd()
log_files = get_log(log_dir)
logs = logparse(log_files)

result = find(logs, 'user_agent', 'windows') 

for r in result:
	print(r['user_agent']) #or print(r)

To Do

  • as_data(logs) : change data type from generate type to list type
  • to_csv(result) : save the analyze result to csv file
  • to_graph(result) : draw the analyze result to graph
  • ...

Blog

프로젝트 제작 과정을 살펴 볼 수 있습니다.

logparser's People

Contributors

jyejin avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.