Skip to content

Commit

Permalink
fix: metrics for all resources if not defined otherwise (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias authored Oct 2, 2024
1 parent c749a30 commit 2fe9888
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions collect_single/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ instances_total:
account_score:
description: Account score by account and cloud
# Needs to be inline with fixbackend report summary
only_on_collected_accounts: true
search: |
aggregate(
id as account_id,
Expand Down
2 changes: 2 additions & 0 deletions collect_single/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class MetricQuery:
description: str
search: str
factor: Optional[int]
only_on_collected_accounts: bool

@staticmethod
def from_json(name: str, js: Json) -> MetricQuery:
Expand All @@ -19,4 +20,5 @@ def from_json(name: str, js: Json) -> MetricQuery:
description=js["description"],
search=js["search"],
factor=js.get("factor"),
only_on_collected_accounts=js.get("only_on_collected_accounts", False),
)
3 changes: 2 additions & 1 deletion collect_single/post_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ async def create_timeseries(self) -> None:
# create metrics
account_ids = [ac.account_id for ac in self.accounts_collected]
for metric in self.load_metrics():
res = await self.core_client.timeseries_snapshot(metric, account_ids)
on_accounts = account_ids if metric.only_on_collected_accounts else None
res = await self.core_client.timeseries_snapshot(metric, on_accounts)
if res:
log.info(f"Created timeseries snapshot: {metric.name} created {res} entries")
# downsample all timeseries
Expand Down

0 comments on commit 2fe9888

Please sign in to comment.