qontract-reconcile 0.10.1rc704__py3-none-any.whl → 0.10.1rc705__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: qontract-reconcile
3
- Version: 0.10.1rc704
3
+ Version: 0.10.1rc705
4
4
  Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
5
5
  Home-page: https://github.com/app-sre/qontract-reconcile
6
6
  Author: Red Hat App-SRE Team
@@ -136,8 +136,9 @@ reconcile/aus/version_gates/ingress_gate_handler.py,sha256=ZCtyggBzzcb0prtdbMpJs
136
136
  reconcile/aus/version_gates/ocp_gate_handler.py,sha256=RW1ppDaCZXVegV9AzzqYXxDUu_Z_7d43Z5h2Pk_piKc,716
137
137
  reconcile/aus/version_gates/sts_version_gate_handler.py,sha256=PhJ7yBh2q-rv9CJcfFhc0H11nyDyG7NAryNS3F74xdY,3697
138
138
  reconcile/aws_account_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
139
- reconcile/aws_account_manager/integration.py,sha256=TLlhxnHXRCVz2GYJQei-dBdSpeLseEkoVUwHhgi41fk,13804
139
+ reconcile/aws_account_manager/integration.py,sha256=eYWP5zrLwSOYcAN8ym0RxU1Gri_Fwovho_X1AxUQMXc,15049
140
140
  reconcile/aws_account_manager/merge_request_manager.py,sha256=zZct3NxWMBQupl4QfD7ULxnt4ipt_2FBoH_NusboIuw,3781
141
+ reconcile/aws_account_manager/metrics.py,sha256=YB10ea4kIGwJfs5N14RF-RoXPb-QQWaDBz1jLZ3YWE0,917
141
142
  reconcile/aws_account_manager/reconciler.py,sha256=AqAA3TIEfuYzIogHSBgwYTebxbTy1D6JhcxdLiOfCsc,13588
142
143
  reconcile/aws_account_manager/utils.py,sha256=K4rAjEMK-eQ_Sv4lOf6dPynQy97xZ4h-n6cJn5Z6zVw,1248
143
144
  reconcile/aws_ami_cleanup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -753,8 +754,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
753
754
  tools/test/test_qontract_cli.py,sha256=UEwAW7PA_GIrbqzaLxpkCxbuVjEFLNvnVG-6VyoCGIc,4147
754
755
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
755
756
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
756
- qontract_reconcile-0.10.1rc704.dist-info/METADATA,sha256=WN9XTRmfJLwGjwt5biVtNZ1_iakFkhuYPTPoPCzM0uI,2382
757
- qontract_reconcile-0.10.1rc704.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
758
- qontract_reconcile-0.10.1rc704.dist-info/entry_points.txt,sha256=rIxI5zWtHNlfpDeq1a7pZXAPoqf7HG32KMTN3MeWK_8,429
759
- qontract_reconcile-0.10.1rc704.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
760
- qontract_reconcile-0.10.1rc704.dist-info/RECORD,,
757
+ qontract_reconcile-0.10.1rc705.dist-info/METADATA,sha256=YtGSBbEgiTX-KjpVXGWDJUurUpGAlTHRnByM79rRMd4,2382
758
+ qontract_reconcile-0.10.1rc705.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
759
+ qontract_reconcile-0.10.1rc705.dist-info/entry_points.txt,sha256=rIxI5zWtHNlfpDeq1a7pZXAPoqf7HG32KMTN3MeWK_8,429
760
+ qontract_reconcile-0.10.1rc705.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
761
+ qontract_reconcile-0.10.1rc705.dist-info/RECORD,,
@@ -5,6 +5,11 @@ from typing import Any
5
5
  import jinja2
6
6
 
7
7
  from reconcile.aws_account_manager.merge_request_manager import MergeRequestManager
8
+ from reconcile.aws_account_manager.metrics import (
9
+ NonOrgAccountCounter,
10
+ OrgAccountCounter,
11
+ PayerAccountCounter,
12
+ )
8
13
  from reconcile.aws_account_manager.reconciler import AWSReconciler
