设置 Slack (Set up Slack)
如果您希望将仪表板订阅或告警发送到 Slack 频道(或 Slack 上的用户),则管理员必须首先将您的 Metabase 与 Slack 集成。(If you want to have your dashboard subscriptions or alerts sent to Slack channels (or people on Slack), an admin must first integrate your Metabase with Slack.)
创建您的 Slack App (Create your Slack App)
为了让 Metabase 发布到您的 Slack 频道,您需要创建一个 Slack App 并使其可用于 Metabase。(For Metabase to post to your Slack channels, you’ll need to create a Slack App and make it available to Metabase.)
从任何 Metabase 页面,转到管理设置 > 设置 > 通知渠道 > Slack。(From any Metabase page, go to Admin settings > Settings > Notification channels > Slack.)
点击打开 Slack Apps。Metabase 将打开一个新的浏览器选项卡,并将您发送到 Slack 网站以创建 Slack 应用程序。(Click on Open Slack Apps. Metabase will open a new browser tab and send you over to the Slack website to create the Slack app.)
在 Slack 网站上,点击创建应用程序。(On the Slack website, click Create an App.)
选择一个工作区来开发您的应用程序 (Pick a workspace to develop your app)
选择您想要创建应用程序的工作区。(Select the workspace you want to create your app.)
应用程序清单 (The app manifest)
当您点击打开 Slack App 时,Metabase 将传递应用程序清单,Slack 将使用该清单来设置您的应用程序。(When you click on Open Slack App, Metabase will pass along the app manifest, which Slack will use to set up your app.)
您可能会收到一条警告,内容为 (You may get a warning that says)
此应用程序是根据第三方清单创建的 始终验证下面的 URL 和权限。(This app is created from a 3rd party manifest Always verify URLs and permissions below.)
此警告是预期之内的(Metabase 在这里是第三方)。您可以点击配置来查看 Metabase 在 URL 中发送的应用程序清单。以下是 YAML 格式的清单 (This warning is expected (Metabase is the third party here). You can click on Configure to see the app manifest Metabase sent along in the URL. Here is the manifest in YAML format)
_metadata:
major_version: 1
minor_version: 1
display_information:
name: Metabase
description: Bringing the power of Metabase to your Slack #channels!
background_color: "#509EE3"
features:
bot_user:
display_name: Metabase
oauth_config:
scopes:
bot:
- users:read
- channels:read
- channels:join
- files:write
- chat:write
- chat:write.customize
- chat:write.public
清单只是处理您应用程序的一些设置,并帮助加快进度。(The manifest just take cares of some settings for your app and helps speed things along.)
点击下一步按钮。然后点击创建以设置您的 Slack 应用程序。(Click the Next button. Then hit Create to set up your Slack app.)
将您的应用程序安装到您的工作区 (Install your app to your workspace)
在 Slack 网站上,针对您新创建的应用程序,在设置 > 基本信息选项卡中,在安装您的应用程序下,点击安装到工作区。在下一个屏幕上,点击允许以授予 Metabase 访问您的 Slack 工作区的权限。(On the Slack site for your newly created app, in the Settings > Basic Information tab, under Install your app, click on Install to workspace. On the next screen, click Allow to give Metabase access to your Slack workspace.)
Bot 用户 OAuth 令牌 (The Bot User OAuth Token)
在 Slack 网站页面上,针对您的 Slack 应用程序,在左侧的功能部分,点击 Slack Apps 侧边栏中的 OAuth 和权限,然后复制 Bot User OAuth Token。返回到 Metabase 中的 Slack 设置页面,并将此令牌粘贴到 Metabase 中具有相同名称的字段中。(On the Slack site page for your Slack app, on the left in the Features section, click on OAuth and Permissions in the Slack Apps sidebar and then copy the Bot User OAuth Token. Return to the Slack settings page in your Metabase and paste this token in the Metabase field with the same name.)
在您的 Slack 中创建一个频道来存储图像文件 (Create a channel in your Slack to store image files)
在您的 Slack 工作区中,创建一个您想要的公共频道名称 — 我们认为像 “metabase” 这样的名称就很好 — 然后在 Metabase 的存储图像文件的公共频道字段中输入该频道的名称。我们将在发送仪表板订阅之前在此处上传图表和表格。这允许您的 Metabase 发布到您的 Slack 工作区,而无需处理不必要的权限。确保您创建的频道与您在 Metabase 的此字段中输入的频道相同(省略 “#” 前缀)。(In your Slack workspace, create a public channel named whatever you want — we think something like “metabase” does just fine — then enter that channel’s name in the Public channel to store image files field in Metabase. We’ll upload charts and tables here before sending out dashboard subscriptions. This allows your Metabase to post to your Slack workspace without having to deal with unnecessary permissions. Make sure the channel you create is the same channel that you enter in this field in Metabase (omit the “#” prefix).)
如果您在 Slack 中重命名频道,您需要将 Metabase 中的存储图像文件的公共频道更新为该新名称。此频道不必与您发送仪表板订阅的频道相同。它仅用于存储图像文件。(If you rename the channel in Slack, you’ll need to update the Public channel to store image files in Metabase to that new name. This channel does not have to be the same as the channel where you send dashboard subscriptions. It’s only used for storing image files.)
保存您在 Metabase 中的更改 (Save your changes in Metabase)
在 Metabase 中,点击保存更改按钮,就完成了!Metabase 将自动运行快速测试,以检查 API 令牌和您的专用 Slack 频道是否正常工作。如果出现问题,它会给您一个错误消息。(In Metabase, click on the Save changes button and that’s it! Metabase will automatically run a quick test to check that the API token and your dedicated Slack channel are working properly. If something goes wrong, it’ll give you an error message.)
向私有 Slack 频道发送告警和订阅 (Sending alerts and subscriptions to private Slack channels)
为了向私有 Slack 频道发送订阅和告警,您必须首先将 Metabase 应用程序添加到私有频道。(In order to send subscriptions and alerts to private Slack channels, you must first add the Metabase app to the private channel.)
在 Slack 中,转到私有频道并提及 Metabase 应用程序。例如,如果您将您的 Slack 应用程序称为 “Metabase”,您只需键入 @Metabase
。Slack 将询问您是否要邀请您的应用程序加入您的频道,您应该这样做。(In Slack, go to the private channel and mention the Metabase app. For example, if you called your Slack app “Metabase”, you’d just type @Metabase
. Slack will ask you if you want to invite your app to your channel, which you should.)
一旦您的 Metabase 应用程序添加到私有频道,您需要在订阅或告警中输入私有频道的名称。确保正确拼写频道名称,否则 Metabase 将无法发送通知。(Once your Metabase app is added to the private channel, you’ll need to type out the private channel’s name in the subscription or alert. Make sure to spell the channel’s name correctly, or Metabase won’t be able to send the notification.)
延伸阅读 (Further reading)
- 告警 (Alerts)
- 仪表板订阅 (Dashboard subscriptions)
- 通知权限 (Notification permissions)
- 设置电子邮件 (Setting up email)
- 使用情况分析 (Usage analytics)
阅读其他版本的 Metabase 的文档。(Read docs for other versions of Metabase.)