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
26 changes: 26 additions & 0 deletions read_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@
from datetime import datetime

import pandas as pd
from matplotlib import pyplot as plt


def __get_date_count(df):
# Create a frequency of days and requests (e.g. datetime.date(2022, 5, 16): 12337
return df["date"].apply(lambda dt: dt.date()).value_counts().sort_index()


def __get_date_chart(df):
"""
Create a chart that will showcase the amount of requests per day.
"""
frequencies = __get_date_count(df)

# Create the bar chart
plt.bar(frequencies.index, frequencies.values)
plt.xlabel("Date")
plt.ylabel("Number of Requests")
plt.title("Number of Requests per Day")
plt.xticks(rotation=45)

# Display the chart
plt.margins(0.05)
plt.tight_layout()
plt.show()


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