9
14
  from reconcile.aws_account_manager.utils import validate
10
15
  from reconcile.gql_definitions.aws_account_manager.aws_accounts import (
@@ -18,7 +23,7 @@ from reconcile.gql_definitions.aws_account_manager.aws_accounts import (
18
23
  from reconcile.typed_queries.app_interface_repo_url import get_app_interface_repo_url
19
24
  from reconcile.typed_queries.github_orgs import get_github_orgs
20
25
  from reconcile.typed_queries.gitlab_instances import get_gitlab_instances
21
- from reconcile.utils import gql
26
+ from reconcile.utils import gql, metrics
22
27
  from reconcile.utils.aws_api_typed.api import AWSApi, AWSStaticCredentials
23
28
  from reconcile.utils.aws_api_typed.iam import AWSAccessKey
24
29
  from reconcile.utils.defer import defer
@@ -297,6 +302,31 @@ class AwsAccountMgmtIntegration(
297
302
  ) as account_aws_api:
298
303
  self.reconcile_account(account_aws_api, reconciler, account)
299
304
 
305
+ def expose_metrics(
306
+ self,
307
+ payer_accounts: list[AWSAccountV1],
308
+ non_organization_accounts: list[AWSAccountV1],
309
+ ) -> None:
310
+ """Expose metrics."""
311
+ with metrics.transactional_metrics(self.name) as metrics_container:
312
+ metrics_container.set_gauge(
313
+ PayerAccountCounter(flavor=self.params.flavor),
314
+ value=len(payer_accounts),
315
+ )
316
+
317
+ for payer_account in payer_accounts:
318
+ metrics_container.set_gauge(
319
+ OrgAccountCounter(
320
+ flavor=self.params.flavor,
321
+ payer_account=payer_account.name,
322
+ ),
323
+ value=sum([len(payer_account.organization_accounts or [])]),
324
+ )
325
+ metrics_container.set_gauge(
326
+ NonOrgAccountCounter(flavor=self.params.flavor),
327
+ value=len(non_organization_accounts),
328
+ )
329
+
300
330
  @defer
301
331
  def run(self, dry_run: bool, defer: Callable | None = None) -> None:
302
332
  """Run the integration."""
@@ -328,6 +358,11 @@ class AwsAccountMgmtIntegration(
328
358
  account_template = gql_api.get_resource(path=self.params.account_tmpl_resource)[
329
359
  "content"
330
360
  ]
361
+
362
+ self.expose_metrics(
363
+ payer_accounts=payer_accounts,
364
+ non_organization_accounts=non_organization_accounts,
365
+ )
331
366
  self.reconcile_payer_accounts(
332
367
  reconciler=reconciler,
333
368
  merge_request_manager=merge_request_manager,
@@ -0,0 +1,39 @@
1
+ from pydantic import BaseModel
2
+
3
+ from reconcile.utils.metrics import GaugeMetric
4
+
5
+
6
+ class BaseMetric(BaseModel):
7
+ """Base class for all AWS account manager metrics."""
8
+
9
+ flavor: str
10
+
11
+ @classmethod
12
+ def name(cls) -> str:
13
+ return "aws_account_manager"
14
+
15
+
16
+ class PayerAccountCounter(BaseMetric, GaugeMetric):
17
+ """Number of managed payer accounts."""
18
+
19
+ @classmethod
20
+ def name(cls) -> str:
21
+ return super().name() + "_payer_account_count"
22
+
23
+
24
+ class OrgAccountCounter(BaseMetric, GaugeMetric):
25
+ """Number of managed organization accounts per payer account."""
26
+
27
+ payer_account: str
28
+
29
+ @classmethod
30
+ def name(cls) -> str:
31
+ return super().name() + "_org_account_count"
32
+
33
+
34
+ class NonOrgAccountCounter(BaseMetric, GaugeMetric):
35
+ """Number of managed non-organization accounts."""
36
+
37
+ @classmethod
38
+ def name(cls) -> str:
39
+ return super().name() + "_non_org_account_count"