diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e7e7b46e..34c3ac04 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,15 +2,15 @@ Changelog ========= -x.x.x ? -* Fix mappings for Table -================== +x.x.x ? +======= -* Added ... +* Fix mappings for Table +* Added support for AWS Cross-Account in CloudwatchMetricsTarget 0.7.1 2024-01-12 -================== +================ * Extended DashboardLink to support links to dashboards and urls, as per the docs_ diff --git a/grafanalib/cloudwatch.py b/grafanalib/cloudwatch.py index a9a22248..f72d891b 100644 --- a/grafanalib/cloudwatch.py +++ b/grafanalib/cloudwatch.py @@ -1,8 +1,8 @@ """Helpers to create Cloudwatch-specific Grafana queries.""" import attr - from attr.validators import instance_of + from grafanalib.core import Target @@ -22,6 +22,8 @@ class CloudwatchMetricsTarget(Target): :param expression: Cloudwatch Metric math expressions :param id: unique id :param matchExact: Only show metrics that exactly match all defined dimension names. + :param account: AWS Account where Cloudwatch is used + :param accountId: AWS Account ID where Cloudwatch is used :param metricName: Cloudwatch metric name :param namespace: Cloudwatch namespace :param period: Cloudwatch data period @@ -32,11 +34,14 @@ class CloudwatchMetricsTarget(Target): :param hide: controls if given metric is displayed on visualization :param datasource: Grafana datasource name """ + alias = attr.ib(default="") dimensions = attr.ib(factory=dict, validator=instance_of(dict)) expression = attr.ib(default="") id = attr.ib(default="") matchExact = attr.ib(default=True, validator=instance_of(bool)) + account = attr.ib(default="") + accountId = attr.ib(default="") metricName = attr.ib(default="") namespace = attr.ib(default="") period = attr.ib(default="") @@ -48,13 +53,14 @@ class CloudwatchMetricsTarget(Target): datasource = attr.ib(default=None) def to_json_data(self): - return { "alias": self.alias, "dimensions": self.dimensions, "expression": self.expression, "id": self.id, "matchExact": self.matchExact, + "account": self.account, + "accountId": self.accountId, "metricName": self.metricName, "namespace": self.namespace, "period": self.period, @@ -88,6 +94,7 @@ class CloudwatchLogsInsightsTarget(Target): :param hide: controls if given metric is displayed on visualization :param datasource: Grafana datasource name """ + expression = attr.ib(default="") id = attr.ib(default="") logGroupNames = attr.ib(factory=list, validator=instance_of(list)) @@ -99,7 +106,6 @@ class CloudwatchLogsInsightsTarget(Target): datasource = attr.ib(default=None) def to_json_data(self): - return { "expression": self.expression, "id": self.id,