New Relic の $util.insights
は、Insights 用の Synthetics のデータをセットし、操作するためのオブジェックトです。デフォルト属性に加えて、すべてのデータは、カスタム属性として、 SyntheticCheck
イベントに追加されます。このデータの接頭辞として、custom
が付きます。
目次
互換性
この機能は、2015年4月1日以降に作成されたモニターで利用可能です。
関数
関数 | 戻り値 |
---|---|
$util.insights.set(key: string, value: ?)
ジョブの完了時に、Insights に保存するキー/値ペアをセットする |
void |
$util.insights.get(key: string)
ジョブの完了時に Insights に保存されるデータのうち、指定したキーを持つ値を返す |
object |
$util.insights.getKeys()
ジョブの完了時に Insights に保存されるデータのうち、現在セットされているキー配列を返す |
object |
$util.insights.has(key: string)
ジョブの完了時に Insights に保存されるデータに、指定したキーが存在する場合は、 |
boolean |
$util.insights.unset(key: string)
ジョブの完了時に Insights に保存されるデータから、指定したキーに一致する、キー/値を削除する |
void |
$util.insights.unsetAll() ジョブの完了時に Insights に保存される全カスタムデータを削除する |
void |
例
以下は、New Relic の RSS ステータスフィードから直近のインシデントを取得し、その情報を Insights へ送信する例です。
var parseString = require('xml2js').parseString;
// New Relic ステータスの RSS フィードを取得
$http.get('https://status.newrelic.com/history.rss', function(err, response, body) {
parseString(body, function(err, result){
// RSS をパースし、最後のインシデントを取得
var latestIncident = result.rss.channel[0].item[0];
// インシデントの詳細情報を Insights へ追加
$util.insights.set('Incident', latestIncident.title[0]);
$util.insights.set('Description', latestIncident.description[0]);
$util.insights.set('Date', latestIncident.pubDate[0]);
});
});
関連情報
関連する情報は以下のとおりです。
- Scripted Browsers 用のコードの書き方 (複数ステップのある WebDriverJS スクリプトの書き方)
- モニターの追加と編集 (New Relic Synthetics にモニターを追加する方法。設定方法にも言及)
- Insights 用の Synthetics デフォルト属性 (Synthetics イベント用に自動的に記録される属性)