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

feat: add account to CloudwatchMetricsTarget #661

Merged
merged 4 commits into from
Jul 16, 2024
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
10 changes: 5 additions & 5 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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_

Expand Down
12 changes: 9 additions & 3 deletions grafanalib/cloudwatch.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Helpers to create Cloudwatch-specific Grafana queries."""

import attr

from attr.validators import instance_of

from grafanalib.core import Target


Expand All @@ -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
Expand All @@ -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="")
Expand All @@ -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,
Expand Down Expand Up @@ -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))
Expand All @@ -99,7 +106,6 @@ class CloudwatchLogsInsightsTarget(Target):
datasource = attr.ib(default=None)

def to_json_data(self):

return {
"expression": self.expression,
"id": self.id,
Expand Down
Loading