Skip to content

Commit

Permalink
adding commit hash as a tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishnu Challa committed Oct 24, 2023
1 parent 79ec362 commit a5155fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 0 additions & 5 deletions assets/kube-burner-report-ocp-wrapper/queries.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -1276,8 +1276,6 @@ local elasticsearch = g.query.elasticsearch;
+ elasticsearch.withQuery(query)
+ elasticsearch.withTimeField('timestamp'),
queries(): [
self.base("Available", "uuid.keyword: $uuid AND metricName.keyword: \"nodeMemoryAvailable-Masters\" AND labels.instance.keyword: $master"),
self.base("Total", "uuid.keyword: $uuid AND metricName.keyword: \"nodeMemoryTotal-Masters\" AND labels.instance.keyword: $master"),
self.base("Utilization", "uuid.keyword: $uuid AND metricName.keyword: \"nodeMemoryUtilization-Masters\" AND labels.instance.keyword: $master"),
],
},
Expand Down Expand Up @@ -1362,8 +1360,6 @@ local elasticsearch = g.query.elasticsearch;
+ elasticsearch.withQuery(query)
+ elasticsearch.withTimeField('timestamp'),
queries(): [
self.base("available", "uuid.keyword: $uuid AND metricName.keyword: \"nodeMemoryAvailable-Workers\" AND labels.instance.keyword: \"$worker\""),
self.base("Total", "uuid.keyword: $uuid AND metricName.keyword: \"nodeMemoryTotal-Workers\" AND labels.instance.keyword: $worker"),
self.base("Utilization", "uuid.keyword: $uuid AND metricName.keyword: \"nodeMemoryUtilization-Workers\" AND labels.instance.keyword: $worker"),
],
},
Expand Down Expand Up @@ -1534,7 +1530,6 @@ local elasticsearch = g.query.elasticsearch;
+ elasticsearch.withTimeField('timestamp'),
queries(): [
self.base("Available", "uuid.keyword: $uuid AND metricName.keyword: \"nodeMemoryAvailable-AggregatedWorkers\""),
self.base("Total", "uuid.keyword: $uuid AND metricName.keyword: \"nodeMemoryTotal-AggregatedWorkers\""),
],
},
aggWorkerNodeContainerCpuUsage: {
Expand Down
9 changes: 7 additions & 2 deletions dittybopper/syncer/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ class GrafanaOperations:
"""
This class is responsible for Grafana operations
"""
def __init__(self, grafana_url: str, input_directory: str):
def __init__(self, grafana_url: str, input_directory: str, git_commit_hash: str):
self.grafana_url = grafana_url
self.input_directory = input_directory
self.git_commit_hash = git_commit_hash
self.dashboards = defaultdict(list)
self.folder_map = dict()
self.logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -102,6 +103,10 @@ def create_dashboards(self):
for folder_id, files in self.dashboards.items():
for json_file in set(files):
dashboard_json = self.read_dashboard_json(json_file)
if "tags" in dashboard_json.keys():
dashboard_json["tags"].append(self.git_commit_hash)
else:
dashboard_json["tags"] = self.git_commit_hash
try:
response = requests.post(
f"{self.grafana_url}/api/dashboards/db",
Expand All @@ -122,7 +127,7 @@ def create_dashboards(self):
raise Exception(f"Error creating dashboard '{dashboard_json['title']}' in folder '{folder_id}'. Message: {e}")

if __name__ == '__main__':
grafana_operations = GrafanaOperations(os.environ.get("GRAFANA_URL"), os.environ.get("INPUT_DIR"))
grafana_operations = GrafanaOperations(os.environ.get("GRAFANA_URL"), os.environ.get("INPUT_DIR"), os.environ.get("GIT_COMMIT_HASH"))
grafana_operations.fetch_all_dashboards()
grafana_operations.create_dashboards()
while True:
Expand Down

0 comments on commit a5155fd

Please sign in to comment.