Skip to content

CloudwatchMetrics Alerts not working #616

Open
@call-stack

Description

@call-stack

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())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions