Skip to content

Commit

Permalink
#22 fix the duplicated timeseries error
Browse files Browse the repository at this point in the history
which is caused by recreating metric exporters

Signed-off-by: Long Zhang <[email protected]>
  • Loading branch information
gluckzhang committed Nov 21, 2024
1 parent 6966493 commit ee7252a
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,24 @@ def validate_configs(config):


def main(config):
metric_exporters = []
for config_metric in config["metrics"]:
metric = MetricExporter(
polling_interval_seconds=config["polling_interval_seconds"],
aws_access_key=config["aws_access_key"],
aws_access_secret=config["aws_access_secret"],
aws_assumed_role_name=config["aws_assumed_role_name"],
targets=config["target_aws_accounts"],
metric_name=config_metric["metric_name"],
group_by=config_metric["group_by"],
metric_type=config_metric["metric_type"],
)
metric_exporters.append(metric)

start_http_server(config["exporter_port"])
while True:
for config_metric in config["metrics"]:
app_metrics = MetricExporter(
polling_interval_seconds=config["polling_interval_seconds"],
aws_access_key=config["aws_access_key"],
aws_access_secret=config["aws_access_secret"],
aws_assumed_role_name=config["aws_assumed_role_name"],
targets=config["target_aws_accounts"],
metric_name=config_metric["metric_name"],
group_by=config_metric["group_by"],
metric_type=config_metric["metric_type"],
)
app_metrics.run_metrics()
for exporter in metric_exporters:
exporter.run_metrics()
time.sleep(config["polling_interval_seconds"])


Expand Down

0 comments on commit ee7252a

Please sign in to comment.