You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following the example in the docs for moving an application to a different policy, I am attempting to move a server to a different policy. My code is as follows.
Following the example in the docs for moving an application to a different policy, I am attempting to move a server to a different policy. My code is as follows.
! /usr/bin/python
from newrelic_api import AlertPolicies, Servers
server_id = Servers().list(
filter_name='<server_name>'
)['servers'][0]['id']
non_notify_policy = AlertPolicies().list(
filter_name='<policy_name>',
filter_type=['server'],
filter_enabled=True
)['alert_policies'][0]
server_in_policy = server_id in non_notify_policy.get('links', {}).get('servers')
if not server_in_policy:
server_ids = non_notify_policy['links']['servers']
server_ids.append(server_id)
When run I get the following errors.
/usr/bin/python2.7 /home/user/PycharmProjects/new_relic_maintenance_mode_disable_alerts/new_relic_maintenance_mode_disable_Alerts
Traceback (most recent call last):
File "/home/user/PycharmProjects/new_relic_maintenance_mode_disable_alerts/new_relic_maintenance_mode_disable_Alerts", line 25, in
policy_update=new_alert_policy
File "/home/user/.local/lib/python2.7/site-packages/newrelic_api/alert_policies.py", line 239, in update
data=policy_update
File "/home/user/.local/lib/python2.7/site-packages/newrelic_api/base.py", line 71, in _put
raise NewRelicAPIServerException('{}: {}'.format(response.status_code, response.text))
newrelic_api.exceptions.NewRelicAPIServerException: 400: {"error":{"title":"missing parameter: alert_policy"}}
Process finished with exit code 1
The text was updated successfully, but these errors were encountered: