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

CloudwatchMetrics Alerts not working #616

Open
call-stack opened this issue Aug 17, 2023 · 1 comment
Open

CloudwatchMetrics Alerts not working #616

call-stack opened this issue Aug 17, 2023 · 1 comment

Comments

@call-stack
Copy link

What happened?

Setting up a cloudwatch alert on metric. But when I am opening the alert in grafana. Getting below error.
Screenshot 2023-08-17 at 11 43 24 AM

but when I re-select the same datasource from the list(done in UI) again, it worked.

How to reproduce it?

Below is the code I am using to setup alert.

cloudwatch_alert = AlertRulev9(
    title="Test Alert",
    condition="B",
    triggers=[
        CloudwatchMetricsTarget(
            datasource="fO0jguEGk",
            refId="A",
            dimensions={
                "ClusterName": "test-cluster-qa",
                "ServiceName":"test-cluster-qa-jamuna"
            },
            metricName = "RunningTaskCount",
            namespace="ECS/ContainerInsights"
        ),
        AlertExpression(
            refId="B",
            expressionType=EXP_TYPE_CLASSIC,
            expression='A',
            conditions=[
               AlertCondition(
                   evaluator=LowerThan(1),
                   operator=OP_AND,
                   reducerType=RTYPE_MIN

               )
            ]
        )
    ],
    evaluateFor="3m",
)


# An AlertGroup is one group contained in an alert folder.
alertgroup = AlertGroup(
    name="test-alert-group",
    rules=[
        cloudwatch_alert
    ]
)

my_alergroup_json = json.dumps(alertgroup.to_json_data())
@call-stack
Copy link
Author

call-stack commented Aug 17, 2023

Removing "datasource": self.datasource, from CloudwatchMetricsTarget inside grafanalib/cloudwatch.py fixed issue for me. Not sure if that is a correct way to handle it but temporarily it working fine for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant