New Relic
Our New Relic integration allows you to import entities
and issues
from your New Relic cloud account into Port, according to your mapping and definition.
An Entity
can be a host, an application, a service, a database, or any other component that sends data to New Relic.
An Issue
is a group of incidents that describe the underlying problem of your symptoms.
Common use casesโ
- Map your monitored applications and services in New Relic with their current open alerts.
- Watch for new alerts and updates raised on your monitored applications and automatically synchronize them into Port.
Prerequisitesโ
To install the integration, you need a Kubernetes cluster that the integration's container chart will be deployed to.
Please make sure that you have kubectl
and helm
installed on your machine, and that your kubectl
CLI is connected to the Kubernetes cluster where you plan to install the integration.
Installationโ
Choose one of the following installation methods:
- Real Time & Always On
- Scheduled
Using this installation option means that the integration will be able to update Port in real time.
This table summarizes the available parameters for the installation. Set them as you wish in the script below, then copy it and run it in your terminal:
Parameter | Description | Required |
---|---|---|
port.clientId | Your port client id | โ |
port.clientSecret | Your port client secret | โ |
port.baseUrl | Your port base url, relevant only if not using the default port app | โ |
integration.identifier | Change the identifier to describe your integration | โ |
integration.type | The integration type | โ |
integration.eventListener.type | The event listener type | โ |
integration.secrets.newRelicAPIKey | The New Relic API key | โ |
integration.secrets.newRelicAccountID | The New Relic account ID | โ |
scheduledResyncInterval | The number of minutes between each resync | โ |
initializePortResources | Default true, When set to true the integration will create default blueprints and the port App config Mapping | โ |
If you are using New Relic's EU region, add the following flag to the command:
--set integration.config.newRelicGraphqlURL="https://api.eu.newrelic.com/graphql"
# The following script will install an Ocean integration at your K8s cluster using helm
# initializePortResources: When set to true the integration will create default blueprints + JQ Mappings
# scheduledResyncInterval: the number of minutes between each resync
# integration.identifier: Change the identifier to describe your integration
helm repo add --force-update port-labs https://port-labs.github.io/helm-charts
helm upgrade --install my-newrelic-integration port-labs/port-ocean \
--set port.clientId="PORT_CLIENT_ID" \
--set port.clientSecret="PORT_CLIENT_SECRET" \
--set port.baseUrl="https://api.getport.io" \
--set initializePortResources=true \
--set scheduledResyncInterval=120 \
--set integration.identifier="my-newrelic-integration" \
--set integration.type="newrelic" \
--set integration.eventListener.type="POLLING" \
--set integration.secrets.newRelicAPIKey="<NR_API_KEY>" \
--set-string integration.secrets.newRelicAccountID=<NR_ACCOUNT_ID>
- GitHub
- Jenkins
This workflow will run the New Relic integration once and then exit, this is useful for scheduled ingestion of data.
If you want the integration to update Port in real time you should use the Real Time & Always On installation option
Make sure to configure the following Github Secrets:
Parameter | Description | Required |
---|---|---|
OCEAN__INTEGRATION__CONFIG__NEW_RELIC_API_KEY | The New Relic API key | โ |
OCEAN__INTEGRATION__CONFIG__NEW_RELIC_ACCOUNT_ID | The New Relic account ID | โ |
OCEAN__INITIALIZE_PORT_RESOURCES | Default true, When set to false the integration will not create default blueprints and the port App config Mapping | โ |
OCEAN__INTEGRATION__IDENTIFIER | Change the identifier to describe your integration, if not set will use the default one | โ |
OCEAN__PORT__CLIENT_ID | Your port client id | โ |
OCEAN__PORT__CLIENT_SECRET | Your port client secret | โ |
OCEAN__PORT__BASE_URL | Your port base url, relevant only if not using the default port app | โ |
Here is an example for newrelic-integration.yml
workflow file:
If you are using New Relic's EU region, add the following flag to the docker command:
-e OCEAN__INTEGRATION__CONFIG__NEW_RELIC_URL=https://api.eu.newrelic.com/graphql
name: New Relic Exporter Workflow
# This workflow responsible for running New Relic exporter.
on:
workflow_dispatch:
jobs:
run-integration:
runs-on: ubuntu-latest
steps:
- name: Run New Relic Integration
run: |
# Set Docker image and run the container
integration_type="newrelic"
version="latest"
image_name="ghcr.io/port-labs/port-ocean-$integration_type:$version"
docker run -i --rm --platform=linux/amd64 \
-e OCEAN__EVENT_LISTENER='{"type":"ONCE"}' \
-e OCEAN__INITIALIZE_PORT_RESOURCES=true \
-e OCEAN__INTEGRATION__CONFIG__NEW_RELIC_API_KEY=${{ secrets.OCEAN__INTEGRATION__CONFIG__NEW_RELIC_API_KEY }} \
-e OCEAN__INTEGRATION__CONFIG__NEW_RELIC_ACCOUNT_ID=${{ secrets.OCEAN__INTEGRATION__CONFIG__NEW_RELIC_ACCOUNT_ID }} \
-e OCEAN__PORT__CLIENT_ID=${{ secrets.OCEAN__PORT__CLIENT_ID }} \
-e OCEAN__PORT__CLIENT_SECRET=${{ secrets.OCEAN__PORT__CLIENT_SECRET }} \
$image_name
exit $?
This pipeline will run the New Relic integration once and then exit, this is useful for scheduled ingestion of data.
Your Jenkins agent should be able to run docker commands.
If you want the integration to update Port in real time using webhooks you should use the Real Time & Always On installation option.
Make sure to configure the following Jenkins Credentials of Secret Text
type:
Parameter | Description | Required |
---|---|---|
OCEAN__INTEGRATION__CONFIG__NEW_RELIC_API_KEY | The New Relic API key | โ |
OCEAN__INTEGRATION__CONFIG__NEW_RELIC_ACCOUNT_ID | The New Relic account ID | โ |
OCEAN__INITIALIZE_PORT_RESOURCES | Default true, When set to false the integration will not create default blueprints and the port App config Mapping | โ |
OCEAN__INTEGRATION__IDENTIFIER | Change the identifier to describe your integration, if not set will use the default one | โ |
OCEAN__PORT__CLIENT_ID | Your port client id | โ |
OCEAN__PORT__CLIENT_SECRET | Your port client secret | โ |
OCEAN__PORT__BASE_URL | Your port base url, relevant only if not using the default port app | โ |
Here is an example for Jenkinsfile
groovy pipeline file:
If you are using New Relic's EU region, add the following flag to the docker command:
-e OCEAN__INTEGRATION__CONFIG__NEW_RELIC_URL=https://api.eu.newrelic.com/graphql
pipeline {
agent any
stages {
stage('Run New Relic Integration') {
steps {
script {
withCredentials([
string(credentialsId: 'OCEAN__INTEGRATION__CONFIG__NEW_RELIC_API_KEY', variable: 'OCEAN__INTEGRATION__CONFIG__NEW_RELIC_API_KEY'),
string(credentialsId: 'OCEAN__INTEGRATION__CONFIG__NEW_RELIC_ACCOUNT_ID', variable: 'OCEAN__INTEGRATION__CONFIG__NEW_RELIC_ACCOUNT_ID'),
string(credentialsId: 'OCEAN__PORT__CLIENT_ID', variable: 'OCEAN__PORT__CLIENT_ID'),
string(credentialsId: 'OCEAN__PORT__CLIENT_SECRET', variable: 'OCEAN__PORT__CLIENT_SECRET'),
]) {
sh('''
#Set Docker image and run the container
integration_type="newrelic"
version="latest"
image_name="ghcr.io/port-labs/port-ocean-${integration_type}:${version}"
docker run -i --rm --platform=linux/amd64 \
-e OCEAN__EVENT_LISTENER='{"type":"ONCE"}' \
-e OCEAN__INITIALIZE_PORT_RESOURCES=true \
-e OCEAN__INTEGRATION__CONFIG__NEW_RELIC_API_KEY=$OCEAN__INTEGRATION__CONFIG__NEW_RELIC_API_KEY \
-e OCEAN__INTEGRATION__CONFIG__NEW_RELIC_ACCOUNT_ID=$OCEAN__INTEGRATION__CONFIG__NEW_RELIC_ACCOUNT_ID \
-e OCEAN__PORT__CLIENT_ID=$OCEAN__PORT__CLIENT_ID \
-e OCEAN__PORT__CLIENT_SECRET=$OCEAN__PORT__CLIENT_SECRET \
$image_name
exit $?
''')
}
}
}
}
}
}
Event listenerโ
The integration uses polling to pull the configuration from Port every minute and check it for changes. If there is a change, a resync will occur.
Ingesting Newrelic objectsโ
The Newrelic integration uses a YAML configuration to describe the process of loading data into the developer portal.
Here is an example snippet from the config which demonstrates the process for getting Issue
data from Newrelic:
resources:
- kind: newRelicAlert
selector:
query: "true"
newRelicTypes: ["ISSUE"]
port:
entity:
mappings:
blueprint: '"newRelicAlert"'
identifier: .issueId
title: .title[0]
properties:
priority: .priority
state: .state
sources: .sources
conditionName: .conditionName
alertPolicyNames: .policyName
activatedAt: .activatedAt
relations:
newRelicService: .__APPLICATION.entity_guids + .__SERVICE.entity_guids
The integration makes use of the JQ JSON processor to select, modify, concatenate, transform and perform other operations on existing fields and values from Newrelic's API events.
Configuration structureโ
The integration configuration determines which resources will be queried from Newrelic, and which entities and properties will be created in Port.
-
The root key of the integration configuration is the
resources
key:resources:
- kind: project
selector:
... -
The
kind
key is a specifier for a Newrelic object:resources:
- kind: project
selector:
... -
The
selector
key allows you to filter which objects of the specifiedkind
will be ingested into your software catalog:resources:
- kind: newRelicService
selector:
query: "true"
newRelicTypes: ["SERVICE", "APPLICATION"]
calculateOpenIssueCount: true
entityQueryFilter: "type in ('SERVICE','APPLICATION')"
entityExtraPropertiesQuery: |
... on ApmApplicationEntityOutline {
guid
name
}- newRelicTypes - An array of Newrelic entity types that will be fetched. The default value is ['SERVICE', 'APPLICATION']. This is related to the type field in the Newrelic entity.
- calculateOpenIssueCount:
- A boolean value that indicates if the integration should calculate the number of open issues for each entity. The default value is `false``.
- NOTE - This can cause a performance degradation as the integration will have to calculate the number of open issues for each entity, which unfortunately is not supported by the New Relic API.
- entityQueryFilter:
- A filter that will be applied to the New Relic API query. This will be placed inside the
query
field of theentitySearch
query in the New Relic GraphQL API. For examples of query filters click here. - Not specifying this field will cause the integration to fetch all the entities and map them to the blueprint defined in the
kind
. - Rule of thumb - Most of the time the
EntityQueryFilter
will be the same as theNewRelicTypes
. For example, if we want to fetch all the services and applications we will set theEntityQueryFilter
totype in ('SERVICE','APPLICATION')
and theNewRelicTypes
to['SERVICE', 'APPLICATION']
.
- A filter that will be applied to the New Relic API query. This will be placed inside the
- entityExtraPropertiesQuery:
- An optional property that allows defining extra properties to fetch for each Newrelic entity. This will be concatenated with the default query properties we are requesting under the
entities
section in theentitySearch
query in the Newrelic GraphQL API. For examples of additional query properties click here.
- An optional property that allows defining extra properties to fetch for each Newrelic entity. This will be concatenated with the default query properties we are requesting under the
-
The
port
,entity
and themappings
keys are used to map the Newrelic object fields to Port entities. To create multiple mappings of the same kind, you can add another item in theresources
array;resources:
- kind: newRelicAlert
selector:
query: "true"
newRelicTypes: ["ISSUE"]
port:
entity:
mappings:
blueprint: '"newRelicAlert"'
identifier: .issueId
title: .title[0]
properties:
priority: .priority
state: .state
sources: .sources
conditionName: .conditionName
alertPolicyNames: .policyName
activatedAt: .activatedAt
relations:
newRelicService: .__APPLICATION.entity_guids + .__SERVICE.entity_guids
- kind: newRelicAlert # In this instance project is mapped again with a different filter
selector:
query: '.name == "MyIssuetName"'
port:
entity:
mappings: ...:::tip Blueprint key Note the value of the
blueprint
key - if you want to use a hardcoded string, you need to encapsulate it in 2 sets of quotes, for example use a pair of single-quotes ('
) and then another pair of double-quotes ("
) :::
Tagsโ
Some Newrelic entities
have a property named tags
which contains potentially useful information such as machine information, hostname, agent name & version, and more. For example:
"tags": [
{
"key": "coreCount",
"values": [
"10"
]
},
{
"key": "hostStatus",
"values": [
"running"
]
},
]
Before mapping, this integration performs a tranformation on each tag
, after which the example above would look like this:
tags = ["coreCount":"10","hostStatus":"running"]
Ingest data into Portโ
To ingest Newrelic objects using the integration configuration, you can follow the steps below:
- Go to the DevPortal Builder page.
- Select a blueprint you want to ingest using Newrelic.
- Choose the Ingest Data option from the menu.
- Select Newrelic under the APM & alerting category.
- Add the contents of your integration configuration to the editor.
- Click
Resync
.
Examplesโ
Examples of blueprints and the relevant integration configurations:
Service (Entity)โ
Service blueprint
{
"identifier": "newRelicService",
"description": "This blueprint represents a New Relic service or application in our software catalog",
"title": "New Relic Service",
"icon": "NewRelic",
"schema": {
"properties": {
"has_apm": {
"title": "Has APM",
"type": "boolean"
},
"open_issues_count": {
"title": "Open Issues Count",
"type": "number",
"default": 0
},
"link": {
"title": "Link",
"type": "string",
"format": "url"
},
"reporting": {
"title": "Reporting",
"type": "boolean"
},
"tags": {
"title": "Tags",
"type": "object"
},
"account_id": {
"title": "Account ID",
"type": "string"
},
"type": {
"title": "Type",
"type": "string"
},
"domain": {
"title": "Domain",
"type": "string"
},
"throughput": {
"title": "Throughput",
"type": "number"
},
"response_time_avg": {
"title": "Response Time AVG",
"type": "number"
},
"error_rate": {
"title": "Error Rate",
"type": "number"
},
"instance_count": {
"title": "Instance Count",
"type": "number"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {}
}
Integration configuration
- kind: newRelicService
selector:
query: "true"
newRelicTypes: ["SERVICE", "APPLICATION"]
calculateOpenIssueCount: true
entityQueryFilter: "type in ('SERVICE','APPLICATION')"
entityExtraPropertiesQuery: |
... on ApmApplicationEntityOutline {
guid
name
alertSeverity
applicationId
apmBrowserSummary {
ajaxRequestThroughput
ajaxResponseTimeAverage
jsErrorRate
pageLoadThroughput
pageLoadTimeAverage
}
apmSummary {
apdexScore
errorRate
hostCount
instanceCount
nonWebResponseTimeAverage
nonWebThroughput
responseTimeAverage
throughput
webResponseTimeAverage
webThroughput
}
}
port:
entity:
mappings:
blueprint: '"newRelicService"'
identifier: .guid
title: .name
properties:
has_apm: 'if .domain | contains("APM") then "true" else "false" end'
link: .permalink
open_issues_count: .__open_issues_count
reporting: .reporting
tags: .tags
domain: .domain
type: .type
Issueโ
Issue blueprint
{
"identifier": "newRelicAlert",
"description": "This blueprint represents a New Relic alert in our software catalog",
"title": "New Relic Alert",
"icon": "NewRelic",
"schema": {
"properties": {
"priority": {
"type": "string",
"title": "Priority",
"enum": ["CRITICAL", "HIGH", "MEDIUM", "LOW"],
"enumColors": {
"CRITICAL": "red",
"HIGH": "red",
"MEDIUM": "yellow",
"LOW": "green"
}
},
"state": {
"type": "string",
"title": "State",
"enum": ["ACTIVATED", "CLOSED", "CREATED"],
"enumColors": {
"ACTIVATED": "yellow",
"CLOSED": "green",
"CREATED": "lightGray"
}
},
"trigger": {
"type": "string",
"title": "Trigger"
},
"sources": {
"type": "array",
"title": "Sources"
},
"alertPolicyNames": {
"type": "array",
"title": "Alert Policy Names"
},
"conditionName": {
"type": "array",
"title": "Condition Name"
},
"activatedAt": {
"type": "string",
"title": "Time Issue was activated"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {
"newRelicService": {
"title": "New Relic Service",
"target": "newRelicService",
"required": false,
"many": true
}
}
}
Integration configuration
- kind: newRelicAlert
selector:
query: "true"
newRelicTypes: ["ISSUE"]
port:
entity:
mappings:
blueprint: '"newRelicAlert"'
identifier: .issueId
title: .title[0]
properties:
priority: .priority
state: .state
sources: .sources
conditionName: .conditionName
alertPolicyNames: .policyName
activatedAt: .activatedAt
relations:
newRelicService: .__APPLICATION.entity_guids + .__SERVICE.entity_guids