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

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.

First of all, make sure you have the burgershop project locally in a proper state (for example, step 3), or do the old-good git checkout:

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

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.1.0</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

There are two ways to get the app:

We recommend the second variant.

Now, configs: moskitocontrol.json, located in etc/appdata in repository, is the file which contains configuration data for your applications.

We’ll need the applications block. Let’s add burgershop (with its SessionCount chart) into the app list, and set it as default app:

"defaultApplication" : "Burgershop",
"@applications": [
        {
            "name": "Burgershop",
            "@components": [
                {
                    "name": "burgershop",
                    "category": "web",
                    "connectorType": "HTTP",
                    "location": "localhost:8080/burgershop"
                }
            ],
            "@charts": [
                {
                    "name": "SessionCount",
                    "limit": 100,
                    "@lines": [
                        {
                            "component": "burgershop",
                            "accumulator": "SessionCount Cur Absolute"
                        }
                    ]
                }
            ]
        }
    ]

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. Deploy MoSKito-Control app on another web container, and let’s run everything!

After deployment, follow the link:

http://localhost:8081/control/main

You’ll see a nice picture like that:

Moskito control

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 thoughts on “The complete MoSKito integration guide – Step 6 – Watching the big app with MoSKito-Control

  1. 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]

    • 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
      }

      }

  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
    }

Leave a Reply

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

*