Datadog 公式 CLI ツール「Pup CLI」を試してみた

Datadog 公式 CLI ツール「Pup CLI」を試してみた

Datadog 公式 CLI ツール「Pup CLI」のインストールから OAuth2 ログイン、モニター取得やログ検索まで一通りやってみました。 OAuth2 認証により API キー・APP キーの管理が不要になり、コマンドラインから安全に Datadog を操作できます。
2026.02.13

こんにちは。オペレーション部のしいなです。

はじめに

Datadog の操作をコマンドラインから行いたいと思ったことはないでしょうか。
公式 CLI ツール「Pup CLI」がプレビュー版として公開されました。
OAuth2 認証に対応しているため、キーの管理を必要とせず、安全に Datadog を操作できます。
macOS へのインストールから OAuth2 ログイン、各種コマンドの実行までを一通り試してみました。

Pup CLI とは

Datadog API との簡単な対話を可能にする Go ベースのコマンドラインツールです。

https://github.com/DataDog/pup

大きな特徴として、OAuth2 認証をサポートしている点があります。
Datadog API をリクエストするには Datadog API キーや APP キーが必要でしたが、ブラウザベース認証によって安全に Datadog を操作することができます。(※従来の API キー認証も引き続き利用可能)
コマンド自体がシンプルなため、直感的な操作が可能です。
出力形式は JSON、Table、YAML をサポートしています。

利用可能なコマンド

プレビュー版のため対応範囲はまだ限定的ですが、メトリクス、ログ、APM など主要なドメインの参照系コマンドは既に利用可能です。
コマンドリファレンスは以下から確認できます。
https://github.com/DataDog/pup/blob/main/docs/COMMANDS.md

使ってみた

macOS へ Pup CLI をインストールし、実際にコマンドによる操作を行ってみます。

前提

  • Datadog アカウントが利用可能

インストール

brew を使ってインストールしていきます。

brew tap datadog/pack
brew install datadog/pack/pup
==> Fetching downloads for: pup
✔︎ Bottle Manifest go (1.25.7_1)                      Downloaded    7.5KB/  7.5KB
✔︎ Formula pup (0.7.0)                                Verified    184.5KB/184.5KB
✔︎ Bottle go (1.25.7_1)                               Downloaded   57.5MB/ 57.5MB
==> Installing pup from datadog/pack
Error: Your Command Line Tools are too outdated.
Update them from Software Update in System Settings.

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 26.0.

エラーとなってしまいました。
Command Line Tools for Xcode のバージョンが古いことが原因のようです。
一度、macOS のソフトウェアアップデートを確認し、Xcode Command Line Tools を更新してから再度試してみます。

