Created
November 14, 2018 22:19
-
-
Save alex-hofsteede/a3d3a6df537d3e7a71fa6eb90eca4d9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import plotly | |
import plotly.graph_objs as go | |
import re | |
import sys | |
import json | |
import math | |
from clickhouse_driver import Client | |
from itertools import combinations | |
client = Client(host='localhost', port=9001) | |
#select timestamp as ts, count() as c, round(avg(cache_get_ms)) as cg, round(avg(cache_set_ms)) as cs, round(avg(dedupe_wait_ms)) as dw, round(avg(rate_limit_ms)) as rl | |
#select count() as c, cache_get_ms, cache_set_ms, dedupe_wait_ms, rate_limit_ms | |
query = """ | |
select count() as c, round(avg(cache_get_ms)) as cg, round(avg(cache_set_ms)) as cs, round(avg(dedupe_wait_ms)) as dw, round(avg(rate_limit_ms)) as rl, round(avg(validate_schema_ms)) as vs | |
from perf.snuba_queries | |
where result_status != 429 and toDate(timestamp) > '2018-08-28' group by timestamp limit 1000 | |
""" | |
print query | |
data, meta= client.execute(query, with_column_types=True) | |
#from random import normalvariate as r | |
#data = [[[max(1, r(10, 10)) for _ in range(100)] for _ in range(5)] for _ in range(5000)] | |
#data = [[sum(p)/len(p) for p in d] for d in data] | |
series = combinations([('count', 0), ('cache get', 1), ('cache set', 2), ('dedupe wait', 3), ('rate limit', 4), ('validate_schema', 5)], 2) | |
plotly.offline.plot({ | |
"data": [go.Scatter(x=[i[xx[1]] for i in data], y=[i[yy[1]] for i in data], mode='markers', name='{},{}'.format(xx[0], yy[0])) for xx, yy in series], | |
"layout": go.Layout( | |
title="scatter", | |
xaxis={'title': 'cg'}, yaxis={'title': 'cs'} | |
) | |
}, auto_open=True, filename="redis-grouped-averages.html") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment