jpskill.com
🛠️ 開発・MCP コミュニティ

new-relic

New Relic を導入・管理し、アプリケーションやインフラの監視、アラート設定、ダッシュボード作成、NRQL クエリ実行、デプロイパイプラインとの連携など、フルスタックの可観測性を実現するSkill。

📜 元の英語説明(参考)

Set up and manage New Relic for full-stack observability including APM, browser monitoring, infrastructure monitoring, and alerting. Use when a user needs to instrument applications, write NRQL queries, create dashboards, configure alert policies, or integrate New Relic with their deployment pipeline.

🇯🇵 日本人クリエイター向け解説

一言でいうと

New Relic を導入・管理し、アプリケーションやインフラの監視、アラート設定、ダッシュボード作成、NRQL クエリ実行、デプロイパイプラインとの連携など、フルスタックの可観測性を実現するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o new-relic.zip https://jpskill.com/download/15163.zip && unzip -o new-relic.zip && rm new-relic.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15163.zip -OutFile "$d\new-relic.zip"; Expand-Archive "$d\new-relic.zip" -DestinationPath $d -Force; ri "$d\new-relic.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して new-relic.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → new-relic フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

New Relic

概要

アプリケーションのパフォーマンス監視、インフラストラクチャの可観測性、ブラウザのリアルユーザー監視、およびインテリジェントなアラートのために New Relic を構成します。エージェントのインストール、NRQL クエリ、ダッシュボードの作成、およびアラートポリシーの構成について説明します。

手順

タスク A: APM エージェントのインストール

# Install New Relic Node.js agent
npm install newrelic
// newrelic.js — New Relic agent configuration (must be first require)
'use strict'
exports.config = {
  app_name: ['payment-service'],
  license_key: process.env.NEW_RELIC_LICENSE_KEY,
  distributed_tracing: { enabled: true },
  logging: { level: 'info' },
  allow_all_headers: true,
  attributes: {
    exclude: [
      'request.headers.cookie',
      'request.headers.authorization',
    ]
  },
  transaction_tracer: {
    enabled: true,
    transaction_threshold: 'apdex_f',
    record_sql: 'obfuscated',
  },
  error_collector: {
    enabled: true,
    ignore_status_codes: [404, 401],
  },
}
// app.js — Load New Relic before anything else
require('newrelic')
const express = require('express')
const app = express()

app.get('/api/orders', async (req, res) => {
  const orders = await db.query('SELECT * FROM orders LIMIT 100')
  res.json(orders)
})

タスク B: インフラストラクチャエージェントのセットアップ

# Install infrastructure agent on Ubuntu
curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh | bash
sudo NEW_RELIC_API_KEY="NRAK-XXXXXXXXX" NEW_RELIC_ACCOUNT_ID="1234567" \
  /usr/local/bin/newrelic install -n infrastructure-agent-installer
# /etc/newrelic-infra.yml — Infrastructure agent config
license_key: "<YOUR_LICENSE_KEY>"
display_name: "web-server-01"
custom_attributes:
  environment: production
  team: platform
  region: us-east-1
enable_process_metrics: true
metrics_system_sample_rate: 15
metrics_network_sample_rate: 15

タスク C: NRQL クエリ

-- Find slowest transactions in the last hour
SELECT average(duration), max(duration), count(*)
FROM Transaction
WHERE appName = 'payment-service'
FACET name
SINCE 1 hour ago
ORDER BY average(duration) DESC
LIMIT 20
-- Error rate by deployment version
SELECT percentage(count(*), WHERE error IS true) AS 'Error Rate'
FROM Transaction
WHERE appName = 'payment-service'
FACET tags.version
SINCE 1 day ago
TIMESERIES 15 minutes
-- Apdex score trend over time
SELECT apdex(duration, 0.5) AS 'Apdex'
FROM Transaction
WHERE appName = 'payment-service'
SINCE 7 days ago
TIMESERIES 1 hour
-- Infrastructure: hosts with high CPU
SELECT average(cpuPercent), max(memoryUsedPercent)
FROM SystemSample
FACET hostname
WHERE environment = 'production'
SINCE 30 minutes ago

タスク D: API 経由でのアラートポリシーの作成

# Create an alert policy via NerdGraph API
curl -X POST 'https://api.newrelic.com/graphql' \
  -H "Content-Type: application/json" \
  -H "Api-Key: ${NEW_RELIC_API_KEY}" \
  -d '{
    "query": "mutation { alertsPolicyCreate(accountId: 1234567, policy: { name: \"Payment Service - Production\", incidentPreference: PER_CONDITION_AND_TARGET }) { id name } }"
  }'
