Giter VIP home page Giter VIP logo

newrelic-cf's Introduction

Archived header

New Relic Service Broker for Cloud Foundry

This repository contains a New Relic Service Broker for Cloud Foundry that allows you to automatically bind New Relic language agents with your applications in Cloud Foundry environments.

##Prerequisites

  • One or more New Relic accounts/sub-accounts
  • A New Relic valid license key for each account.
    You can obtain the license key for each account from your New Relic account under 'Account Settings'
  • A running Cloud Foundry environment
  • Proxy host and port details if your PCF environment is behind a firewall

##Installation Overview

  1. Download the New Relic Service Broker JAR file and the manifest.yml file
  2. Edit the manifest.yml file
  3. Push the Service Broker jar file to Cloud Foundry as an application
  4. Create a Service Broker
  5. Enable Access to the Service Broker
  6. Create a Service for each New Relic Account
  7. Bind the Service to your application
  8. (Optional) Add Proxy configuration
  9. Re-Stage or re push your application

##Installation Instructions #####1. Download the 2 files

  • new-relic-service-broker.jar
  • manifest.yml

#####2. Edit the manifest.yml file

  1. Specify the correct "domain" for your PCF environment
  2. Add a section at the end of the file to define the following 3 environment variables:
env:
    SECURITY_USER_NAME: "<DIRECTOR_USER_NAME>"
    SECURITY_USER_PASSWORD: "<DIRECTOR_PASSWORD>"
    NRPLANS: '<A JSON ARRAY CONTAINING ONE OR MORE PLANS/LICENSE KEYS>'

Note 1: "env:" must be preceded with exactly 2 spaces, and each variable name must be preceded with exactly 4 spaces.

Note 2: The "NRPLANS" environment variable is a JSON array object. In this object you will define a key: value pair for each New Relic account you wish to provide access to. The structure is:

{"planName" : "the name you want to display", "licenseKey" : "the license key from your New Relic account" }

The “planName” is how your developers will know which New Relic account to use for their applications.
Name it such that users will know which New Relic account to use.
Note 3. "planName" cannot contain any spaces (you can use dashes or camelCase to separate words).

The "licenseKey" value can be found in the "Account Administration" menu option from the top right corner of New Relic. Plan names are free form text with no spaces, you can use dashes between words.
Note 4 NRPLANS json array must be defined all in one line.

Here is a sample "NRPLANS" JSON array object:

NRPLANS: '[{"planName" : "New-Relic-Test", "licenseKey" : "712345678901234567890123456789012345e21d"}, {"planName" : "New-Relic-Production", "licenseKey" : "79999999999999999999999999999999999e21d"}}]'

#####3. Push the Service Broker jar file to Cloud Foundry as an application

cd '<SERVICE_BROKER_DIRECTORY>'
cf push

This will push the service broker into Cloud Foundry and start it running.
sample output:

broker: test-sb
service         plan                    access orgs   
newrelic-test   New-Relic-Test          none        
newrelic-test   New-Relic-Production    none        

Notes:

  • Make a note of the URL for the service broker app
  • Make a note of the "service" name

#####4. Create a Service Broker
cf create-service-broker <SERVICE_BROKER_NAME> <USER> <PASSWORD> <SERVICE_BROKER_URL>

  • SERVICE_BROKER_NAME: pick a name for your service broker
  • USER: an admin user who has privileges to create service brokers
  • PASSWORD: password for the admin user
  • SERVICE_BROKER_URL: the url that was returned as a result of pushing the service broker app

#####5. Enable Access to the Service Broker

cf enable-service-access <SERVICE>
  • SERVICE: the service name that was returned from "cf push" (i.e. "newrelic-test")
    You can also run "cf marketplace" to get the service name This command ensures that access to all plans offered by the service are available for use.

#####6. Create a Service for each New Relic Account Create a service for "each" of the plans (in our example you need to run “cf create-service” 2 times)

cf create-service <SERVICE_BROKER_SERVICE_NAME> <SERVICE_BROKER_PLAN> <SERVICE_INSTANCE>
  • SERVICE_BROKER_SERVICE_NAME: the service name for service broker (i.e. "newrelic-test")
  • SERVICE_BROKER_PLAN: plan name offered by the service broker (i.e. "New-Relic-Test")
  • SERVICE_INSTANCE: descriptive name of the service instance as you wish to set (i.e. "New Relic Account for our Test Environment")

Run "cf services" to make sure all your service instances have properly been created

#####7. Bind the Service to your application Assuming that your applications are already pushed to Cloud Foundry, these services can be bound to your applications to use New Relic language agents and monitor your applications

cf bind-service <APP_NAME> <SERVICE_INSTANCE>

#####8. (Optional) If you are behind a proxy, add the proxy settings to your application

cf set-env <APP_NAME> JAVA_OPTS "-Dnewrelic.config.proxy_host=proxy.yourCompany.com -Dnewrelic.config.proxy_port=nnn"

Note: If you're using a proxy across all of your applications, you may want to implement a PCF 'Environment Variable Group' for the staging process.

$ cf ssevg '{"JAVA_OPTS":"-Dnewrelic.config.proxy_host=proxy.yourCompany.com -Dnewrelic.config.proxy_port=nnn"}'
Setting the contents of the running environment variable group as admin...
OK
$ cf sevg
Retrieving the contents of the running environment variable group as admin...
OK
Variable Name   Assigned Value
JAVA_OPTS           -Dnewrelic.config.proxy_host=proxy.yourCompany.com -Dnewrelic.config.proxy_port=nnn

