Applications

newrelic_api.applications

class newrelic_api.applications.Applications(api_key=None)

An interface for interacting with the NewRelic application 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 application and all of its reported data.

WARNING: Only applications that have stopped reporting can be deleted.
This is an irreversible process which will delete all reported data for this application.
Parameters:id (int) – Application ID
Return type:dict
Returns:The JSON response of the API
{
    "application": {
        "id": "integer",
        "name": "string",
        "language": "string",
        "health_status": "string",
        "reporting": "boolean",
        "last_reported_at": "time",
        "application_summary": {
            "response_time": "float",
            "throughput": "float",
            "error_rate": "float",
            "apdex_target": "float",
            "apdex_score": "float"
        },
        "end_user_summary": {
            "response_time": "float",
            "throughput": "float",
            "apdex_target": "float",
            "apdex_score": "float"
        },
        "settings": {
            "app_apdex_threshold": "float",
            "end_user_apdex_threshold": "float",
            "enable_real_user_monitoring": "boolean",
            "use_server_side_config": "boolean"
        },
        "links": {
            "servers": [
                "integer"
            ],
            "application_hosts": [
                "integer"
            ],
            "application_instances": [
                "integer"
            ]
        }
    }
}
list(filter_name=None, filter_ids=None, filter_language=None, page=None)

This API endpoint returns a paginated list of the Applications associated with your New Relic account. Applications can be filtered by their name, the list of application IDs or the application language as reported by the agents.

Parameters:
  • filter_name (str) – Filter by application name
  • filter_ids (list of ints) – Filter by application ids
  • filter_language (str) – Filter by application language
  • page (int) – Pagination index
Return type:

dict

Returns:

The JSON response of the API

{
    "applications": [
        {
            "id": "integer",
            "name": "string",
            "language": "string",
            "health_status": "string",
            "reporting": "boolean",
            "last_reported_at": "time",
            "application_summary": {
                "response_time": "float",
                "throughput": "float",
                "error_rate": "float",
                "apdex_target": "float",
                "apdex_score": "float"
            },
            "end_user_summary": {
                "response_time": "float",
                "throughput": "float",
                "apdex_target": "float",
                "apdex_score": "float"
            },
            "settings": {
                "app_apdex_threshold": "float",
                "end_user_apdex_threshold": "float",
                "enable_real_user_monitoring": "boolean",
                "use_server_side_config": "boolean"
            },
            "links": {
                "servers": [
                    "integer"
                ],
                "application_hosts": [
                    "integer"
                ],
                "application_instances": [
                    "integer"
                ]
            }
        }
    ]
}
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:
  • id (int) – Application ID
  • names (list of str) – Retrieve specific metrics by name
  • values (list of str) – Retrieve specific metric values
  • from_dt (datetime) – Retrieve metrics after this time
  • to_dt (datetime) – Retrieve metrics before this time
  • summarize (bool) – Summarize the data
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:
  • id (int) – Application ID
  • name (str) – Filter metrics by name
  • page (int) – Pagination index
Return type:

dict

Returns:

The JSON response of the API

{
    "metric": {
        "name": "string",
        "values": [
            "string"
        ]
    }
}
show(id)

This API endpoint returns a single Application, identified its ID.

Parameters:id (int) – Application ID
Return type:dict
Returns:The JSON response of the API.
{
    "application": {
        "id": "integer",
        "name": "string",
        "language": "string",
        "health_status": "string",
        "reporting": "boolean",
        "last_reported_at": "time",
        "application_summary": {
            "response_time": "float",
            "throughput": "float",
            "error_rate": "float",
            "apdex_target": "float",
            "apdex_score": "float"
        },
        "end_user_summary": {
            "response_time": "float",
            "throughput": "float",
            "apdex_target": "float",
            "apdex_score": "float"
        },
        "settings": {
            "app_apdex_threshold": "float",
            "end_user_apdex_threshold": "float",
            "enable_real_user_monitoring": "boolean",
            "use_server_side_config": "boolean"
        },
        "links": {
            "servers": [
                "integer"
            ],
            "application_hosts": [
                "integer"
            ],
            "application_instances": [
                "integer"
            ]
        }
    }
}
update(id, name=None, app_apdex_threshold=None, end_user_apdex_threshold=None, enable_real_user_monitoring=None)

Updates any of the optional parameters of the application

Parameters:
  • id (int) – Application ID
  • name (str) – The name of the application
  • app_apdex_threshold (float) – Application apdex threshold to update
  • end_user_apdex_threshold (float) – End user apdex threshold to update
  • enable_real_user_monitoring (bool) – Whether to enable real user monitoring
Return type:

dict

Returns:

The JSON response of the API

{
    "application": {
        "id": "integer",
        "name": "string",
        "language": "string",
        "health_status": "string",
        "reporting": "boolean",
        "last_reported_at": "time",
        "application_summary": {
            "response_time": "float",
            "throughput": "float",
            "error_rate": "float",
            "apdex_target": "float",
            "apdex_score": "float"
        },
        "end_user_summary": {
            "response_time": "float",
            "throughput": "float",
            "apdex_target": "float",
            "apdex_score": "float"
        },
        "settings": {
            "app_apdex_threshold": "float",
            "end_user_apdex_threshold": "float",
            "enable_real_user_monitoring": "boolean",
            "use_server_side_config": "boolean"
        },
        "links": {
            "servers": [
                "integer"
            ],
            "application_hosts": [
                "integer"
            ],
            "application_instances": [
                "integer"
            ]
        }
    }
}