brew install datadog/pack/pup
出力
==> Auto-updating Homebrew...
Adjust how often this is run with `$HOMEBREW_AUTO_UPDATE_SECS` or disable with
`$HOMEBREW_NO_AUTO_UPDATE=1`. Hide these hints with `$HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).
==> Fetching downloads for: pup
✔︎ Bottle Manifest go (1.25.7_1)                                                                                                                  Downloaded    7.5KB/  7.5KB
✔︎ Bottle go (1.25.7_1)                                                                                                                           Downloaded   57.5MB/ 57.5MB
✔︎ Formula pup (0.7.0)                                                                                                                            Verified    184.5KB/184.5KB
==> Installing pup from datadog/pack
==> Installing datadog/pack/pup dependency: go
==> Pouring go--1.25.7_1.arm64_tahoe.bottle.tar.gz
🍺  /opt/homebrew/Cellar/go/1.25.7_1: 14,442 files, 203.3MB
==> go build -ldflags=-s -w
🍺  /opt/homebrew/Cellar/pup/0.7.0: 9 files, 21.6MB, built in 35 seconds
==> Running `brew cleanup pup`...
Disable this behaviour by setting `HOMEBREW_NO_INSTALL_CLEANUP=1`.
Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).
==> `brew cleanup` has not been run in the last 30 days, running now...
Disable this behaviour by setting `HOMEBREW_NO_INSTALL_CLEANUP=1`.
Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/aom_bottle_manifest--3.13.1... (32.2KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/aom--3.13.1... (4.2MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/aribb24_bottle_manifest--1.0.4... (14.7KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/aribb24--1.0.4... (73.9KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/ca-certificates_bottle_manifest--2025-09-09... (2KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/ca-certificates--2025-09-09... (133KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/cairo_bottle_manifest--1.18.4-1... (37KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/cairo--1.18.4... (1.6MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/cjson_bottle_manifest--1.7.19... (11.2KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/cjson--1.7.19... (58.7KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/dav1d_bottle_manifest--1.5.1... (9.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/dav1d--1.5.1... (361KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/ffmpeg_bottle_manifest--8.0_1... (131.1KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/ffmpeg--8.0_1... (21.6MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/flac_bottle_manifest--1.5.0... (12.5KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/flac--1.5.0... (555.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/fontconfig_bottle_manifest--2.17.1-1... (17.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/fontconfig--2.17.1... (400.6KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/freetype_bottle_manifest--2.14.1_1... (9.2KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/freetype--2.14.1_1... (991KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/frei0r_bottle_manifest--2.4.0... (9.5KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/frei0r--2.4.0... (688.6KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/fribidi_bottle_manifest--1.0.16... (10KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/fribidi--1.0.16... (98.4KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/gettext_bottle_manifest--0.26... (17.9KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/gettext--0.26... (9.6MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/giflib_bottle_manifest--5.2.2... (10.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/giflib--5.2.2... (152.9KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/glib_bottle_manifest--2.86.0... (24.4KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/glib--2.86.0... (9.2MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/gmp_bottle_manifest--6.3.0... (13.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/gmp--6.3.0... (1MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/gnutls_bottle_manifest--3.8.10... (25.4KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/gnutls--3.8.10... (3.2MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/graphite2_bottle_manifest--1.3.14... (14.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/graphite2--1.3.14... (91.6KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/harfbuzz_bottle_manifest--12.1.0... (29.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/harfbuzz--12.1.0... (3.3MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/highway_bottle_manifest--1.3.0... (9.7KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/highway--1.3.0... (897.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/imath_bottle_manifest--3.2.1... (9.5KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/imath--3.2.1... (194.2KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/jpeg-turbo_bottle_manifest--3.1.2... (10.7KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/jpeg-turbo--3.1.2... (1MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/jpeg-xl_bottle_manifest--0.11.1_3... (33.7KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/jpeg-xl--0.11.1_3... (13.9MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/lame_bottle_manifest--3.100... (16KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/lame--3.100... (794.7KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/leptonica_bottle_manifest--1.86.0... (17.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/leptonica--1.86.0... (2.7MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libarchive_bottle_manifest--3.8.1... (15.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libarchive--3.8.1... (1.6MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libass_bottle_manifest--0.17.4... (38.7KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libass--0.17.4... (232.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libb2_bottle_manifest--0.98.1... (15.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libb2--0.98.1... (36KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libbluray_bottle_manifest--1.4.0... (17.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libbluray--1.4.0... (370.1KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libdeflate_bottle_manifest--1.24... (10.4KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libdeflate--1.24... (113.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libevent_bottle_manifest--2.1.12_1... (17KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libevent--2.1.12_1... (715KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libidn2_bottle_manifest--2.3.8... (12.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libidn2--2.3.8... (311.6KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libmicrohttpd_bottle_manifest--1.0.2... (24.9KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libmicrohttpd--1.0.2... (482.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libnghttp2_bottle_manifest--1.67.1... (7.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libnghttp2--1.67.1... (214.2KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libogg_bottle_manifest--1.3.6... (9.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libogg--1.3.6... (234.7KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libpng_bottle_manifest--1.6.50... (10.9KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libpng--1.6.50... (457.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/librist_bottle_manifest--0.2.11... (26.5KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/librist--0.2.11... (213.4KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libsamplerate_bottle_manifest--0.2.2-1... (9.5KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libsamplerate--0.2.2... (2.7MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libsndfile_bottle_manifest--1.2.2_1... (17.4KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libsndfile--1.2.2_1... (616.5KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libsodium_bottle_manifest--1.0.20... (10.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libsodium--1.0.20... (307.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libsoxr_bottle_manifest--0.1.3-1... (15.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libsoxr--0.1.3... (79.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libssh_bottle_manifest--0.11.3... (12.1KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libssh--0.11.3... (539.2KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libtasn1_bottle_manifest--4.20.0... (10.1KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libtasn1--4.20.0... (167.9KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libtiff_bottle_manifest--4.7.1... (12.5KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libtiff--4.7.1... (1.9MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libudfread_bottle_manifest--1.2.0... (9.4KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libudfread--1.2.0... (43.4KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libunibreak_bottle_manifest--6.1... (10.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libunibreak--6.1... (65.4KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libunistring_bottle_manifest--1.4... (7.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libunistring--1.4... (1.9MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libvidstab_bottle_manifest--1.1.1... (12.5KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libvidstab--1.1.1... (47.2KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libvmaf_bottle_manifest--3.0.0-1... (11.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libvmaf--3.0.0... (1.1MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libvorbis_bottle_manifest--1.3.7-1... (14.2KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libvorbis--1.3.7... (590.2KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libvpx_bottle_manifest--1.15.2... (9.4KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libvpx--1.15.2... (1.9MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libx11_bottle_manifest--1.8.12... (18.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libx11--1.8.12... (2.3MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libxau_bottle_manifest--1.0.12... (10.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libxau--1.0.12... (33.4KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libxcb_bottle_manifest--1.17.0-1... (19.2KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libxcb--1.17.0... (1MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libxdmcp_bottle_manifest--1.1.5... (12.0KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libxdmcp--1.1.5... (37.2KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libxext_bottle_manifest--1.3.6... (16.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libxext--1.3.6... (108.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libxrender_bottle_manifest--0.9.12... (14.2KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/libxrender--0.9.12... (54.6KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/little-cms2_bottle_manifest--2.17... (15KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/little-cms2--2.17... (433.1KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/lzo_bottle_manifest--2.10... (16.7KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/lzo--2.10... (148.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/mbedtls_bottle_manifest--3.6.4... (17.9KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/mbedtls--3.6.4... (3.6MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/mpg123_bottle_manifest--1.33.2... (10.7KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/mpg123--1.33.2... (649KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/nettle_bottle_manifest--3.10.2... (11.9KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/nettle--3.10.2... (988.5KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/opencore-amr_bottle_manifest--0.1.6... (13.9KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/opencore-amr--0.1.6... (306.4KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/openexr_bottle_manifest--3.4.0_2... (15.5KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/openexr--3.4.0_2... (1.2MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/openjpeg_bottle_manifest--2.5.4... (14.0KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/openjpeg--2.5.4... (2.2MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/openjph_bottle_manifest--0.24.1... (12.2KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/openjph--0.24.1... (157.4KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/openssl@3_bottle_manifest--3.5.4... (11.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/openssl@3--3.5.4... (10.7MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/opus_bottle_manifest--1.5.2... (10.7KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/opus--1.5.2... (482.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/p11-kit_bottle_manifest--0.25.10... (9.9KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/p11-kit--0.25.10... (939.9KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/pango_bottle_manifest--1.57.0... (39.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/pango--1.57.0... (886.5KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/pcre2_bottle_manifest--10.46... (12.9KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/pcre2--10.46... (2.4MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/pixman_bottle_manifest--0.46.4-1... (9.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/pixman--0.46.4... (416.3KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/rav1e_bottle_manifest--0.8.1... (9.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/rav1e--0.8.1... (13.2MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/rubberband_bottle_manifest--4.0.0... (23.4KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/rubberband--4.0.0... (637.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/sdl2_bottle_manifest--2.32.10... (23.0KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/sdl2--2.32.10... (1.8MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/snappy_bottle_manifest--1.2.2... (9.2KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/snappy--1.2.2... (46.9KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/speex_bottle_manifest--1.2.1... (14.6KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/speex--1.2.1... (549.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/srt_bottle_manifest--1.5.4... (12.5KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/srt--1.5.4... (1.8MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/svt-av1_bottle_manifest--3.1.2... (9.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/svt-av1--3.1.2... (1.4MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/tesseract_bottle_manifest--5.5.1... (54.7KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/tesseract--5.5.1... (13.2MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/theora_bottle_manifest--1.2.0... (12KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/theora--1.2.0... (752.7KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/unbound_bottle_manifest--1.24.0... (14KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/unbound--1.24.0... (3.0MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/webp_bottle_manifest--1.6.0... (19.5KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/webp--1.6.0... (903.0KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/x264_bottle_manifest--r3222... (9.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/x264--r3222... (2MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/x265_bottle_manifest--4.1-1... (9.8KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/x265--4.1... (4.0MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/xorgproto_bottle_manifest--2024.1... (20.6KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/xorgproto--2024.1... (717.1KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/xvid_bottle_manifest--1.3.7... (14.1KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/xvid--1.3.7... (439.7KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/zeromq_bottle_manifest--4.3.5_2... (11KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/zeromq--4.3.5_2... (1.7MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/zimg_bottle_manifest--3.0.6... (9.4KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/zimg--3.0.6... (353.6KB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/go_mod_cache... (7,849 files, 88.3MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/portable-ruby-3.4.7.arm64_big_sur.bottle.tar.gz... (12.2MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/portable-ruby-3.4.8.arm64_big_sur.bottle.tar.gz... (12.2MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/go_cache... (1,788 files, 472.2MB)
Removing: /Users/shiina.yuichi/Library/Caches/Homebrew/bootsnap/e480d26faefcc0649aee4a1b4bb5df1bf6ea887486b0f1485789bf3d26f5e27a... (654 files, 5.6MB)

インストールに成功しました。

OAuth2 を利用してログイン

OAuth2 を利用して Datadog にログインしてみます。

pup auth login
🔐 Starting OAuth2 login for site: datadoghq.com

📡 Callback server started on: http://127.0.0.1:8000/oauth/callback
📝 Registering new OAuth2 client...
✓ Client registered successfully

🌐 Opening browser for authentication...
If the browser doesn't open, visit: https://app.datadoghq.com/oauth2/v1/authorize?client_id=XXXXXXXXXXXXXXXXXXXXXXX

⏳ Waiting for authorization...
🔄 Exchanging authorization code for tokens...

コマンドを実行すると、ブラウザ画面が開きます。
Datadog の organization を選択します。

Datadog-Authorize-1

アクセス権限を確認のうえ、認可を行います。
Datadog-Authorize-2

成功すると "Authentication Sucessful!" と表示されます。
Datadog-Authorize-3

ターミナルに戻るとログイン成功したメッセージが表示されます。

✅ Login successful!
   Access token expires: 2026-02-12T13:57:56+09:00
   Token stored in: macOS Keychain (secure)

これでログイン成功です。

OAuth 認証トークンは OS のキーチェーンに保存されます。
macOS の場合はキーチェーンアクセスにdatadog-cliという名前で保管されていることがわかります。
datadog-cli1

認証状況の確認

認証状況を確認してみます。

pup auth status
✅ Authenticated for site: datadoghq.com
   Token expires in: 59m6s

{
  "authenticated": true,
  "expires_at": "2026-02-12T13:57:56+09:00",
  "has_refresh": true,
  "site": "datadoghq.com",
  "status": "valid",
  "token_type": "Bearer"
}

ログイン先の Datadog サイトやトークンの有効期限を確認できます。
トークンの有効期限は、デフォルトで1時間となっているようです。

有効期限が切れるとコマンドは失敗します。
pup auth refreshpup auth loginコマンドで再認証可能です。

⚠️  Token expired
   Run 'pup auth refresh' to refresh or 'pup auth login' to re-authenticate

{
  "authenticated": false,
  "expires_at": "2026-02-12T13:57:56+09:00",
  "has_refresh": true,
  "site": "datadoghq.com",
  "status": "expired",
  "token_type": "Bearer"
}

接続テスト

Datadog との接続をテストする専用コマンドが用意されています。

pup test
Configuration is valid:
  Site: datadoghq.com
  API Key: (not set - using OAuth2 or will prompt)
  App Key: (not set - using OAuth2 or will prompt)

Connection test successful!

Datadog API、APP キーなしで接続が行えていることが確認できますね。

モニターの詳細情報を取得

モニター ID を指定して、情報を取得するコマンドを実行してみます。

pup monitors get <モニター ID>
{
  "created": "2026-02-12T04:27:50.584Z",
  "created_at": 1770870470000,
  "creator": {
    "email": "user@example.com",
    "handle": "user@example.com",
    "id": XXXXXXXXX,
    "name": "shiina yuichi"
  },
  "deleted": null,
  "draft_status": "published",
  "id": 258374678,
  "message": "Alert!",
  "modified": "2026-02-12T04:58:40.110Z",
  "multi": false,
  "name": "EC2 CPU Monitor",
  "options": {
    "evaluation_delay": 900,
    "include_tags": false,
    "new_host_delay": 300,
    "notify_audit": false,
    "on_missing_data": "default",
    "silenced": {},
    "thresholds": {
      "critical": 70
    }
  },
  "org_id": 1116874,
  "overall_state": "OK",
  "overall_state_modified": "2026-02-12T04:41:39+00:00",
  "priority": null,
  "query": "avg(last_1h):avg:aws.ec2.cpuutilization{*} \u003e 70",
  "restricted_roles": null,
  "tags": [
    "env:production"
  ],
  "type": "query alert"
}

各種情報を取得することができました。

ログ検索

エラーログの検索も試してみます。

pup logs search --query="status:error" --from="1d" --output=table 
┌────────────────────────────────────────────────────┬──────┬────────┬────────────┬──────────────────────┬────────────┬──────────────────────────────────────────────┬────────────────────────────────────────────────────┬───────────┐
│                         ID                         │ TYPE │ STATUS │    TAGS    │      TIMESTAMP       │ ATTRIBUTES │                     HOST                     │                      MESSAGE                       │  SERVICE  │
├────────────────────────────────────────────────────┼──────┼────────┼────────────┼──────────────────────┼────────────┼──────────────────────────────────────────────┼────────────────────────────────────────────────────┼───────────┤
│ AwAAAZxQH8u4O6ckcgAAABhBWnhRSDk0cEFBQ01nN3FjWFl... │ log  │ error  │ [16 items]2026-02-12T04:33:07Z │ {8 fields} │ ip-10-0-0-46.ap-northeast-1.compute.internal │ 2026/02/12 04:33:07 [error] 2224#2224: *3 open(... │ webserver │
│ AwAAAZxQH6x4kqbQrAAAABhBWnhRSDdqWUFBREFYdUp3MDd... │ log  │ error  │ [16 items]2026-02-12T04:32:59Z │ {8 fields} │ ip-10-0-0-46.ap-northeast-1.compute.internal │ 2026/02/12 04:32:59 [error] 2224#2224: *2 open(... │ webserver │
└────────────────────────────────────────────────────┴──────┴────────┴────────────┴──────────────────────┴────────────┴──────────────────────────────────────────────┴────────────────────────────────────────────────────┴───────────┘

条件にマッチするログが返されました。
テーブル形式に出力すると見やすいのですが、メッセージが省略されてしまいますね。
JSON 形式では詳細な情報が多く出力されるため、jq を利用して出力を整形してみます。

pup logs search --query="status:error" --from="1d" --output=json | jq -s '.[0].data[].attributes | select(.message) | "[\(.timestamp)] \(.status) \(.service)\n  HOST: \(.host)\n  MSG:  \(.message)\n"' -r
[2026-02-12T04:33:07Z] error webserver
  HOST: ip-10-0-0-46.ap-northeast-1.compute.internal
  MSG:  2026/02/12 04:33:07 [error] 2224#2224: *3 open() "/usr/share/nginx/html/admin.html" failed (2: No such file or directory), client: ::1, server: _, request: "GET /admin.html HTTP/1.1", host: "localhost"

[2026-02-12T04:32:59Z] error webserver
  HOST: ip-10-0-0-46.ap-northeast-1.compute.internal
  MSG:  2026/02/12 04:32:59 [error] 2224#2224: *2 open() "/usr/share/nginx/html/admin.php" failed (2: No such file or directory), client: ::1, server: _, request: "GET /admin.php? HTTP/1.1", host: "localhost"

見やすく整形できました。

モニター削除

モニターに対しては削除コマンドが実装されていました。
試しにモニターを削除するコマンドを実行してみます。

pup monitors delete <モニター ID>
⚠️  WARNING: This will permanently delete monitor XXXXXXXX
Are you sure you want to continue? (y/N): 

デフォルトでは更新系のコマンドは承認が必要となります。
DD_AUTO_APPROVE環境変数によって自動承認することは可能です。
意図しない更新を実施してしまう可能性もあるので、falseのまま利用がよさそうです。

まとめ

Pup CLI を利用して、コマンドで Datadog の操作を試してみました。
OAuth2 認証により API キーの管理が不要になる点は、セキュリティ面で大きなメリットがあります。
コマンド体系もシンプルで直感的に操作でき、出力形式を JSON、Table、YAML から選べる点も実用的ですよね。
現時点ではプレビュー版のためカバーされるコマンドは限定的ですが、モニターの取得やログ検索など主要な参照系操作は既に利用可能です。
削除などの更新系コマンドには承認が必要となっている点にも安心感があります。
コマンドラインツールのため、シェルスクリプトや CI/CD パイプラインへの組み込みができ、Datadog 運用の自動化に活用できそうです。
今後のアップデートに注目したいツールです。

本記事が参考になれば幸いです。

この記事をシェアする

FacebookHatena blogX

関連記事