이것은 New Relic Data API(v2)를 사용하여 특정 기간 동안 애플리케이션의 평균 오류율을 얻는 방법의 예입니다. 이 값은 APM 요약 페이지 의 오류율 차트 위에 백분율로 표시됩니다.
API를 사용하려면 다음이 필요합니다.
평균 백분율은 앱 요약 페이지 의 오류율 차트 위에 표시됩니다. New Relic은 다음 공식을 사용하여 계산합니다.
Application Error Rate = 100 * Errors/all:error_count / (HttpDispatcher:call_count + OtherTransaction/all:call_count)
API 명령
메트릭 타임슬라이스 값을 얻으려면 다음 세 가지 명령을 사용하십시오. 이 예에서는 각 명령에 대해 동일한 기간을 사용하며 모두 요약되어 있습니다.
오류 수를 얻으려면:
$curl -X GET "https://api.newrelic.com/v2/applications/$APP_ID/metrics/data.xml" \
> -H "Api-Key:<a href="/docs/apis/rest-api-v2/getting-started/introduction-new-relic-rest-api-v2
$ -d 'names[]=Errors/all&values[]=error_count&from=2014-04-01T00:00:00+00:00&to=2014-04-01T23:35:00+00:00&summarize=true'
"from": "2014-04-01T00:00:00+00:00",
"from": "2014-04-01T00:35:00+00:00",
"to": "2014-04-01T23:35:00+00:00",
"metrics_found": ["Errors/all"],
"to": "2014-04-01T23:35:00+00:00"
HttpDispatcher 호출 수 를 얻으려면(웹 애플리케이션):
$curl -X GET "https://api.newrelic.com/v2/applications/$APP_ID/metrics/data.xml" \
> -H "Api-Key:<a href="/docs/apis/rest-api-v2/getting-started/introduction-new-relic-rest-api-v2
$ -d 'names[]=HttpDispatcher&values[]=call_count&from=2014-04-01T00:00:00+00:00&to=2014-04-01T23:35:00+00:00&summarize=true'
"from": "2014-04-01T00:00:00+00:00",
"name": "HttpDispatcher",
"from": "2014-04-01T00:35:00+00:00",
"to": "2014-04-01T23:35:00+00:00",
"metrics_found": ["HttpDispatcher"],
"to": "2014-04-01T23:35:00+00:00"
OtherTransaction 호출 수 를 얻으려면(웹 앱이 아님):
$curl -X GET "https://api.newrelic.com/v2/applications/$APP_ID/metrics/data.xml" \
> -H "Api-Key:<a href="/docs/apis/rest-api-v2/getting-started/introduction-new-relic-rest-api-v2
$ -d 'names[]=OtherTransaction/all&values[]=call_count&from=2014-04-01T00:00:00+00:00&to=2014-04-01T23:35:00+00:00&summarize=true'
"from": "2014-04-01T00:00:00+00:00",
"name": "OtherTransaction/all",
"from": "2014-04-01T00:35:00+00:00",
"to": "2014-04-01T23:35:00+00:00",
"metrics_found": ["OtherTransaction/all"],
"to": "2014-04-01T23:35:00+00:00"