Skip to content

Instantly share code, notes, and snippets.

@tbicr
Last active August 29, 2015 14:27
Show Gist options
  • Save tbicr/e54d2d3bd614db766097 to your computer and use it in GitHub Desktop.
Save tbicr/e54d2d3bd614db766097 to your computer and use it in GitHub Desktop.
Jula log stat
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"\n",
"import os\n",
"import re\n",
"\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"path = 'AppLogs'\n",
"\n",
"def files():\n",
" for file in os.listdir(path):\n",
" yield open(os.path.join(path, file), 'rb')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"names = ['type', 'proc', 'user', 'date', 'data']\n",
"converters = {name: str.strip for name in names}\n",
"df = pd.concat([pd.read_csv(file, sep='|', names=names, converters=converters) for file in files()])"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def get_values(data):\n",
" if '[PaymentMethodValidator] Time spent to call fraudService:' not in data:\n",
" return None\n",
" match = re.search('\\[PaymentMethodValidator\\] Time spent to call fraudService: \\'([0-9\\.]+)\\' sec;', data)\n",
" return float(match.groups()[0])\n",
"\n",
"times = df[(df.date > '2015/08/18 12:23') & (df.date < '2015/08/18 12:43')].data.map(get_values)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"count 714.000000\n",
"mean 1.810340\n",
"std 0.622092\n",
"min 0.901000\n",
"5% 1.179650\n",
"25% 1.367250\n",
"50% 1.652500\n",
"75% 2.054500\n",
"95% 3.069100\n",
"max 6.725000\n",
"Name: data, dtype: float64"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"times.dropna()\n",
"\n",
"times.describe(percentiles=[.05, .25, .5, .75, .95])"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f9ce8413ac8>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAEACAYAAABMEua6AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGJBJREFUeJzt3W+MZvV53vHvBeutjUFsXVfLglGXF2CykSVw4pVbFHxM\nAEHVAnkTg2QZktRCIrWRK1dZKrWgxFrjSnYttbItJeBdp2Fb6igUHC3hT/Y0i6IusctgzLABLI/E\numabyEBNaat1uPtizpZhPDPPmfObZ+7nd/b6SKM9v3POM+eaZ+CaM/c8s6uIwMzMxuG07ABmZrZx\nXOpmZiPiUjczGxGXupnZiLjUzcxGxKVuZjYia5a6pHdKOiJpTtK8pM93+++SdEzSU93btUsec4ek\nFyQdlXT1tD8AMzN7iya9Tl3SGRHxhqQtwBPAZ4FfBn4SEV9adu4u4D7gQ8B5wGPARRHx5jTCm5nZ\n200cv0TEG93mVuB04JVurRVOvx44EBEnImIBeBHYvQE5zcysh4mlLuk0SXPAceBQRDzbHfqUpKcl\n3SNpW7fvXODYkocfY/GO3czMNkGfO/U3I+IS4H3A5ZIa4KvABcAlwI+AL671LjYgp5mZ9bCl74kR\n8ZqkPwZ+MSLak/sl/R7wULf8IXD+koe9r9v3NpJc9GZmA0TESqPvt52w6hvwXmBbt/0u4M9Y/CHp\nOUvO+QxwX7e9C5hjcf5+AfB9uh/GLnu/sdZ1Z/0NuCs7w6mY3fnz35w/PX9MOmfSnfoOYL+k01gc\n1fx+RDwu6RuSLmFxtPID4NbuavOS7gfmgZ8Ct0WXZGR2ZgcosDM7QKGd2QEK7cwOUGhndoBCO7MD\nTNuapR4RzwAfXGH/J9Z4zF5gb3k0MzN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e4D5iPhydp71kvReSdu67XcBVwFP5abqLyL+\nRUScHxEXsPgt9J9GxCeyc/Ul6QxJZ3Xb7wauBqp4FVhEvAy8JOmibteVwLOJkYa6icUbgjVt2j+S\nMYZfSpJ0APgI8HckvQT8q4j4enKsvi4DPg58V9LJMrwjIh5OzLQeO4D93U//TwN+PyIeT85UorZx\n5HbgjxbvDdgC/EFEPJIbaV0+BfxBd0P5feDXkvOsS/eF9Epg4s8y/MtHZmYj4n+j1MxsRFzqZmYj\n4lI3MxsRl7qZ2Yi41M3MRsSlbmY2Ii51M7MRcambmY3I/wPsB1oUEWEIsQAAAABJRU5ErkJggg==\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x7f9cc1da7d68>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"times.hist()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment