diff --git a/app/exporter.py b/app/exporter.py index 5790c74..edcbad1 100644 --- a/app/exporter.py +++ b/app/exporter.py @@ -12,8 +12,9 @@ class MetricExporter: - def __init__(self, polling_interval_seconds, aws_access_key, aws_access_secret, aws_assumed_role_name, group_by, targets): + def __init__(self, polling_interval_seconds, metric_name, aws_access_key, aws_access_secret, aws_assumed_role_name, group_by, targets): self.polling_interval_seconds = polling_interval_seconds + self.metric_name = metric_name self.targets = targets self.aws_access_key = aws_access_key self.aws_access_secret = aws_access_secret @@ -27,7 +28,7 @@ def __init__(self, polling_interval_seconds, aws_access_key, aws_access_secret, for group in group_by["groups"]: self.labels.add(group["label_name"]) self.aws_daily_cost_usd = Gauge( - "aws_daily_cost_usd", "Daily cost of an AWS account in USD", self.labels) + self.metric_name, "Daily cost of an AWS account in USD", self.labels) def run_metrics_loop(self): while True: diff --git a/exporter_config.yaml b/exporter_config.yaml index a61266f..60a91ff 100644 --- a/exporter_config.yaml +++ b/exporter_config.yaml @@ -1,5 +1,6 @@ exporter_port: $EXPORTER_PORT|9090 # the port that exposes cost metrics polling_interval_seconds: $POLLING_INTERVAL_SECONDS|28800 # by default it is 8 hours because for daily cost, AWS only updates the data once per day +metric_name: aws_daily_cost_usd # change the metric name if needed aws_access_key: $AWS_ACCESS_KEY # for prod deployment, DO NOT put the actual value here aws_access_secret: $AWS_ACCESS_SECRET # for prod deployment, DO NOT put the actual value here diff --git a/main.py b/main.py index 2c46159..fccdce6 100644 --- a/main.py +++ b/main.py @@ -55,6 +55,7 @@ def get_configs(): def main(config): app_metrics = MetricExporter( polling_interval_seconds=config["polling_interval_seconds"], + metric_name=config["metric_name"], aws_access_key=config["aws_access_key"], aws_access_secret=config["aws_access_secret"], aws_assumed_role_name=config["aws_assumed_role_name"],