変更追跡機能は、顧客やシステムに対する特定の変更の影響を監視するための優れた方法です。これを行うには、監視する変更を指定し、New Relic UI で結果を表示します。
GraphQL または CI/CD 統合を使用して監視する変更を指定できますが、CLI を使用して同じことを行うこともできます。CLI を使用して監視する変更を指定する場合、 GraphQL クエリを実行するか、New Relic データベースに対してNRQL クエリを実行して、それらの変更のリストを取得できます。
CLI をインストールする
GraphQL ミューテーションを送信してマーカーを作成できる新しいバージョンの CLI があります。CLI を使用していた場合でも、この機能を利用するにはアップグレードする必要があります。
CLI をインストールまたはアップグレードするには、こちらの手順に従ってください。
CLI でデプロイ マーカーを作成する
CLI にはさまざまなオプションがありますが (以下を参照)、 create
コマンドは特定の New Relic エンティティのデプロイをマークします。
マーカーを作成する構文は次のとおりです。
newrelic entity deployment create [flags]
次の例を見てみましょう。
newrelic entity deployment create --guid INSERT_YOUR_GUID_HERE --version <1.0.0>
プライマリ (親) オプション
-h, --help help for create-g, --guid string the entity GUID to create change tracker-v, --version string the tag names to add to the entity --changelog string a URL for the changelog or list of changes if not linkable --commit string the commit identifier, for example, a Git commit SHA --deepLink string a link back to the system generating the deployment --deploymentType string type of deployment, one of BASIC, BLUE_GREEN, CANARY, OTHER, ROLLING or SHADOW --description string a description of the deployment --groupID string string that can be used to correlate two or more events-t --timestamp int64 the start time of the deployment, the number of milliseconds since the Unix epoch, defaults to now-u --user string username of the deployer or bot
親コマンドから継承されたオプション
-a, --accountId int the account ID to use. Can be overridden by setting NEW_RELIC_ACCOUNT_ID --debug debug level logging --format string output text format [JSON, Text, YAML] (default "JSON") --plain output compact text --profile string the authentication profile to use --trace trace level logging
追跡している変更を一覧表示する
追跡したい変更を指定したら、NerdGraph で GraphQL クエリを実行するか、New Relic UI で NRQL クエリを実行して、それらを一覧表示できます。
GraphQL クエリ
GraphiQL IDE であるNerdGraphで、次のようなクエリを実行できます。
newrelic --profile xyz nerdgraph query '{ actor { entity(guid: "MTE2NjAxMzJ8QVBNfEFQUExJQ0FUSU9OfDg0MTY1OTI") { deploymentSearch { results { deploymentId } } guid name } } }'{ "actor": { "entity": { "deploymentSearch": { "results": [ { "deploymentId": "445784" } ] }, "guid": "MTE2NjAxMzJ8QVBNfEFQUExJQ0FUSU9OfDg0MTY1OTI", "name": "deployment-marker-api (production)" } }}
あるいは、New Relic データベースに対してNRQL クエリを実行して、それらの変更のリストを取得することもできます。
次のステップ
追跡したい変更を指定したら、New Relic UI でそれらの変更の影響を分析できます。詳細については、 New Relic で変更を表示および分析する方法 を参照してください。