Package org.jmxtrans.embedded.output
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 Summary
Fields Modifier and Type Field Description static intDEFAULT_STACKDRIVER_API_TIMEOUT_IN_MILLISstatic StringDEFAULT_STACKDRIVER_API_URLstatic StringSETTING_DETECT_INSTANCEstatic StringSETTING_SOURCE_INSTANCEstatic StringSETTING_STACKDRIVER_API_TIMEOUT_IN_MILLISstatic intSTACKDRIVER_PROTOCOL_VERSIONFields inherited from class org.jmxtrans.embedded.output.AbstractOutputWriter
SETTING_HOST, SETTING_NAME_PREFIX, SETTING_PORT, SETTING_PROTOCOL, SETTING_PROXY_HOST, SETTING_PROXY_PORT, SETTING_SOCKET_FACTORY, SETTING_TLS_INSECURE, SETTING_TLS_KEY_STORE, SETTING_TLS_KEY_STORE_PASSWORD, SETTING_TLS_TRUST_STORE, SETTING_TLS_TRUST_STORE_PASSWORD, SETTING_TOKEN, SETTING_URL, SETTING_USE_TLS, SETTING_USERNAME -
Constructor Summary
Constructors Constructor Description StackdriverWriter() -
Method Summary
Modifier and Type Method Description intgetExceptionCounter()voidserialize(Iterable<QueryResult> results, OutputStream out)Put the values into the JSON format expected by the Stackdriver custom metrics gatewayvoidstart()Initial setup for the writer class.voidwrite(Iterable<QueryResult> results)Send given metrics to the Stackdriver server using HTTPMethods inherited from class org.jmxtrans.embedded.output.AbstractOutputWriter
equals, getBooleanSetting, getIntSetting, getIntSetting, getLongSetting, getSettings, getStrategy, getStringSetting, getStringSetting, hashCode, isEnabled, setEnabled, setSettings, setStrategy, stop, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jmxtrans.embedded.output.OutputWriter
getSettings, isEnabled, setEnabled, setSettings, stop
-
Field Details
-
STACKDRIVER_PROTOCOL_VERSION
public static final int STACKDRIVER_PROTOCOL_VERSION- See Also:
- Constant Field Values
-
SETTING_SOURCE_INSTANCE
- See Also:
- Constant Field Values
-
SETTING_DETECT_INSTANCE
- See Also:
- Constant Field Values
-
DEFAULT_STACKDRIVER_API_URL
- See Also:
- Constant Field Values
-
SETTING_STACKDRIVER_API_TIMEOUT_IN_MILLIS
- See Also:
- Constant Field Values
-
DEFAULT_STACKDRIVER_API_TIMEOUT_IN_MILLIS
public static final int DEFAULT_STACKDRIVER_API_TIMEOUT_IN_MILLIS- See Also:
- Constant Field Values
-
-
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:
startin interfaceOutputWriter- Overrides:
startin classAbstractOutputWriter
-
write
Send given metrics to the Stackdriver server using HTTP- Specified by:
writein interfaceOutputWriter- Specified by:
writein classAbstractOutputWriter- Parameters:
results- Iterable collection of data points
-
serialize
public void serialize(@Nonnull Iterable<QueryResult> results, @Nonnull OutputStream out) throws IOExceptionPut 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()
-