Welcome!

Industrial IoT Authors: Zakia Bouachraoui, William Schmarzo, Elizabeth White, Stackify Blog, Yeshim Deniz

Blog Feed Post

Measuring HTTP request and responses in Apache using Monitis, python and M3

free-website-monitoringAs we have mentioned on our blog few weeks ago. Apache is still the most popular webserver in the world. Monitis is already helpful in monitoring Apache performance (e.g. you can check how to get metrics provided by Apache status module or speed of served static content), but in this article we show how to use simple python script with M3 to monitor number of HTTP request and status codes of response provided by Apache. We will show how to use a new plugin to monitor the most popular types of HTTP requests (GET and POST) or groups of response status codes (2XX, 3XX, 4XX, 5XX).

Log parser

Apache logs are source of big number of interesting information helping to monitor an application performance and state.To get them we will use modified version of apache-log-parser script avaliable on github (this is orginal version and here you can find one extended by Monitis).

Installation

Installation is easy. First you have to download/update Monitis Linux Scripts from GitHub. If you haven’t done it yet. You need to clone repo:

git clone git://github.com/monitisexchange/Monitis-Linux-Scripts.git

If you already downloaded repository you might want to update it:

git update  (of course in directory you have cloned repo)

Next copy apache-log-parser.py to /usr/local/monitis. For example from main directory of Monitis-Linux-Scripts git repo run following command:

(ls -l /usr/local/monitis || mkdir /usr/local/monitis) && cp m3v3/plugins/

Now you can test the script:

/usr/local/monitis/apache-log-parser.py

Without any command line option you should see output similar to the following line (you might see numbers bigger than 0):

22/May/2012,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0

Limitation

If the above script failed it might be because of its limitation. The script works base on following two assumptions. It expects that Apache logs:

  • are located in /var/log/apache2/access.log. Can be easily changed in lines 12 and 13.

 

  • are in default format. This is a bit harder to change (you have to understand regex), but it can be done in line 87.

Usage

Apache log parser gets apache log file and counts number of selected parameters (e.g. request type) in given period of time (e.g. last hour). At the moment parser supports three: command line options:

  • -r (time resolution) – predefine: seconds, minutes, hours or days (default days).
  • -m (parameter to measure)  -predefine: requests, responses (HTTP status codes), and whole groups of responses, (default responses).
  • -t (time format) – predefine: UNIX timestamp and format based on default apache log time format. Controls the way time is presented in results.

For example to get information about request types  in last hour with time presented in apache format:
/usr/local/monitis/apache-log-parser.py -r “hour” -m “requests” -t “apache”

Script has also short help (available with option -h or –help).

M3 configuration

apache-log-parser.py is very useful when run as command line script, but we would like to use it to prepare some graphs. To connect to Monitis we are going to use version 3 of  MonitisMonitorManager (M3V3). So  if you haven’t used it yet, please follow installation notes to get it onto your system.

To use M3V3 we need xml config. Our configs are not different to typical M3 config.

a) For status codes, you need following line to define test command:
<exectemplate>/usr/local/monitis/apache-log-parser.py -t “unix” -r “min” -m “response_group”</exectemplate>

The output will be: number, number, number, number, number format (e.g. 1339760630,0,0,0,0) where successive numbers mean: UNIX timestamp, and next 2xx, 3xx, 4xx, 5xx status codes respectively. Therefore, regex for our metrics are defined in way similar to this example (for 3xx codes):
<regex>\d+,\s*\d+,\s*(\d+)</regex>

What means a number (any length) followed by comma, possible space, another number, another comma, space again and requested number.

b) To get numbers of request type we use nearly identical command:
<exectemplate>/usr/local/monitis/apache-log-parser.py -t “unix” -r “min” -m “requests”</exectemplate>

have similar output, but with 10 numbers (1339761646,  0,  0,  0,  0,  0,  0,  0,  0,  0) and similar regex (example for POSTs):

<regex>\d,\s*\d+,\s*(\d+)</regex>

You might notice that we measure only 2 metrics and have 9 values in output, this is because script counts all HTTP requests even that less popular, which you rather not want to measure by default.

Finally please remember that to make it works you need only to provide yours Monitis API key and secret.

Further changes

The script is easy to extend and more detailed description will be provided in another article.

Share Now:del.icio.usDiggFacebookLinkedInBlinkListDZoneGoogle BookmarksRedditStumbleUponTwitterRSS

Read the original blog entry...

More Stories By Hovhannes Avoyan

Hovhannes Avoyan is the CEO of PicsArt, Inc.,

IoT & Smart Cities Stories
Dynatrace is an application performance management software company with products for the information technology departments and digital business owners of medium and large businesses. Building the Future of Monitoring with Artificial Intelligence. Today we can collect lots and lots of performance data. We build beautiful dashboards and even have fancy query languages to access and transform the data. Still performance data is a secret language only a couple of people understand. The more busine...
Nicolas Fierro is CEO of MIMIR Blockchain Solutions. He is a programmer, technologist, and operations dev who has worked with Ethereum and blockchain since 2014. His knowledge in blockchain dates to when he performed dev ops services to the Ethereum Foundation as one the privileged few developers to work with the original core team in Switzerland.
René Bostic is the Technical VP of the IBM Cloud Unit in North America. Enjoying her career with IBM during the modern millennial technological era, she is an expert in cloud computing, DevOps and emerging cloud technologies such as Blockchain. Her strengths and core competencies include a proven record of accomplishments in consensus building at all levels to assess, plan, and implement enterprise and cloud computing solutions. René is a member of the Society of Women Engineers (SWE) and a m...
Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settlement products to hedge funds and investment banks. After, he co-founded a revenue cycle management company where he learned about Bitcoin and eventually Ethereal. Andrew's role at ConsenSys Enterprise is a mul...
Whenever a new technology hits the high points of hype, everyone starts talking about it like it will solve all their business problems. Blockchain is one of those technologies. According to Gartner's latest report on the hype cycle of emerging technologies, blockchain has just passed the peak of their hype cycle curve. If you read the news articles about it, one would think it has taken over the technology world. No disruptive technology is without its challenges and potential impediments t...
If a machine can invent, does this mean the end of the patent system as we know it? The patent system, both in the US and Europe, allows companies to protect their inventions and helps foster innovation. However, Artificial Intelligence (AI) could be set to disrupt the patent system as we know it. This talk will examine how AI may change the patent landscape in the years to come. Furthermore, ways in which companies can best protect their AI related inventions will be examined from both a US and...
In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
Bill Schmarzo, Tech Chair of "Big Data | Analytics" of upcoming CloudEXPO | DXWorldEXPO New York (November 12-13, 2018, New York City) today announced the outline and schedule of the track. "The track has been designed in experience/degree order," said Schmarzo. "So, that folks who attend the entire track can leave the conference with some of the skills necessary to get their work done when they get back to their offices. It actually ties back to some work that I'm doing at the University of San...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things'). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing. IoT is not about the devices, its about the data consumed and generated. The devices are tools, mechanisms, conduits. This paper discusses the considerations when dealing with the...
Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...