我希望设置一些来自gcloud ->松弛的警报,到目前为止已经按照以下说明进行了测试和运行:
ga=2.190773474.-879257953.1550134526#slack
但是,理想情况下,我应该将这些通知的配置存储在一个terraform脚本中,以便在需要再次设置的情况下不需要执行手动步骤。看起来这是可能的:channel.html
我已经运行了gcloud alpha monitoring channel-descriptors describe projects/<My Project>/notificationChannelDescriptors/slack,它为labels+type生成了以下输出:
labels:
- description: A permanent authentication token provided by Slack. This field is obfuscated
by returning only a few characters of the key when fetched.
key: auth_token
- description: The Slack channel to which to post notifications.
key: channel_name
type: slack因此,我认为通知通道的terraform配置应该是:
resource "google_monitoring_notification_channel" "basic" {
display_name = "My slack notifications"
type = "slack"
labels = {
auth_token = "????????"
channel_name = "#notification-channel"
}
}但是,我不知道如何为这个脚本获取auth令牌?我似乎无法从或 gcloud中提取我已经设置的一个,也找不到任何从头开始创建一个.
注:这是而不是特定于Terraform的问题,因为脚本只是连接到google。因此,任何直接使用API的人也必须从某个地方获得这个auth_token。必须有一种有目的的方法来获得它,或者为什么它会在API中.?
发布于 2019-06-08 22:08:47
发布于 2022-02-20 19:23:14
一个诀窍是创建您自己的Slack并使用它的oauth令牌。如果你知道怎么做就很简单了。当我自己研究这个问题的时候,我发现了一篇很棒的博客文章,它解释了https://bradtho.github.io/technology/gcp-alerting/
或者,您可以设置默认的Google集成,并在单击“发送测试通知”时检查网络调用。POST有效负载包含令牌。
https://stackoverflow.com/questions/54884815
复制相似问题