So I setup a notification channel with:
gcloud alpha monitoring channels create \
--description='test notification' \
--display-name='test_channel' \
--type=email \
[email protected]
But I can't seem to get an Alert Policy to work with the command line (trying to avoid using load from file as I would need to use a template). It seems like this should work:
gcloud alpha monitoring policies create \
--notification-channels=test_channel \
--aggregation='{"alignmentPeriod": "60s","perSeriesAligner": "ALIGN_MEAN"}' \
--condition-display-name='CPU Utilization >0.80 for 10m'\
--condition-filter='metric.type="appengine.googleapis.com/flex/instance/cpu/utilization" resource.type="gae_instance"' \
--duration='1min' \
--if='> 0.80' \
--display-name='test alert'
But it returns:
Invalid value for [--aggregation]: Should only be specified if --condition-filter is also specified.
However, as you can see, there's a --condition-filter flag above. I tried reordering it so --condition-filter appears before --aggregation, but this is causing a duration error, although it already matches the documentation, and slight edits like =60s, =1min, or adding quotes around the time in --aggregation doesn't seem to help:
gcloud alpha monitoring policies create \
--notification-channels=test_channel \
--condition-filter='metric.type=appengine.googleapis.com/flex/instance/cpu/utilization resource.type=gae_instance' \
--aggregation='{"alignmentPeriod": "20s","perSeriesAligner": "ALIGN_MEAN"}' \
--condition-display-name='CPU Utilization >0.80 for 1m'\
--duration='1min' \
--if='> 0.80' \
--display-name='test alert'
What is wrong? Why am I getting these errors?
--combiner='AND', I think I could also have done something like--condition-filter="resource.type=\"global\" AND metric.type=\"logging.googleapis.com/user/vpc_firewall_changes\"". And docs got me on an incorrect1minformatting, when it should be1mwhich I had tried but with other errors. The flagChannel Name: my-channelthrew me off on notification-channels, docs do mention ID but missed that and thought all flags would work.