The complete MoSKito integration guide – Step 6 – Watching the big app with MoSKito-Control


Aleksey Khilkevich - February 4, 2014 - 4 comments

In all previous steps, we integrated MoSKito into our application and set up data storage. In simple words, we learned how to monitor our app’s performance and store the obtained MoSKito data for later analysis. What’s next?

Here’s the good news: our burgershop is now the world’s leading burger-seller, with million revenues. It has become a big distributed app, with multiple instances and servers.
The bad news: even the smallest fail might lead to a thousand-euro loss per minute.

The question: how to keep trace of hundreds of producers on a dozen of instances? It’s the moment to call Superman another hero!

So, today we’re setting up MoSKito-Control, a tool for monitoring multi-node web applications.

moskito_control

In earthly terms, MoSKito-Control is an application (with web and mobile interfaces) that gets connected to multiple standalone MoSKito instances and creates an overview display of the whole application and its health. This is a kind of application you want to run on a TV in your CommandCenter.

MoSKito-Control consists of two parts:
– the agent, which is installed into the target (monitored) application,
– the MoSKito-Control WebApp.

We will:

  • Install the Agent
  • Set up the WebApp.

I. Installing the Agent

We need to enable the http agent in the burgershop. Simply add the following dependency to the pom.xml:

<dependency>
    <groupId>org.moskito</groupId>
    <artifactId>moskito-control-agent-http-endpoint</artifactId>
    <version>1.2.2</version>
</dependency>

Our web container supports servlet 3.0 (Tomcat 7), so it’s all what we need. If you use an older container, add the filter to your web.xml:

<filter>
    <filter-name>ControlEndpoint</filter-name>
    <filter-class>org.moskito.controlagent.endpoints.http.HttpEndpoint</filter-class>
</filter>

