You can use New Relic's REST API to obtain a list of metric timeslice data about your plugin's components (instances), including metric names and values, for the account associated with your API key.
Tip
When using these examples, be sure to replace each placeholder (for example, ${COMPONENT_ID}
) with its specific ID.
Listing a component's metric names
To obtain a list of the metric names for a single component by its ${COMPONENT_ID}
, use this API call:
curl -X GET "https://api.newrelic.com/v2/components/${COMPONENT_ID}/metrics.json" \ -H "X-Api-Key:${APIKEY}" -i
The output (JSON format) lists the metric name and values:
{ "metrics": [ { "name": "Agent/MetricsReported/count", <---<<< METRIC_NAME "values": [ "average_response_time", <---<<< METRIC_VALUES listing "calls_per_minute", "call_count", "min_response_time", "max_response_time", "average_exclusive_time", "average_value", "requests_per_minute", "standard_deviation" ] }, { "name": "Component/Client SSL Profiles/Current Cache Entries//Common/clientssl-insecure-compatible[entries]", "values": [ "average_value", "total_value", "max_value", "min_value", "standard_deviation", "rate", "count" ] }, ... }}
Listing a specific metric name and values
To obtain a single metric name and the available metric values for a specific plugin component, replace the ${COMPONENT_ID} and ${METRIC_NAME} placeholders with the actual values in the following API call:
curl -X GET "https://api.newrelic.com/v2/components/${COMPONENT_ID}/metrics.json" \ -H "X-Api-Key:${APIKEY}" -i \ -d "name=${METRIC_NAME}"
The output will be similar to what appears when you create an API call for multiple metric names.
Specifying the metric data values
To obtain the metric timeslice data for a specific component, use any of the following API calls. Be sure to replace the ${COMPONENT_ID}, ${APIKEY}, ${METRIC_NAME} and ${METRIC_VALUE} placeholders with the actual values.
If you want to... | Use this API call... |
---|---|
Obtain all metric values | Use the metric name to acquire all the metric values:
|
Obtain a single metric value | Specify the metric name and the metric value:
|
Change the default time period and UTC | Specify
|
Return average metric data | Include
|
For more help
If you need more help, check out these support and learning resources:
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's data security and licenses documentation.