This post discusses Apache log visualization with Matplotlib library.
First, download the data file used in this example from here.
We will require numpy and matplotlib
import numpy as np import matplotlib.pyplot as plt
numpy.loadtext() can directly load a text file in an array
requests-idevji.txt contains only hour on which request was made, this is achieved by pre-prcoessing the Apache log.
data = np.loadtxt ('requests-idevji.txt')
We need 24 bins because we have 24 hours’ data. For other attributes of hist() see references.
plt.hist(data, bins=24) plt.title("Requests @ iDevji") plt.xlabel("Hours") plt.ylabel("# Requests")