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

In [1]:
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.

In [2]:
data = np.loadtxt ('requests-idevji.txt')

We need 24 bins because we have 24 hours’ data. For other attributes of hist() see references.

In [3]:
plt.hist(data, bins=24)
plt.title("Requests @ iDevji")
plt.xlabel("Hours")
plt.ylabel("# Requests")
Out[3]:
Text(0,0.5,'# Requests')
In [4]:
plt.show()
References:

  1. numpy.loadtext(), Scipy.org
  2. PyPlot API, Matplotlib.org

Comments

avatar
  Subscribe  
Notify of