Plugin API responses and error codes

Depending on whether you are using the API for New Relic Plugins or a New Relic agent SDK for plugins, the HTTP responses and logging techniques may be different. For example, responses for the Plugin API are uncompressed JSON. Successful posts return this JSON:

{"status":"ok"}

The New Relic Plugins product does not support Accept-Encoding.

Debugging logs

To debug information, use either of these options:

  public static Logger getLogger();

OR

  public static void Logger setLogger(Logger logger) {
  LOGGER = logger;
  }

Error codes

If an error occurs, then New Relic Plugins will return an appropriate status code. The json returned is the hash key error with a detailed description of the error that occurred. For example:

{"error":"Failed to create agent with parameters=[...]"}
     {"error":"Missing metric data"}
     {"error":"Unable to parse body: Unexpected token RIGHT BRACE(}) at position 228."}
Code Name Description
400 Bad request The request or headers are in the wrong format, or the URL is incorrect, or the GUID does not meet the validation requirements.
403 Unauthorized Authentication error (no license key header, or invalid license key).
404 Not found Invalid URL.
405 Method not allowed Returned if the method is an invalid or unexpected type (GET/POST/PUT/etc.).
413 Request entity too large Too many metrics were sent in one request, or too many components (instances) were specified in one request, or other single-request limits were reached.
500 Internal server error Unexpected server error.
502 Bad gateway All 50X errors mean there is a transient problem in the server completing requests, and no data has been retained. Clients are expected to resend the data after waiting one minute. The data should be aggregated appropriately, combining multiple timeslice data values for the same metric into a single aggregate timeslice data value.
503 Service unavailable See 502 description.
504 Gateway timeout See 502 description.

For more help

Recommendations for learning more: