【问题标题】:How to correctly configure Datadog with Slack?如何使用 Slack 正确配置 Datadog?
【发布时间】:2018-06-26 02:10:21
【问题描述】:

我目前正在使用这个link 在 Python 中编写一个程序,该程序将使用 Datadog API 为 POSTPUTDELETE 请求发送 curl 命令。到目前为止,该请求似乎正在按我的意愿触发,但它不会占用我的凭据。我不完全确定服务挂钩网址是什么,但我相信它可能是罪魁祸首。谁能告诉我如何为此找到以下 Slack 特定元素?

  • 帐户(这是您的 Slack 名称还是您的 Slack 句柄?假设我的 Slack 名称是“John Doe”,但我的句柄是“J.D.”)
  • Slack 服务挂钩 URL(不知道这是什么或在哪里可以找到)

这是我在 Python 中的测试脚本:

os.system("curl -v -X POST -H \"Content-type: application/json\" \
-d '{\
    \"service_hooks\": [\
        {\
            \"account\": \"[???]\",\
            \"url\": \"[???]\"\
        }\
    ],\
    \"channels\": [\
        {\
            \"channel_name\": \"[#???]\",\
            \"transfer_all_user_comments\": \"false\",\
            \"account\": \"[???]\"\
        }\
    ]\
}' \
\"https://api.datadoghq.com/api/v1/integration/slack?api_key=$"+[???]+"&application_key=$"+[???]+"\"");

结果是:

M-C02TW43FHV2Q:python foobar$ python main.py

Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 00.000.000.00...
* TCP_NODELAY set
* Connected to api.datadoghq.com (00.000.000.00) port 000 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_000_GCM_SH00000
* Server certificate: *.datadoghq.com
* Server certificate: COMODO RSA Domain Validation Secure Server CA
* Server certificate: COMODO RSA Certification Authority
> POST /api/v1/integration/slack?api_key=00000000000000000000000000000&application_key=00000000000000000000000000000000 HTTP/1.1
> Host: api.datadoghq.com
> User-Agent: curl/0.00.0
> Accept: */*
> Content-type: application/json
> Content-Length: 292
>
* upload completely sent off: 292 out of 292 bytes
< HTTP/1.1 403 Forbidden
< Date: Tue, 26 Jun 2018 01:42:25 GMT
< Content-Type: application/json
< Content-Length: 31
< Connection: keep-alive
< Vary: Accept-Encoding
< Pragma: no-cache
< Cache-Control: no-cache
< X-DD-VERSION: 00.000000
< DD-POOL: dogweb_sameorig
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Strict-Transport-Security: max-age=100000000;
<
* Connection #0 to host api.datadoghq.com left intact
{"errors": ["Invalid API key"]}M-000000000000:python foobar$

如果能帮助我查找此信息,我将不胜感激!

【问题讨论】:

    标签: python curl slack slack-api datadog


    【解决方案1】:

    在我看来,这些是 Datadog 特定的配置参数。因此,您首先需要将 Datadog 应用程序安装到您的 Slack 工作区,您可以在 Slack 应用程序目录中找到该工作区。

    这是官方文档中描述的过程:

    安装

    Slack 集成通过其集成磁贴安装在 数据狗应用程序。

    配置

    1. 在您的 Slack 帐户中,转到应用程序页面并搜索 数据狗。
    2. 点击安装,然后点击添加集成。
    3. 复制 Slack 服务挂钩并粘贴到服务挂钩字段中 Datadog 的 Slack。
    4. 添加您希望能够发布到的频道。
    5. 如果您希望收到图表上的每条评论的通知,请勾选 每个通道的复选框“Transfer all user cmets”。如果离开 未选中(默认)您将需要使用 @slack-channel_name 将 cmets 发布到 slack 的语法。

    来源:official documentation 来自 Datadog

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多