# Create a NRQL alert condition — High error rate
curl -X POST 'https://api.newrelic.com/graphql' \
  -H "Content-Type: application/json" \
  -H "Api-Key: ${NEW_RELIC_API_KEY}" \
  -d '{
    "query": "mutation { alertsNrqlConditionStaticCreate(accountId: 1234567, policyId: 987654, condition: { name: \"High Error Rate\", enabled: true, nrql: { query: \"SELECT percentage(count(*), WHERE error IS true) FROM Transaction WHERE appName = '\''payment-service'\''\" }, signal: { aggregationWindow: 300, aggregationMethod: EVENT_FLOW, aggregationDelay: 120 }, terms: [{ threshold: 5, thresholdOccurrences: ALL, thresholdDuration: 300, operator: ABOVE, priority: CRITICAL }, { threshold: 2, thresholdOccurrences: ALL, thresholdDuration: 300, operator: ABOVE, priority: WARNING }], violationTimeLimitSeconds: 86400 }) { id name } }"
  }'

タスク E: NerdGraph 経由でのダッシュボードの作成

# Create a dashboard with multiple widgets
curl -X POST 'https://api.newrelic.com/graphql' \
  -H "Content-Type: application/json" \
  -H "Api-Key: ${NEW_RELIC_API_KEY}" \
  -d '{
    "query": "mutation { dashboardCreate(accountId: 1234567, dashboard: { name: \"Payment Service Overview\", permissions: PUBLIC_READ_WRITE, pages: [{ name: \"Overview\", widgets: [{ title: \"Throughput\", configuration: { line: { nrqlQueries: [{ accountIds: [1234567], query: \"SELECT rate(count(*), 1 minute) FROM Transaction WHERE appName = '\''payment-service'\'' TIMESERIES\" }] } }, rawConfiguration: { facet: { showOtherSeries: false } } }, { title: \"Error Rate\", configuration: { billboard: { nrqlQueries: [{ accountIds: [1234567], query: \"SELECT percentage(count(*), WHERE error IS true) AS '\''Error Rate'\'' FROM Transaction WHERE appName = '\''payment-service'\'' SINCE 1 hour ago\" }], thresholds: [{ alertSeverity: CRITICAL, value: 5 }, { alertSeverity: WARNING, value: 2 }] } } }] }] }) { entityResult { guid } } }"
  }'

タスク F: ブラウザ監視

<!-- index.html — Add New Relic browser agent snippet -->
<head>
  <script type="text/javascript">
    ;window.NREUM||(NREUM={});NREUM.init={distributed_tracing:{enabled:true},
    privacy:{cookies_enabled:true},ajax:{deny_list:["bam.nr-data.net"]}};
    // Paste the full browser agent JS snippet from New Relic UI
    // Settings > Application > Browser monitoring > Copy/paste method
  </script>
</head>

# Configure browser monitoring via API for SPA
curl -X POST 'https://api.newrelic.com/graphql' \
  -H "Content-Type: application/json" \
  -H "Api-Key: ${NEW_RELIC_API_KEY}" \
  -d '{
    "query": "mutation { agentApplicationSettingsUpdate(guid: \"YOUR_BROWSER_ENTITY_GUID\", settings: { browserConfig: { apdexTarget: 3.0 }, browserMonitoring: { distributedTracing: { enabled: true }, ajax: { enabled: true }, spa: { enabled: true } } }) { browserConfig { apdexT

(原文がここで切り詰められています)
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

New Relic

Overview

Configure New Relic for application performance monitoring, infrastructure observability, browser real-user monitoring, and intelligent alerting. Covers agent installation, NRQL querying, dashboard creation, and alert policy configuration.

Instructions

Task A: Install APM Agent

# Install New Relic Node.js agent
npm install newrelic
// newrelic.js — New Relic agent configuration (must be first require)
'use strict'
exports.config = {
  app_name: ['payment-service'],
  license_key: process.env.NEW_RELIC_LICENSE_KEY,
  distributed_tracing: { enabled: true },
  logging: { level: 'info' },
  allow_all_headers: true,
  attributes: {
    exclude: [
      'request.headers.cookie',
      'request.headers.authorization',
    ]
  },
  transaction_tracer: {
    enabled: true,
    transaction_threshold: 'apdex_f',
    record_sql: 'obfuscated',
  },
  error_collector: {
    enabled: true,
    ignore_status_codes: [404, 401],
  },
}
// app.js — Load New Relic before anything else
require('newrelic')
const express = require('express')
const app = express()

app.get('/api/orders', async (req, res) => {
  const orders = await db.query('SELECT * FROM orders LIMIT 100')
  res.json(orders)
})

Task B: Infrastructure Agent Setup

# Install infrastructure agent on Ubuntu
curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh | bash
sudo NEW_RELIC_API_KEY="NRAK-XXXXXXXXX" NEW_RELIC_ACCOUNT_ID="1234567" \
  /usr/local/bin/newrelic install -n infrastructure-agent-installer
# /etc/newrelic-infra.yml — Infrastructure agent config
license_key: "<YOUR_LICENSE_KEY>"
display_name: "web-server-01"
custom_attributes:
  environment: production
  team: platform
  region: us-east-1
enable_process_metrics: true
metrics_system_sample_rate: 15
metrics_network_sample_rate: 15

Task C: NRQL Queries

