Skip to content

msummers-nr/Metric-Replicator

Repository files navigation

New Relic API Client (Java) Build Status

Java library for interfacing with New Relic APIs

Setting up your credentials

There is a template config file in the config directory, it is in HOCON format. You can make a copy of this file for your own configuration. The config uses different identifiers, this section of the documentation covers API Keys and how they are used.

Name Description
accountName Just a label to help know the name of the account, used in logging.
adminName A label to know who is the owner of the Admin API Key.
accountId The Account ID is required to query data from your account.
licenseKey The License Key is used for Agents or Plugins to send data to your account.
restKey The Rest API Key can be used to query certain kinds of data, it's recommended to use an Admin Key which provides more flexibility.
adminKey The Admin API Key is like the Rest API Key but tied to a single admin user, there are also a few API calls that require this key.
insightsQueryKey The Insights Query API Key is used to run NRQL queries and process the results.
insightsInsertKey The Insights Insert API Key is used to publish custom events into Insights.

Using your custom config

Once you make a copy of config/template.conf to your own file, then you reference it with -Dconfig.file at runtime.

Building and running the tests

This project relies on gradle, so you can test that everything is working properly (including your config file) like this:

$ ./gradlew -Dconfig.file=config/myconfig.conf test
:compileJava
:processResources UP-TO-DATE
:classes
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test
Hibernate: drop table account if exists
Hibernate: drop table application if exists

BUILD SUCCESSFUL

Total time: 6.39 secs

Tasks

In addition to including Java libraries for working with the API, this project also can run as a Spring Boot application. Developers can create tasks such as an ETL-style program for working with the API on a regular schedule. There are currently a couple of tasks available.

Metrics Copier Task

This task will copy metrics from a source account (through the Applications API) and publish to a destination account (through the Insights Insert API). You configure the task with a config section like this:

	tasks {
		metricsCopier {
			enabled = false
			source.account = "defaultAccount"
			source.metricFile = "config/metricsTemplate.csv"
			dest.account = "defaultAccount"
			dest.eventType = "MetricTest"
		}
	}

Here are all the sections underneath tasks.metricsCopier:

  • enabled (default: false) - set to true so you can use this task
  • source.account - where you will query for data (needs to match the name of an account from the accounts section)
  • source.metricFile - location of the metric CSV file containing the source metrics to copy out
  • dest.account - where you want to publish the results (needs to match the name of an account from the accounts section)
  • dest.eventType - name of the eventType in Insights for the created events

In addition to the config file you need to make a metric CSV with the metrics you want to copy out. Copy the metricTemplate.csv file and then add in your values. Here are the fields for the CSV:

  • appName - name of the application
  • appId - application id in the New Relic API
  • configType - you must choose whether to collect data at the application, application_host or application_instance
  • metricName - exact metric name to query
  • shortName - short version of the name

Synthetics Copier Task

This task will query the current result (SUCCESS or FAIL) for every location for every monitor. It publishes the response data in the same format as this Synthetics Plugin as well as sending the data as Insights events.

	tasks {
		syntheticsCopier {
			enabled = false
			source.account = "defaultAccount"
			dest.account = "defaultAccount"
		}
	}

Here are all the sections underneath tasks.metricsCopier:

  • enabled (default: false) - set to true so you can use this task
  • source.account - where you will query for data (needs to match the name of an account from the accounts section)
  • dest.account - where you want to publish the results (needs to match the name of an account from the accounts section)

API Details

There are multiple API systems involved, these tables have additional details.

API Coverage

Type Status Description
Rest v2 API (not Alerts) Partial Query apps, metric names and data and POST to Plugins
Rest v2 API (Alerts) Not supported yet Alerts in a separate list because it's a large set of APIs
Insights API Partial The query and insert calls are supported
Synthetics API Not supported yet CRUD functionality for Synthetic Monitors

Deprecated / Will Not Support

  • Servers
  • Legacy Alert Policies
  • Legacy Notification Channels

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages