Skip to content

Commit

Permalink
Merge pull request #91 from naved001/bucket-names
Browse files Browse the repository at this point in the history
  • Loading branch information
naved001 authored Dec 3, 2024
2 parents ef4e830 + 168193b commit 616a196
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions openshift_metrics/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Merges metrics from files and produces reports by pod and by namespace
"""

import os
import argparse
from datetime import datetime, UTC
import json
Expand Down Expand Up @@ -145,23 +146,24 @@ def main():
utils.write_metrics_by_pod(condensed_metrics_dict, pod_report_file, ignore_hours)

if args.upload_to_s3:
bucket_name = os.environ.get("S3_INVOICE_BUCKET", "nerc-invoicing")
primary_location = (
f"Invoices/{report_month}/"
f"Service Invoices/NERC OpenShift {report_month}.csv"
)
utils.upload_to_s3(invoice_file, "nerc-invoicing", primary_location)
utils.upload_to_s3(invoice_file, bucket_name, primary_location)

timestamp = datetime.utcnow().strftime('%Y%m%dT%H%M%SZ')
secondary_location = (
f"Invoices/{report_month}/"
f"Archive/NERC OpenShift {report_month} {timestamp}.csv"
)
utils.upload_to_s3(invoice_file, "nerc-invoicing", secondary_location)
utils.upload_to_s3(invoice_file, bucket_name, secondary_location)
pod_report_location = (
f"Invoices/{report_month}/"
f"Archive/Pod-NERC OpenShift {report_month} {timestamp}.csv"
)
utils.upload_to_s3(pod_report_file, "nerc-invoicing", pod_report_location)
utils.upload_to_s3(pod_report_file, bucket_name, pod_report_location)

if __name__ == "__main__":
main()
4 changes: 2 additions & 2 deletions openshift_metrics/openshift_prometheus_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ def main():
json.dump(metrics_dict, file)

if args.upload_to_s3:
utils.upload_to_s3(output_file, "openshift-metrics", s3_location)

bucket_name = os.environ.get("S3_METRICS_BUCKET", "openshift_metrics")
utils.upload_to_s3(output_file, bucket_name, s3_location)

if __name__ == "__main__":
main()

0 comments on commit 616a196

Please sign in to comment.