Class StackdriverWriter

java.lang.Object
org.jmxtrans.embedded.output.AbstractOutputWriter
org.jmxtrans.embedded.output.StackdriverWriter
All Implemented Interfaces:
OutputWriter

public class StackdriverWriter
extends AbstractOutputWriter
implements OutputWriter
Stackdriver implementation of the OutputWriter. This implementation uses POST /v1/metrics HTTP API. Settings:
  • "url": Stackdriver server URL. Optional, default value: "https://custom-gateway.stackdriver.com/v1/custom".
  • "token": Stackdriver API token. Mandatory
  • "source": Instance of the machine ID that the JMX data is being collected from. Optional.
  • "detectInstance": Set to "AWS" if you want to detect the local AWS instance ID on startup. Optional.
  • "stackdriverApiTimeoutInMillis": read timeout of the calls to Stackdriver HTTP API. Optional, default value: 1000.
  • "enabled": flag to enable/disable the writer. Optional, default value: {$code true}.
Author:
Eric Kilby
  • Field Details

  • Constructor Details

    • StackdriverWriter

      public StackdriverWriter()
  • Method Details

    • start

      public void start()
      Initial setup for the writer class. Loads in settings and initializes one-time setup variables like instanceId.
      Specified by:
      start in interface OutputWriter
      Overrides:
      start in class AbstractOutputWriter
    • write

      public void write​(Iterable<QueryResult> results)
      Send given metrics to the Stackdriver server using HTTP
      Specified by:
      write in interface OutputWriter
      Specified by:
      write in class AbstractOutputWriter
      Parameters:
      results - Iterable collection of data points
    • serialize

      public void serialize​(@Nonnull Iterable<QueryResult> results, @Nonnull OutputStream out) throws IOException
      Put the values into the JSON format expected by the Stackdriver custom metrics gateway
      Parameters:
      results - Iterable collection of data points (gauges and counters)
      out - OutputStream to write JSON to
      Throws:
      IOException
    • getExceptionCounter

      public int getExceptionCounter()