Java Application REST Integration

Integrating a Java application with a monitoring system like Bronshae provides a better understanding of application usage.  The Bronshae REST API can be used to integrate custom application data like number of transactions, memory usage, or any other relevant information for collection and monitoring.

Sending the Data

Clients send their data to Bronshae in either a JSON or plain text format by using an HTTP put. The plain text format is represented by attribute name pairs with the hostname as the first component. The following example is a plain text representation of myhost data."24""23982""1131""dev"

The curl command can be used for sending the data to a running Bronshae instance. Once the curl command puts the data, the Bronshae process determines which host is running the Correlation service and then stores the information. The advantage is that multiple Correlation services can be running in a deployed environment for redundancy.

% curl --request PUT --basic -u admin:admin -H "Content-Type:text/plain" \
--data  '"24""23982" \"1131""dev"' \

The next example uses JSON in a file called example.json. It works the same as the plain text example, but the content-type is application/json.

    "api-version": "1.0",
    "attribute-set": {
        "": 24,
        "": 23982,
        "": 1131
        "": "dev"
% curl --request PUT --basic -u admin:admin -H "Content-Type:application/json" \
-d @example.json http://localhost:9100/api/status/hosts 

Java REST Example

The next example uses a Java client called Resty. Resty is a project on GitHub that provides a way to interact with a REST api. The parameters are the same as the curl examples above, but this time a JSONObject holds the information. The code for the RestClient can be downloaded from here.

    Resty r = new Resty();
r.authenticate(site, username, password.toCharArray());

// HTTP Put the data and then print out the response
JSONResource response = r.json(site, put(content(jsonObj)));
System.out.println("Response: " + response.toObject().toString(4));

The line r.json(site, put(content(jsonObj))) will create the JSON content, execute an HTTP PUT, and then return the response as a JSONResource. Note that the RestyClient statically imports the Resty static methods which allows calls to content() and put() without the class name.

% java -cp resty-0.3.2.jar:. RestyClient

Sending: {
    "api-version": "1.0",
    "attribute-set": {
        "": 23982,
        "": "dev",
        "": 1131,
        "": 24
Response: {"api-status": 0}

By integrating data from an application, companies can better track application performance and trends based upon demand. Since Bronshae uses a REST api, data from Java applications or any other appliation that supports REST calls are supported.