경고에서 엔터티 는 애플리케이션, 브라우저 또는 호스트와 같은 모니터링 대상으로 정의됩니다. 경고 UI 에는 선택할 수 있는 사용 가능한 엔터티가 표시됩니다. REST API 및 API 탐색기를 사용하여 조건에 대한 엔터티를 추가 하거나 제거 할 수도 있습니다.
REST API를 사용하기 전에
REST API는 더 이상 경고를 프로그래밍 방식으로 관리하는 데 선호되는 방법이 아닙니다. 자세한 내용은 API 소개를 읽어보세요. 그리고 응용지능.
요구 사항
조건의 엔터티 목록을 수정하려면 다음 사항을 알아야 합니다.
- API 키
- 모니터링하려는 항목의 {entity_ID}
- 수정하려는 조건의 {condition_ID}
일반 절차
조건에 대한 항목 목록을 업데이트하려면 다음 안내를 따르세요.
정책과 연결된 조건 목록을 가져오고 적절한 범주에 대해 수정할 조건을 선택합니다.
중요
조건에 추가할 수 있는 최소 및 최대 엔터티 수에 대한 요구 사항을 따르십시오.
예: 항목 추가/제거
다음 예에서는 조건에 TimberTime
이라는 Ruby 애플리케이션을 추가하는 방법과 동일한 조건에서 항목을 제거하는 방법을 보여줍니다.
이 예제의 첫 번째 단계만 Ruby 앱을 엔터티로 선택하는 데 고유합니다. 나머지 단계는 선택한 엔터티에 대해 동일합니다.
entity_id
가져오기 ; 예:{application_id}
:curl -X GET 'https://api.newrelic.com/v2/applications.json' \ -H "X-Api-Key:$API_KEY" -i
또는
애플리케이션 이름을 알고 있는 경우 이 명령을 사용하고
app_name
을 지정합니다.curl -X GET 'https://api.newrelic.com/v2/applications.json' \ -H "X-Api-Key:$API_KEY" -i \ -d 'filter[name]=TimberTime'
출력을 검토하여
{application_id}
을 찾고 이를{entity_id}
로 사용합니다.{"applications": [{"id": 12345, <---<<< {application_id} == {entity_id}"name": "TimberTime","language": "ruby","health_status": "gray",...},업데이트하려는
policy_id
을(를) 가져옵니다. 예를 들어TimberTime
앱의Logjam Alert
정책입니다.policy_id
을 얻으려면 다음 명령을 사용하십시오.curl -X GET 'https://api.newrelic.com/v2/alerts_policies.json' \ -H "X-Api-Key:$API_KEY" -i \ -G -d 'filter[name]= Logjam Alert' <---<<< {policy_name}
정책 결과를 검토합니다. 예를 들어:
{"policies": [{"id": 85, <---<<< {policy_id}"incident_preference": "PER_POLICY","name": "Logjam Alert","created_at": 1461176510393,"updated_at": 1461176510393},이 정책의 모든 조건을 나열하고
{condition_id}
를 찾습니다.curl -X GET 'https://api.newrelic.com/v2/alerts_conditions.json' \ -H "X-Api-Key:$API_KEY" -i \ -G -d 'policy_id=85'
정책 조건을 검토합니다. 예를 들어:
{"conditions": [{"id": 234567, <---<<< {condition_id}"type": "apm_app_metric","name": "Throughput (web) (High)","enabled": true,"entities": ["8288171" <---<<< Entity currently included in the policy],"metric": "response_time_web","terms": [{"duration": "5","operator": "above","priority": "critical","threshold": "500","time_function": "all"}]}]}API 요청을 사용하여 정책 조건에서 엔터티를 추가하거나 제거합니다.
{entity_id}
12345를{condition_id}
234567에 추가하려면{entity_type}
를application
으로 설정합니다.curl -X PUT 'https://api.newrelic.com/v2/alerts_entity_conditions/12345.json' \ -H "X-Api-Key:$API_KEY" -i \ -H 'Content-Type: application/json' \ -G -d 'entity_type=Application&condition_id=234567'
{condition_id}
} 234567에서{entity_id}
8288171을 제거하려면{entity_type}
를application
으로 설정합니다.curl -X DELETE 'https://api.newrelic.com/v2/alerts_entity_conditions/8288171.json' \ -H "X-Api-Key:$API_KEY" -i \ -G -d 'entity_type=Application&condition_id=234567'