New Relic's infrastructure agent provides an SDK for creating an on-host integration. This document explains requirements and best practices for generating integration logs.
It's up to the you to decide what kind of log messages to create, and what kind of information will be useful for debugging issues. There's only one requirement: the integration executable must write logs to standard error (stderr).
The infrastructure agent will capture lines written to standard error and merge them into the logging stream written by the infrastructure agent itself.
To avoid depending on third-party logging solutions, the Go integration building library provides a simple log package with the common log-levels.
Recommendations and best practices
Here are the recommended practices for generating integration logs:
- By default, an integration should be "quiet." Aside from the data emitted to standard output, there should be very few logging or diagnostic messages generated.
- We recommended you to include a verbose logging mode similar to the
verbosesetting in the infrastructure agent. Include a command line switch to enable and disable verbose logging (for example,
- To debug your integration while the integration is running, include the verbose switch in the definition file as part of the command line to be run. This will send the verbose logs to the Infrastructure agent's own log file.
- For general debugging purposes, use a flag that writes the standard out JSON data in human-readable "pretty-printed" form (for example,
--pretty). Note that output written in a "pretty-printed" form is only for your debugging purposes and is not compatible with the infrastructure agent.
- Your integration should be created so that it can run on its own. If in doubt whether the integration is communicating with the agent, you can run the integration from the command line and see if it's producing the correct output or log messages you expect.
For information about the Go language logging package, see Logging package.