Servers¶
newrelic_api.servers¶
- class newrelic_api.servers.Servers(api_key=None)¶
An interface for interacting with the NewRelic server API.
- __init__(api_key=None)¶
Parameters: api_key (str) – The API key. If no key is passed, the environment variable NEW_RELIC_API_KEY is used. Raises: If the api_key parameter is not present, and no environment variable is present, a newrelic_api.exceptions.ConfigurationException is raised.
- delete(id)¶
This API endpoint deletes an server and all of its reported data.
- WARNING: Only servers that have stopped reporting can be deleted.
- This is an irreversible process which will delete all reported data for this server.
Parameters: id (int) – Server ID Return type: dict Returns: The JSON response of the API { "server": { "id": "integer", "account_id": "integer", "name": "string", "host": "string", "reporting": "boolean", "last_reported_at": "time", "summary": { "cpu": "float", "cpu_stolen": "float", "disk_io": "float", "memory": "float", "memory_used": "integer", "memory_total": "integer", "fullest_disk": "float", "fullest_disk_free": "integer" } } }
- list(filter_name=None, filter_ids=None, filter_labels=None, page=None)¶
This API endpoint returns a paginated list of the Servers associated with your New Relic account. Servers can be filtered by their name or by a list of server IDs.
Parameters: Return type: dict
Returns: The JSON response of the API, with an additional ‘pages’ key if there are paginated results
{ "servers": [ { "id": "integer", "account_id": "integer", "name": "string", "host": "string", "reporting": "boolean", "last_reported_at": "time", "summary": { "cpu": "float", "cpu_stolen": "float", "disk_io": "float", "memory": "float", "memory_used": "integer", "memory_total": "integer", "fullest_disk": "float", "fullest_disk_free": "integer" } } ], "pages": { "last": { "url": "https://api.newrelic.com/v2/servers.json?page=2", "rel": "last" }, "next": { "url": "https://api.newrelic.com/v2/servers.json?page=2", "rel": "next" } } }
- metric_data(id, names, values=None, from_dt=None, to_dt=None, summarize=False)¶
This API endpoint returns a list of values for each of the requested metrics. The list of available metrics can be returned using the Metric Name API endpoint. Metric data can be filtered by a number of parameters, including multiple names and values, and by time range. Metric names and values will be matched intelligently in the background. You can also retrieve a summarized data point across the entire time range selected by using the summarize parameter.
Note All times sent and received are formatted in UTC. The default time range is the last 30 minutes.
Parameters: Return type: dict
Returns: The JSON response of the API
{ "metric_data": { "from": "time", "to": "time", "metrics": [ { "name": "string", "timeslices": [ { "from": "time", "to": "time", "values": "hash" } ] } ] } }
- metric_names(id, name=None, page=None)¶
Return a list of known metrics and their value names for the given resource.
Parameters: Return type: dict
Returns: The JSON response of the API, with an additional ‘pages’ key if there are paginated results
{ "metrics": [ { "name": "string", "values": [ "string" ] } ], "pages": { "last": { "url": "https://api.newrelic.com/v2/servers/{server_id}/metrics.json?page=2", "rel": "last" }, "next": { "url": "https://api.newrelic.com/v2/servers/{server_id}/metrics.json?page=2", "rel": "next" } } }
- show(id)¶
This API endpoint returns a single Server, identified its ID.
Parameters: id (int) – Server ID Return type: dict Returns: The JSON response of the API { "server": { "id": "integer", "account_id": "integer", "name": "string", "host": "string", "reporting": "boolean", "last_reported_at": "time", "summary": { "cpu": "float", "cpu_stolen": "float", "disk_io": "float", "memory": "float", "memory_used": "integer", "memory_total": "integer", "fullest_disk": "float", "fullest_disk_free": "integer" } } }
- update(id, name=None)¶
Updates any of the optional parameters of the server
Parameters: Return type: dict
Returns: The JSON response of the API
{ "server": { "id": "integer", "account_id": "integer", "name": "string", "host": "string", "reporting": "boolean", "last_reported_at": "time", "summary": { "cpu": "float", "cpu_stolen": "float", "disk_io": "float", "memory": "float", "memory_used": "integer", "memory_total": "integer", "fullest_disk": "float", "fullest_disk_free": "integer" } } }