CLOUD

Mobile Analytics with Storm (Part 2)

In the previous article “Mobile Analytics with Storm“, we discussed how to configure the logging library for mobile apps to send stacktrace messages to Storm via REST API. To make this logging library more usable and robust, mobile app developers are now able to send invaluable stacktrace messages via TCP (through the Network Inputs option). The configuration steps are incredibly simple and are summarized using the diagram shown below:

  1. Click at “Network data” to enable Storm to receive data via TCP
  2. Click at “Authorize your IP address” so that Storm is receiving data from authorized IP address(es). Please take note of the “IP/Port combination” in “Send data to” – we are going to use that combination to send data to Storm.
  3. Choose “Manually authorize IP address
  4. Click at “What is my IP?” to obtain an authorized IP address and then set the custom sourcetype to “app_message

The steps to configure the logging library in your IDE is as follow (if you have not done so already):

  1. Download the logging library either from SplunkBase (http://splunk-base.splunk.com/apps/78613/mobile-analytics-with-splunk-storm-android) or from github (https://github.com/nicholaskeytholeong/splunk-storm-mobile-analytics/blob/master/android/splunkstormmobileanalytics.jar)
  2. Include splunkstormmobileanalytics.jar into your project. This is how you can simply do it: move the jar file into libs directory of your app project
  3. libraryineclipse

  4. Allow the Internet permission between the <manifest> tags in the AndroidManifest.xml
  5. <uses-permission android:name="android.permission.INTERNET"/>
  6. Add the import statement into the main activity of your app
  7. import com.storm.android.Storm;
  8. Connect to Splunk Storm in the onCreate() method of the main activity
  9. protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Storm.TCPconnect(RECEIVING_IP, RECEIVING_PORT_NUMBER, getApplicationContext());
        /**
         * an example would be Storm.TCPconnect("logs1.nkey.splunkstorm.com", 20072, getApplicationContext());
         * your other wonderful codes to develop your wonderful mobile app
        **/
    }
  10. You are now able to send data via TCP from your Android mobile app to SplunkStorm

To conclude, this is how we send data with the logging library for Android apps via TCP into Splunk Storm:

  1. Create a Splunk Storm project at https://www.splunkstorm.com
  2. Download the jar file either from SplunkBase (http://splunk-base.splunk.com/apps/78613/mobile-analytics-with-splunk-storm-android) or from github (https://github.com/nicholaskeytholeong/splunk-storm-mobile-analytics/blob/master/android/splunkstormmobileanalytics.jar)
  3. Configure Network Input from Splunk Storm UI accordingly (discussed earlier in this article)

Give it a try and tell us your experience integrating it into your mobile apps. Feedback and suggestions are always welcomed!

“Enterprise, Developer, Cloud, Content”

----------------------------------------------------
Thanks!
Nicholas Key

Splunk
Posted by

Splunk

Join the Discussion