Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions read_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@

import pandas as pd


def __get_failure_rate(df):
"""
Retrieve the failure rate of an access file.
Failure rate is defined as (number of 200 status code & is a bot) / (number of bot requests)
"""

# Is the request from a bot?
is_bot = df["is_bot"]

# Is the request a success and from a bot?
is_success_and_bot = (df["status_code"] == "200") & is_bot

return len(df[is_success_and_bot]) / len(df[is_bot])


methods = ["GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS", "TRACE", "PATCH"]
pattern = r'^([\d.]+) - - \[([^]]+)\] "([^"]*)" (\d+) (\d+) "([^"]*)" "([^"]*)" "-"$'

Expand Down