Search code examples
google-cloud-functionsgoogle-cloud-monitoring

Protocol message Condition has no "conditionAbsent" field error with create_alert_policy method


I'm trying to create an alert policy with Cloud Functions in python. I have the following very simple alert policy:

alert_policy = {
    'combiner': 'OR',
    'conditions': [
        {
            'conditionAbsent': {
                'duration': '3900s',
                'filter': 'resource.type = "l7_lb_rule" AND metric.type = "logging.googleapis.com/user/name_stuff_here"'
            }
        }
    ]
}

When running the function I have the following error: Protocol message Condition has no "conditionAbsent" field error

How should I write this alert Policy? I also had some error because of Displayname field which I've removed entirely. Is there an alert policy builder or something like that where I can validate alerts json?


Solution

  • Looking more closely at the documentation I found that conditionAbsent should be passed as condition_absent