In [4]:
import pandas as pd
import numpy as np
metrics = pd.read_csv('/data/metrics.csv', index_col=0)
metrics[:30]
Out[4]:
app_prefix node_id http_endpoint http_method http_status latency
timestamp
1522219178 webapp1 10.1.3.4 test GET 200 0.109911
1522219178 webapp1 10.1.3.4 test GET 200 0.054598
1522219178 webapp1 10.1.3.4 test GET 200 0.051498
1522219178 webapp1 10.0.1.1 test GET 400 0.059128
1522219178 webapp1 10.1.3.4 test GET 200 0.053644
1522219178 webapp1 10.0.1.1 test GET 400 0.053167
1522219178 webapp1 10.0.1.1 test GET 200 0.050783
1522219178 webapp1 10.1.3.4 test GET 200 0.056028
1522219178 webapp1 10.1.3.4 test GET 200 0.052929
1522219178 webapp1 10.0.1.1 test GET 200 0.054836
1522219178 webapp1 10.1.3.4 test GET 200 0.060320
1522219178 webapp1 10.0.1.1 test GET 200 0.053644
1522219178 webapp1 10.0.1.1 test GET 200 0.055552
1522219178 webapp1 10.0.1.1 test GET 200 0.056744
1522219178 webapp1 10.0.1.1 test GET 200 0.066996
1522219178 webapp1 10.0.1.1 test GET 400 0.078678
1522219178 webapp1 10.0.1.1 test GET 200 0.169277
1522219178 webapp1 10.1.3.4 test GET 200 0.057220
1522219178 webapp1 10.0.1.1 test GET 400 0.057459
1522219178 webapp1 10.0.1.1 test GET 200 0.052929
1522219178 webapp1 10.1.3.4 test GET 200 0.057936
1522219178 webapp1 10.0.1.1 test GET 200 0.053883
1522219178 webapp1 10.1.3.4 test GET 200 0.181675
1522219178 webapp1 10.0.1.1 test GET 200 0.062227
1522219178 webapp1 10.1.3.4 test GET 200 0.061750
1522219178 webapp1 10.0.1.1 test GET 400 0.063896
1522219178 webapp1 10.1.3.4 test GET 200 0.053883
1522219178 webapp1 10.0.1.1 test GET 200 0.051737
1522219178 webapp1 10.0.1.1 test GET 200 0.052452
1522219178 webapp1 10.1.3.4 test GET 200 0.051975
In [7]:
metrics.groupby(['node_id', 'http_status']).latency.aggregate(np.mean)
Out[7]:
node_id   http_status
10.0.1.1  200            0.047088
          400            0.048214
          500            0.387338
10.1.3.4  200            0.057956
          400            0.059737
          500            0.403446
Name: latency, dtype: float64
In [8]:
metrics.groupby(['node_id', 'http_status']).latency.aggregate(np.percentile, 99.999)
Out[8]:
node_id   http_status
10.0.1.1  200            0.068661
          400            0.057935
          500            1.330025
10.1.3.4  200            0.220268
          400            0.162116
          500            1.419507
Name: latency, dtype: float64
In [9]:
metrics.groupby(['http_endpoint', 'http_method']).latency.aggregate(np.percentile, 99)
Out[9]:
http_endpoint  http_method
test           GET            0.162706
test1          GET            1.346610
Name: latency, dtype: float64
In [12]:
%matplotlib inline
rolling_mean = metrics.rolling(window=5000, center=False, on='latency').mean()
rolling_mean.plot(title='Rolling average over 30 seconds', use_index=True)
Out[12]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc5ca694cc0>
In [13]:
metrics.plot.hist(y='latency')
Out[13]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fc5c7649b00>