Skip to content

Commit

Permalink
Merge pull request #12 from jtaleric/kube-burner-mem
Browse files Browse the repository at this point in the history
Adding memory query and small refactor
  • Loading branch information
shashank-boyapally authored Jan 22, 2024
2 parents 1d1d6c1 + 34ff117 commit ee763c7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Run pytest on Pull Request

on: [push,pull_request]
on: [push]

jobs:
test:
Expand Down
38 changes: 30 additions & 8 deletions fmatch/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ def burner_results(self, uuid, uuids, index):
runs = [item['_source'] for item in result["hits"]["hits"]]
return runs

def burner_cpu_results(self, uuids, namespace, index):
""" kube burner CPU aggregated results for a namespace
def burner_metric_query(self, uuids, namespace, index, metricName):
""" burner_metric_query will query for specific metricName data.
Args:
uuids (_type_): _description_
namespace (_type_): _description_
index (_type_): _description_
Returns:
_type_: _description_
uuids (list): List of uuids
namespace (str): namespace we are interested in
index (str): ES/OS Index to query from
metricName (str): metricName defined in kube-burner metrics
"""
ids = "\" OR uuid: \"".join(uuids)
query = {
Expand Down Expand Up @@ -239,7 +239,7 @@ def burner_cpu_results(self, uuids, namespace, index):
"query_string": {
"query": (
f'( uuid: \"{ids}\" )'
f' AND metricName: "containerCPU"'
f' AND metricName: {metricName}'
f' AND labels.namespace.keyword: {namespace}'
)
}
Expand All @@ -252,6 +252,28 @@ def burner_cpu_results(self, uuids, namespace, index):
data = self.parse_burner_cpu_results(runs)
return data

def burner_cpu_results(self, uuids, namespace, index):
""" kube burner CPU aggregated results for a namespace
Args:
uuids (_type_): _description_
namespace (_type_): _description_
index (_type_): _description_
Returns:
_type_: _description_
"""
return self.burner_metric_query(uuids, namespace, index, "containerCPU")

def burner_mem_results(self, uuids, namespace, index):
""" kube burner memory aggregated results for a namespace
Args:
uuids (_type_): _description_
namespace (_type_): _description_
index (_type_): _description_
Returns:
_type_: _description_
"""
return self.burner_metric_query(uuids, namespace, index, "containerMemory")

def parse_burner_cpu_results(self, data: dict):
""" parse out CPU data from kube-burner query
Args:
Expand Down
2 changes: 2 additions & 0 deletions fmatch/test_fmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
ids, "openshift-ovn-kubernetes", "ripsaw-kube-burner*")
etcd_cpu = match.burner_cpu_results(
ids, "openshift-etcd", "ripsaw-kube-burner*")
ovn_mem = match.burner_mem_results(
ids, "openshift-ovn-kubernetes", "ripsaw-kube-burner*")

podl_df = match.convert_to_df(
podl, columns=['uuid', 'timestamp', 'quantileName', 'P99'])
Expand Down

0 comments on commit ee763c7

Please sign in to comment.