<filter-mapping>
    <filter-name>ControlEndpoint</filter-name>
    <url-pattern>/moskito-control-agent/*</url-pattern>
</filter-mapping>

The first part is done.

II. Setting up MoSKito-Control application

Download latest version from https://www.moskito.org/download.html and
unpack to a folder. Let`s call this folder $MOSKITO_HOME.

Now we need to apply changes to configuration file. Go to $MOSKITO_HOME/moskito-control/moskito-control-configuration folder, find moskitocontrol.json and edit it.
You can find example configuration in a folder called “example-configurations” or paste next:

{
    "mailNotificationEnabled":false,
    "notificationsMutingTime":60,
    "defaultApplication":"Burgershop",
    "@applications":[
        {
            "name":"Burgershop",
            "@components":[
                {
                    "name":"ComponentName",
                    "category":"CategoryName",
                    "connectorType":"HTTP",
                    "location":"localhost:8080/burgershop/"
                }
            ],
            "@charts":[
                {
                    "name":"Sessions",
                    "limit":100,
                    "@lines":[
                        {
                            "component":"ComponentName",
                            "accumulator":"SessionCount Cur Absolute"
                        }
                    ]
                }
            ]
        }
    ],
    "@connectors":[
        {
            "type":"HTTP",
            "className":"org.moskito.control.connectors.HttpConnector"
        },
        {
            "type":"RMI",
            "className":"org.moskito.control.connectors.RMIConnector"
        }
    ],
    "@statusUpdater":{
        "checkPeriodInSeconds":10,
        "threadPoolSize":10,
        "timeoutInSeconds":60,
        "enabled":true
    },
    "@chartsUpdater":{
        "checkPeriodInSeconds":40,
        "threadPoolSize":5,
        "timeoutInSeconds":60,
        "enabled":true
    }
}

For more config info, browse MoSKito-Control docs.

III. Run’em All!

Now we have installed the http agent on the burgershop and have configured MoSKito-Control app. Go ahead and start them.

Build burgershop app and deploy to tomcat.

Then, start MoSKito-Control app. To do this we need to execute start-moskito-control.sh
*In case both projects burgershop and moskito-control on the same machine as in guide, be sure you made right configuration for both tomcat servers.

We should open our moskito-control UI in browser. Follow next link http://localhost:8999/control/main and if everything is ok you will see something like:

Moskito control

*If you see red circle to the left of ComponentName it means something is wrong and moskito-control can not connect to your app. Try to check your moskitocontrol.json and application you try to connect to.

And… that’s all!

Now you see the health of all your app’s instances in one place! More info is in MoSKito-Control Server (WebApp) User Manual.

To include another application, just add the agent into it and configure the moskitocontrol.json. It will then appear on the monitoring screen.

That’s it for today, and may your apps never crash!

4 comments

  1. Amit Kumar Rai

    I followed the same procedure but getting following error during deployment of moskito-control:
    243 2014-04-04 15:24:03,286 [main] INFO o.moskito.control.StartListener:32 – S
    tarting up MoSKito Control…
    276 2014-04-04 15:24:03,319 [main] ERROR o.c.ConfigurationManager:638 – getConf
    iguration(moskitocontrol, global)
    org.configureme.parser.ConfigurationParserException: JSON Error
    at org.configureme.parser.json.JsonParser.parseConfiguration(JsonParser.
    java:104) ~[configureme-2.3.0.jar:2.3.0]
    at org.configureme.ConfigurationManager.getConfiguration(ConfigurationMa
    nager.java:636) [configureme-2.3.0.jar:2.3.0]
    at org.configureme.ConfigurationManager.configure(ConfigurationManager.j
    ava:425) [configureme-2.3.0.jar:2.3.0]
    at org.configureme.ConfigurationManager.configureInitially(Configuration
    Manager.java:365) [configureme-2.3.0.jar:2.3.0]
    at org.configureme.ConfigurationManager.configureAs(ConfigurationManager
    .java:319) [configureme-2.3.0.jar:2.3.0]
    at org.configureme.ConfigurationManager.configureAs(ConfigurationManager
    .java:303) [configureme-2.3.0.jar:2.3.0]
    at org.configureme.ConfigurationManager.configure(ConfigurationManager.j
    ava:352) [configureme-2.3.0.jar:2.3.0]
    at org.configureme.ConfigurationManager.configure(ConfigurationManager.j
    ava:329) [configureme-2.3.0.jar:2.3.0]
    at org.configureme.ConfigurationManager.configure(ConfigurationManager.j
    ava:186) [configureme-2.3.0.jar:2.3.0]
    at org.moskito.control.config.MoskitoControlConfiguration$MoskitoControl
    ConfigurationHolder.(MoskitoControlConfiguration.java:178) ~[MoskitoCont
    rolConfiguration$MoskitoControlConfigurationHolder.class:na]
    at org.moskito.control.config.MoskitoControlConfiguration.getConfigurati
    on(MoskitoControlConfiguration.java:84) ~[MoskitoControlConfiguration.class:na]
    at org.moskito.control.StartListener.contextInitialized(StartListener.ja
    va:35) ~[StartListener.class:na]
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
    t.java:4210) ~[catalina.jar:6.0.39]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
    709) ~[catalina.jar:6.0.39]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
    .java:799) ~[catalina.jar:6.0.39]
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77
    9) ~[catalina.jar:6.0.39]
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583)
    ~[catalina.jar:6.0.39]
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
    a:1079) ~[catalina.jar:6.0.39]
    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
    ava:1002) ~[catalina.jar:6.0.39]
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506
    ) ~[catalina.jar:6.0.39]
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317) ~[
    catalina.jar:6.0.39]
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
    :324) ~[catalina.jar:6.0.39]
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
    eSupport.java:142) ~[catalina.jar:6.0.39]
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
    ~[catalina.jar:6.0.39]
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:822) ~[
    catalina.jar:6.0.39]
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    ~[catalina.jar:6.0.39]
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463
    ) ~[catalina.jar:6.0.39]
    at org.apache.catalina.core.StandardService.start(StandardService.java:5
    25) ~[catalina.jar:6.0.39]
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754
    ) ~[catalina.jar:6.0.39]
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595) ~[catal
    ina.jar:6.0.39]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.
    0_25]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:57) ~[na:1.7.0_25]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:43) ~[na:1.7.0_25]

    • Amit Kumar Rai

      My moskitocontrol.json looks like following:
      {
      “defaultApplication” : “Burgershop”,
      “@applications”: [
      {
      “name”: “Burgershop”,
      “@components”: [
      {
      “name”: “My Tomcat Instance 02”,
      “category”: “web”,
      “connectorType”: “HTTP”,
      “location”: “localhost:8081/burgershop”
      }
      ]
      }
      ],

      “@connectors”: [
      {
      “type”: “HTTP”,
      “className”: “org.moskito.control.connectors.HttpConnector”
      }
      ],

      “@statusUpdater”: {
      “checkPeriodInSeconds”: 10,
      “threadPoolSize”: 10,
      “timeoutInSeconds”: 60,
      “enabled”: true
      },

      “@chartsUpdater”: {
      “checkPeriodInSeconds”: 40,
      “threadPoolSize”: 5,
      “timeoutInSeconds”: 60,
      “enabled”: true
      }

      }

    • Hello Amit,
      did you have another exception as cause for this exception. When in doubt, feel free to open a ticket at https://jira.opensource.anotheria.net

  2. In the minimal example it should be stated, that you also need the following components by default in the moskitocontrol.json

    “@connectors”: [
    {
    “type”: “HTTP”,
    “className”: “org.moskito.control.connectors.HttpConnector”
    }
    ],
    “@statusUpdater”: {
    “checkPeriodInSeconds”: 10,
    “threadPoolSize”: 10,
    “timeoutInSeconds”: 60,
    “enabled”: true
    },
    “@chartsUpdater”: {
    “checkPeriodInSeconds”: 40,
    “threadPoolSize”: 5,
    “timeoutInSeconds”: 60,
    “enabled”: true
    }

Post a Comment

Your email address will not be published.