This will enable you to set the JAVA_OPTS parameters on a more global basis such that all applications would inherit the settings without the need to add application level settings to each application. You can find more details on that here: https://docs.pivotal.io/pivotalcf/devguide/deploy-apps/environment-variable.html#evgroups

#####9. Re-Stage or re push your application

cf restage MY_SAMPLE_APP

Additional Note If you would like to add more Services / Accounts after completing this process, it's easy. You'll simply need to add your new plan(s), restage the broker and then enable the access. Here's how:

cf env NRPLANS: '[{"planName" : "My-New-Plan", "licenseKey" : "71234567890123456789012345678901234aabbc"}]'
cf restage MY_SAMPLE_APP
cf enable-service-access <SERVICE>

where JSON_OBJ = the new set of plans with new license keys. (The old ones will stay intact).

newrelic-cf's People

Contributors

melissaklein24 avatar shahramk avatar tmartin14 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

newrelic-cf's Issues

Include source code

The repository contains the JAR file, without the actual source code of the broker. Could that be included, so that it can be inspected/tweaked?

Binding an app to a Newrelic Service on OpenSource Cloud Foundry

Does this newrelic-cf broker only work on Pivotal Cloud Foundry (PCF) instances or should it also work on CF Open Source editions? Reason I ask is that I have successfully installed the service broker and bound some basic groovy apps to it on a PCF instance which lights up the new Relic APM dashboard. However when installing on an open source edition of CF it fails when binding the same apps to the service.

Output of the error message is:
AJ-MBP:newrelic-cf adam$ cf bind-service aj-blue aj-monitor-cf
Binding service aj-monitor-cf to app aj-blue in org adam / space systems as [email protected]...
FAILED
Server error, status code: 502, error code: 10001, message: The service broker rejected the request to http://service-broker-questioning-decresc.apps.demo.labs.cf.canopy-cloud.com/v2/service_instances/b6c56836-dbb9-48d2-8b5d-ad23d6ca90b0/service_bindings/bcf2f2ad-c6e9-4ff4-8a1c-c627e80f311c. Status Code: 400 Bad Request, Body: {"timestamp":1445613681936,"status":400,"error":"Bad Request","exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"Could not read JSON: Unrecognized field "bind_resource" (class com.nebhale.newrelicservicebroker.binding.BindingRequest), not marked as ignorable (6 known properties: "serviceId", "plan_id", "planId", "service_id", "app_guid", "appGuid"])\n at [Source: org.apache.catalina.connector.CoyoteInputStream@49865307; line: 1, column: 170](through reference chain: com.nebhale.newrelicservicebroker.binding.BindingRequest["bind_resource"]); nested exception is com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "bind_resource" (class com.nebhale.newrelicservicebroker.binding.BindingRequest), not marked as ignorable (6 known properties: "serviceId", "plan_id", "planId", "service_id", "app_guid", "appGuid"])\n at [Source: org.apache.catalina.connector.CoyoteInputStream@49865307; line: 1, column: 170](through reference chain: com.nebhale.newrelicservicebroker.binding.BindingRequest["bind_resource"])","path":"/v2/service_instances/b6c56836-dbb9-48d2-8b5d-ad23d6ca90b0/service_bindings/bcf2f2ad-c6e9-4ff4-8a1c-c627e80f311c"}

Would appreciate some help on understanding the issue and confirmation on whether the broker should work on all CF environments or just Pivotal ones.

Adam

New field introduced in Broker Api 2.12 not handled

A new field "context" has been introduced in the Broker API, so on recent CF deployments
cf create-service newrelic serviceplan xyz will fail with

Server error, status code: 502, error code: 10001, message: The service broker rejected the request to http://pe-cf-newrelic.xxx.com/v2/service_instances/uuid?accepts_incomplete=true. Status Code: 400 Bad Request, Body: {"timestamp":1511947927619,"status":400,"error":"Bad Request","exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"Could not read JSON: Unrecognized field \"context\" (class com.nebhale.newrelicservicebroker.provisioning.ProvisioningRequest), not marked as ignorable (8 known properties: \"serviceId\", \"plan_id\", \"space_guid\", \"planId\", \"service_id\", \"organization_guid\", \"organizationGuid\", \"spaceGuid\"])\n at [Source: org.apache.catalina.connector.CoyoteInputStream@4f3b6e16; line: 1, column: 225] (through reference chain: com.nebhale.newrelicservicebroker.provisioning.ProvisioningRequest[\"context\"]); nested exception is com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field \"context\" (class com.nebhale.newrelicservicebroker.provisioning.ProvisioningRequest), not marked as ignorable (8 known properties: \"serviceId\", \"plan_id\", \"space_guid\", \"planId\", \"service_id\", \"organization_guid\", \"organizationGuid\", \"spaceGuid\"])\n at [Source: org.apache.catalina.connector.CoyoteInputStream@4f3b6e16; line: 1, column: 225] (through reference chain: com.nebhale.newrelicservicebroker.provisioning.ProvisioningRequest[\"context\"])","path":"/v2/service_instances/uuid"}

This is the change: https://github.com/openservicebrokerapi/servicebroker/blob/v2.12/spec.md#changes-since-v211

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.