The complete MoSKito integration guide – Step 5 – MoSKito-Central in remote mode

In the previous step we integrated MoSKito-Central in embedded mode, today is exactly the promised fine day to integrate MoSKito-Central in remote (standalone) mode.

You may ask “Why do we need it?”,  the answer is: our burgershop has become a real empire with multiple application instances and we want to monitor all of them and consolidate the obtained performance data in one place.

So, let’s start!

First, we synchronise our start point, which is the code from step 4. As before, we can get it using the following commands:

git clone https://github.com/dvayanu/burgershop
cd burgershop
git checkout moskito-integration-guide-step4

I. Adding dependencies

 <dependency>
    <groupId>org.moskito</groupId>
    <artifactId>moskito-central-rest-connector</artifactId>
    <version>${moskito-central.version}</version>
 </dependency>

We’re just adding a dependency for the remote connector, removing moskito-central-storages and moskito-central-embedded-connector, since we don’t need them anymore.

II. Adding configurations

Now we ask our MoSKitorized app to use the remote connector and tell the app where to connect it.

In moskito.json, write RESTRemoteConnector instead of EmbeddedCentralConnector.
moskito.json

{
    "@pluginsConfig": {
        "@plugins": [
            {
                "name": "RESTRemoteCentralConnector",
                "configurationName": "rest-connector",
                "className": "org.moskito.central.connectors.rest.RESTConnector"
            }
        ]
    }

}

Now add config for rest-connector:
rest-connector.json

{
	host: "localhost",
	port: 8080,
	resourcePath: "/moskito-central/central/addSnapshot"
}

This config says where to connect.

We also remove moskito-centralmoskito-csv and moskito-fs configs from the shop and will configure them in the section below.

III. Configure standalone MoSKito-Central web app
To configure our remote web app, it would be nice to get it before 🙂

Download the latest version of moskito-central-rest-webapp  from Maven: http://search.maven.org/#search%7Cga%7C1%7Cmoskito-central, unpack, make changes to configs, and pack again.

Or, get the project from github:

git clone https://github.com/anotheria/moskito-central
cd moskito-central/moskito-central-server/moskito-central-rest-webapp/

Configure storages in the same way as in embedded mode.
moskito-central.json

{
    "@storages": [
        {
            "name": "json-file",
            "clazz": "org.moskito.central.storage.fs.FileSystemStorage",
            "configName": "moskito-fs"
        },
        {
            "name": "csv-file",
            "clazz": "org.moskito.central.storage.fs.CSVFileStorage",
            "configName": "moskito-csv"
        }
    ]
}

moskito-fs.json

{
    "pattern": "/tmp/moskito-central/json/{host}/{component}/{producer}/{interval}/{date}/{date}_{time}_{producer}.json",
    "serializer": "org.moskito.central.storage.serializer.GsonSerializer",
    "includeIntervals": "*",
    "excludeIntervals": "15m",
    "includeProducers": "*",
    "excludeProducers": ""
}

moskito-csv.json

{
    "pattern": "/tmp/moskito-central/csv/{host}/{component}/{producer}/{interval}/{producer}_{stat}.csv",
    "@entries": [
        {
            "includedProducers": "SessionCount",
            "includedStats": "*",
            "includedIntervals": "*"
        },
        {
            "includedProducers": "RequestURIFilter",
            "includedStats": "cumulated",
            "includedIntervals": "5m,1h"
        },
        {
            "includedProducers": "sales",
            "includedStats": "*",
            "includedIntervals": "1m,1h"
        }
    ]
}

IV. Run folks run!
Rebuild the shop and moskito-central-rest-webapp (if you have downloaded the source code) and deploy both applications.

Again, order your favourite burger if you have one, or just trust our choice 😉

http://localhost:8080/burgershop/order.html?choice1=brioche&choice2=dog&choice3=cockroach
http://localhost:8080/burgershop/order.html?choice1=brioche&choice2=lamb&choice3=cockroach

In a moment, you’ll find new directories and data files in your local /tmp/moskito-central folder.
remote_mode_files

Voila … done!

A couple of notices to finish it all:

That’s is all for today, to sum it up: we have successfully integrated  MoSKito-Central in the remote mode and, as usual, today’s code is marked as moskito-integration-guide-step5

git clone https://github.com/dvayanu/burgershop
cd burgershop
git checkout moskito-integration-guide-step5

Enjoy, and see you!

3 thoughts on “The complete MoSKito integration guide – Step 5 – MoSKito-Central in remote mode

  1. Hi,

    is there an easy way to introgate moskito in a not Java Web App? I was try to monitor some JMS based apps, which do not run in a container. Form what I understood normally the container takes care of setting up the connectors (RMI, HTTP). Is there I way to do this manually?

    Thx,

    Klaus

  2. Hello,

    is it somehow possible to view via moskito inspector files stored by moskito center. Or is there any other UI for view this stats (csv, json, DB)?

    Thanks & Regards
    Marek

Leave a Reply

Your email address will not be published. Required fields are marked *

*