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

make metric name configurable #4

Merged
merged 1 commit into from
Dec 8, 2023
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
5 changes: 3 additions & 2 deletions app/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions exporter_config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down