Skip to content

Commit

Permalink
Adding memory query and small refactor
Browse files Browse the repository at this point in the history
Moving the burner query to something generic based on the `metricName`

Added burner_mem for us to also track memory usage

Signed-off-by: Joe Talerico <[email protected]>
  • Loading branch information
Joe Talerico committed Jan 22, 2024
1 parent 1d1d6c1 commit 71b52ce
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
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 71b52ce

Please sign in to comment.