-- Find slowest transactions in the last hour
SELECT average(duration), max(duration), count(*)
FROM Transaction
WHERE appName = 'payment-service'
FACET name
SINCE 1 hour ago
ORDER BY average(duration) DESC
LIMIT 20
-- Error rate by deployment version
SELECT percentage(count(*), WHERE error IS true) AS 'Error Rate'
FROM Transaction
WHERE appName = 'payment-service'
FACET tags.version
SINCE 1 day ago
TIMESERIES 15 minutes
-- Apdex score trend over time
SELECT apdex(duration, 0.5) AS 'Apdex'
FROM Transaction
WHERE appName = 'payment-service'
SINCE 7 days ago
TIMESERIES 1 hour
-- Infrastructure: hosts with high CPU
SELECT average(cpuPercent), max(memoryUsedPercent)
FROM SystemSample
FACET hostname
WHERE environment = 'production'
SINCE 30 minutes ago

Task D: Create Alert Policies via API

# Create an alert policy via NerdGraph API
curl -X POST 'https://api.newrelic.com/graphql' \
  -H "Content-Type: application/json" \
  -H "Api-Key: ${NEW_RELIC_API_KEY}" \
  -d '{
    "query": "mutation { alertsPolicyCreate(accountId: 1234567, policy: { name: \"Payment Service - Production\", incidentPreference: PER_CONDITION_AND_TARGET }) { id name } }"
  }'
# Create a NRQL alert condition — High error rate
curl -X POST 'https://api.newrelic.com/graphql' \
  -H "Content-Type: application/json" \
  -H "Api-Key: ${NEW_RELIC_API_KEY}" \
  -d '{
    "query": "mutation { alertsNrqlConditionStaticCreate(accountId: 1234567, policyId: 987654, condition: { name: \"High Error Rate\", enabled: true, nrql: { query: \"SELECT percentage(count(*), WHERE error IS true) FROM Transaction WHERE appName = '\''payment-service'\''\" }, signal: { aggregationWindow: 300, aggregationMethod: EVENT_FLOW, aggregationDelay: 120 }, terms: [{ threshold: 5, thresholdOccurrences: ALL, thresholdDuration: 300, operator: ABOVE, priority: CRITICAL }, { threshold: 2, thresholdOccurrences: ALL, thresholdDuration: 300, operator: ABOVE, priority: WARNING }], violationTimeLimitSeconds: 86400 }) { id name } }"
  }'

Task E: Create Dashboards via NerdGraph

# Create a dashboard with multiple widgets
curl -X POST 'https://api.newrelic.com/graphql' \
  -H "Content-Type: application/json" \
  -H "Api-Key: ${NEW_RELIC_API_KEY}" \
  -d '{
    "query": "mutation { dashboardCreate(accountId: 1234567, dashboard: { name: \"Payment Service Overview\", permissions: PUBLIC_READ_WRITE, pages: [{ name: \"Overview\", widgets: [{ title: \"Throughput\", configuration: { line: { nrqlQueries: [{ accountIds: [1234567], query: \"SELECT rate(count(*), 1 minute) FROM Transaction WHERE appName = '\''payment-service'\'' TIMESERIES\" }] } }, rawConfiguration: { facet: { showOtherSeries: false } } }, { title: \"Error Rate\", configuration: { billboard: { nrqlQueries: [{ accountIds: [1234567], query: \"SELECT percentage(count(*), WHERE error IS true) AS '\''Error Rate'\'' FROM Transaction WHERE appName = '\''payment-service'\'' SINCE 1 hour ago\" }], thresholds: [{ alertSeverity: CRITICAL, value: 5 }, { alertSeverity: WARNING, value: 2 }] } } }] }] }) { entityResult { guid } } }"
  }'

Task F: Browser Monitoring

<!-- index.html — Add New Relic browser agent snippet -->
<head>
  <script type="text/javascript">
    ;window.NREUM||(NREUM={});NREUM.init={distributed_tracing:{enabled:true},
    privacy:{cookies_enabled:true},ajax:{deny_list:["bam.nr-data.net"]}};
    // Paste the full browser agent JS snippet from New Relic UI
    // Settings > Application > Browser monitoring > Copy/paste method
  </script>
</head>
# Configure browser monitoring via API for SPA
curl -X POST 'https://api.newrelic.com/graphql' \
  -H "Content-Type: application/json" \
  -H "Api-Key: ${NEW_RELIC_API_KEY}" \
  -d '{
    "query": "mutation { agentApplicationSettingsUpdate(guid: \"YOUR_BROWSER_ENTITY_GUID\", settings: { browserConfig: { apdexTarget: 3.0 }, browserMonitoring: { distributedTracing: { enabled: true }, ajax: { enabled: true }, spa: { enabled: true } } }) { browserConfig { apdexTarget } } }"
  }'

Best Practices

  • Use distributed tracing across all services for end-to-end request visibility
  • Set meaningful Apdex thresholds per service based on actual SLA requirements
  • Use FACET in NRQL to break down metrics by deployment version, endpoint, or region
  • Configure alert notification channels (Slack, PagerDuty) before creating policies
  • Use workloads to group related entities and get unified health status
  • Exclude sensitive headers and parameters from agent collection