Datadog公式のツール dog 使用方法まとめ comment 編です。
目次
Events に表示されるコメント(メッセージ)の操作が行えます。
サブコマンド |
説明 |
post |
コメント送信 |
update |
コメント更新 |
reply |
コメントへの返信 |
show |
コメント情報取得 |
delete |
コメント削除 |
コメントの一覧を取得するAPIは用意されていません。
更新系の操作はコメントIDを引数として与える必要がありますが、Web UIでIDを確認する、postしたコメントで戻り値を取得しておく等、IDを取得する術を用意しなくてはならず使い勝手はよくないです。(利用頻度は低そうです)
post
usage: dog comment post [-h] [--handle HANDLE] [comment]
実行例
$ dog comment post "PostTest"
id 9999999999999999999
url /event/event?id=9999999999999999999
resource /api/v1/comments/9999999999999999999
handle hoge@example.com
message u'PostTest'
HANDLE にはDatadogのユーザを指定するようです。存在しないユーザの場合はエラーとなります。
$ dog comment post --handle "hoge" "PostTest hoge"
ERROR: The value provided for parameter 'handle' is invalid
$ dog comment post --handle "user@example.com" "PostTest user"
id 9999999999999999999
url /event/event?id=9999999999999999999
resource /api/v1/comments/9999999999999999999
handle user@example.com
message u'PostTest user'
update
対象の comment_id が必要です。
対象コメントが直接書き換わります。(履歴は残りません)
usage: dog comment update [-h] [--handle HANDLE] comment_id [comment]
実行例
$ dog comment update 9999999999999999999 "CommentUpdate"
id 9999999999999999999
url /event/event?id=9999999999999999999
resource /api/v1/comments/9999999999999999999
handle hoge@example.com
message u'CommentUpdate'
replay
対象の comment_id が必要です。
対象コメントへ返信の付与になります。
usage: dog comment reply [-h] [--handle HANDLE] comment_id [comment]
実行例
$ dog comment reply 9999999999999999999 "ReplyTest"
id 9999999999999999990
url /event/event?id=9999999999999999990
resource /api/v1/comments/9999999999999999990
handle hoge@example.com
message u'ReplyTest'
show
対象の comment_id が必要です。一覧取得はできません。
usage: dog comment show [-h] comment_id
実行例
返信(reply)のコメントID指定は取得できません(エラーになります)
# コメントを指定
$ dog comment show 9999999999999999999
id 9999999999999999999
url /event/event?id=9999999999999999999
resource /api/v1/events/9999999999999999999
message u'CommentUpdate'
# コメントのreplyを指定
$ dog comment show 9999999999999999990
ERROR: No event matches that comment_id.
delete
対象の comment_id が必要です。
対象コメント・返信を削除します。(responseも無く、履歴は残りません)
コメントを削除するとそのコメントに対する返信もまとめて消えます。
存在しない id 指定は 500 エラーが返ります。
usage: dog comment delete [-h] comment_id
実行例
# コメントのreplyを指定
$ dog comment delete 9999999999999999990
# コメントを指定
$ dog comment delete 9999999999999999999
# 削除済みコメントを指定
$ dog comment delete 9999999999999999999
Traceback (most recent call last):
File "/usr/bin/dog", line 9, in <module>
load_entry_point('datadog==0.15.0', 'console_scripts', 'dog')()
File "/usr/lib/python2.7/site-packages/datadog/dogshell/__init__.py", line 69, in main
args.func(args)
File "/usr/lib/python2.7/site-packages/datadog/dogshell/comment.py", line 166, in _delete
res = api.Comment.delete(id)
File "/usr/lib/python2.7/site-packages/datadog/api/resources.py", line 110, in delete
return APIClient.submit('DELETE', cls._class_url + "/" + str(id), **params)
File "/usr/lib/python2.7/site-packages/datadog/api/api_client.py", line 129, in submit
proxies=_proxies, verify=_cacert
File "/usr/lib/python2.7/site-packages/datadog/api/http_client.py", line 84, in request
raise HTTPError(e.response.status_code, result.reason)
datadog.api.exceptions.HTTPError: Datadog returned a bad HTTP response code: 500 - Internal Server Error. Please try again later. If the problem persists, please contact support@datadoghq.com
サポートへのメッセージポストで利用できるかなと思いました。(他に用途が浮かびませんでした)
Messages in the event stream containing @support-datadog will reach our Support Team.