import requests
url = "https://platform.ankra.app/api/v1/org/applications/{application_id}/alerts"
payload = {
"name": "<string>",
"environment_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"condition": {
"condition_type": "app_metric",
"threshold": 1,
"hold_minutes": 30,
"route": None,
"operator": "gt"
},
"send_to": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
environment_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
condition: {
condition_type: 'app_metric',
threshold: 1,
hold_minutes: 30,
route: null,
operator: 'gt'
},
send_to: ['3c90c3cc-0d44-4b50-8888-8dd25736052a']
})
};
fetch('https://platform.ankra.app/api/v1/org/applications/{application_id}/alerts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://platform.ankra.app/api/v1/org/applications/{application_id}/alerts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"environment_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"condition": {
"condition_type": "app_metric",
"threshold": 1,
"hold_minutes": 30,
"route": null,
"operator": "gt"
},
"send_to": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
}
'{
"alert_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"rule_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"own": true,
"environment_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"says": "<string>",
"condition": {
"condition_type": "app_metric",
"metric": "failed_share_pct",
"threshold": 1,
"hold_minutes": 30,
"route": null,
"operator": "gt"
},
"severity": "<string>",
"send_to": [
{
"integration_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "<string>",
"label": "<string>"
}
],
"enabled": true,
"last_firing": {
"trigger_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"triggered_at": "2023-11-07T05:31:56Z",
"resolved_at": "2023-11-07T05:31:56Z",
"acknowledged_by": {
"user_id": "<string>",
"name": "<string>"
},
"acknowledged_after_seconds": 1,
"resolved_by": "itself",
"resolution_note": "<string>"
},
"evaluated_at": "2023-11-07T05:31:56Z",
"evaluation": "ok",
"unknown_reason": "<string>"
}{
"detail": "<string>"
}{
"detail": "permission_denied",
"permission": "<string>",
"scope_type": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}Create an application alert
Creates an alert on one environment of the application, with one condition on the application’s own metrics, sending to 1 to 5 of the organisation’s places to send alerts to. It is stored as an organisation alert named “Application · Environment · name” with one rule the alert evaluator reads, so it also shows under Alerts. An environment with nothing running on it yet is accepted, so an alert can be set before the first deploy: it reads unknown, with unknown_reason no_installations, until something runs there. Refused 400 when the organisation has no place to send alerts to, or the application already has 50 alerts. Requires alerts.manage, or applications.write on the application; a viewer is refused whatever the RBAC rollout mode. Audited.
import requests
url = "https://platform.ankra.app/api/v1/org/applications/{application_id}/alerts"
payload = {
"name": "<string>",
"environment_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"condition": {
"condition_type": "app_metric",
"threshold": 1,
"hold_minutes": 30,
"route": None,
"operator": "gt"
},
"send_to": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
environment_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
condition: {
condition_type: 'app_metric',
threshold: 1,
hold_minutes: 30,
route: null,
operator: 'gt'
},
send_to: ['3c90c3cc-0d44-4b50-8888-8dd25736052a']
})
};
fetch('https://platform.ankra.app/api/v1/org/applications/{application_id}/alerts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://platform.ankra.app/api/v1/org/applications/{application_id}/alerts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"environment_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"condition": {
"condition_type": "app_metric",
"threshold": 1,
"hold_minutes": 30,
"route": null,
"operator": "gt"
},
"send_to": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
}
'{
"alert_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"rule_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"own": true,
"environment_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"says": "<string>",
"condition": {
"condition_type": "app_metric",
"metric": "failed_share_pct",
"threshold": 1,
"hold_minutes": 30,
"route": null,
"operator": "gt"
},
"severity": "<string>",
"send_to": [
{
"integration_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "<string>",
"label": "<string>"
}
],
"enabled": true,
"last_firing": {
"trigger_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"triggered_at": "2023-11-07T05:31:56Z",
"resolved_at": "2023-11-07T05:31:56Z",
"acknowledged_by": {
"user_id": "<string>",
"name": "<string>"
},
"acknowledged_after_seconds": 1,
"resolved_by": "itself",
"resolution_note": "<string>"
},
"evaluated_at": "2023-11-07T05:31:56Z",
"evaluation": "ok",
"unknown_reason": "<string>"
}{
"detail": "<string>"
}{
"detail": "permission_denied",
"permission": "<string>",
"scope_type": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}Authorizations
Body
A create or a full update of one application alert. No other key is accepted.
Response
The created alert
One alert of an application's list: an own alert, which these routes made and may change, or an organisation alert rule that watches the environment, which is changed under Alerts.
ok: the rule was read on its last run. unknown: the evaluator holds it unread (the metric store did not answer or lacks the metric, or the environment's installations cannot be resolved). not_evaluated: no run recorded a state yet.
ok, unknown, not_evaluated Why the evaluator holds the rule, only while evaluation is unknown. no_installations: nothing of the application runs on the environment, or only on a stopped cluster. application_not_found or environment_not_found: what the alert watched is gone; the evaluator then closes the alert's open firing with a resolution_note, since nothing can report it resolved. Any other value names a read that failed or a metric the store lacks.