Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding memory query and small refactor #12

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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