Skip to content

Latest commit

 

History

History
47 lines (31 loc) · 1.64 KB

File metadata and controls

47 lines (31 loc) · 1.64 KB

Stackdriver sample for Google Compute Engine

Open in Cloud Shell

This sample demonstrates how to use Stackdriver on Google Compute Engine

Running on Compute Engine

  1. Create a compute instance on the Google Cloud Platform Developer's Console

  2. SSH into the instance you created

  3. Update packages and install required packages sudo apt-get update && sudo apt-get install git-core openjdk-8-jdk maven

  4. Follow the instructions to Install the Stackdriver Logging Agent

  5. Create /etc/google-fluentd/config.d/forward.conf and add

    <source>
      type forward
      port 24224
    </source>
  6. Restart the logging agent

    sudo service google-fluentd restart

  7. Clone the repo

    git clone https://github.com/GoogleCloudPlatform/java-docs-samples.git

  8. Navigate to the Stackdriver sample folder

    java-docs-samples/compute/stackdriver

  9. Make sure that openjdk 8 is the selected java version

    sudo update-alternatives --config java

  10. Use maven to package the class as a jar

    mvn clean package

  11. Switch to the target folder and execute the jar file

    java -jar compute-stackdriver-1.0-SNAPSHOT-jar-with-dependencies.jar

  12. On the Developer's Console, navigate to Stackdriver Error Reporting and verify that the sample error was logged.