GithubHelp home page GithubHelp logo

isabella232 / cloud-foundry-sampleapp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wavefronthq/cloud-foundry-sampleapp

0.0 0.0 0.0 23 KB

Wavefront Cloud Foundry (Spring Boot) Sample Application

Java 100.00%

cloud-foundry-sampleapp's Introduction

Wavefront Cloud Foundry Sample Spring Boot Application

This project describes how to send application metrics from a Spring Boot app running in PCF to a Wavefront proxy.

Requirements

Wavefront Proxy

The rest of this document assumes the wavefront proxy service instance provisioned in PCF is called wfproxy-service. Replace the service name accordingly if different.

Application Manifest

A manifest.yml file is used to provide parameters to a PCF application. The developer needs to identify the wavefront proxy running in PCF and add it to the manifest file.

Here is a sample manifest file:

---
 services:
  - wfproxy-service

Maven pom.xml File

Update the Maven pom.xml file to include the wavefrontHQ public repositories and dependencies dropwizard-metrics-3.1. It should also include spring-boot-maven-plugin and maven-shade-plugin.

Parse VCAP_SERVICES

The VCAP_SERVICES present in the manifest file (or externally bound to the application using cf bind-services ... command) are passed to the application as environment variable. It is parsed to retrieve the wavefront-proxy hostname and port:

VCAP_SERVICES =
{
  "wavefront-proxy": [
    {
      "credentials": {
        "hostname": "10.202.1.15",
        "port": 2878
      },
      "syslog_drain_url": null,
      "volume_mounts": [],
      "label": "wavefront-proxy",
      "provider": null,
      "plan": "standard",
      "name": "wfproxy-service",
      "tags": [
        "wavefront",
        "metrics"
      ]
    }
  ]
}

Send metrics from the application

Most of the sample code is present in the MetricSystem.java file. It determines all the metrics to be reported and adds them to the metricRegistry. The WavefrontReporter is then used to send the metrics to the proxy.

WavefrontReporter wfReporter = WavefrontReporter.forRegistry(metricRegistry)
    .withSource("springboot")
    .prefixedWith("pcf")
    .bindToCloudFoundryService("wavefront-proxy", true);
wfReporter.start(10,  TimeUnit.SECONDS);

The wavefront-proxy is the name of the wavefront proxy service running in PCF. The Wavefront tile should be used to install the wavefront proxy service. Once the tile is installed, the default name of the wavefront proxy service will be wavefront-proxy.

There are additional overloaded methods available in WavefrontReporter class, which can be used to bind to wavefront proxy (e.g., bindToCloudFoundryService()).

Build and push the application

mvn clean install -DskipTests
cf login -a <pcf-api-url> --skip-ssl-validation --sso
cf push wavefront-sample-app -f src/main/resources/manifest.yml -p target/springboot-0.0.1-SNAPSHOT.jar
cf logs wavefront-sample-app --recent

If the manifest does not have wavefront-proxy service info, then the service can be bound to it later using the following commands:

cf bind-service wavefront-sample-app wfproxy-service
cf restage wavefront-sample-app

cloud-foundry-sampleapp's People

Contributors

vikramraman avatar spramanik4667 avatar akodali18 avatar sushantdewan123 avatar panghy avatar haosong avatar bnarasimmaraj avatar

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.