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:
- Click at “Network data” to enable Storm to receive data via TCP
- 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.
- Choose “Manually authorize IP address“
- 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):
- 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)
- 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
- Allow the Internet permission between the <manifest> tags in the AndroidManifest.xml
- Add the import statement into the main activity of your app
- Connect to Splunk Storm in the onCreate() method of the main activity
- You are now able to send data via TCP from your Android mobile app to SplunkStorm
<uses-permission android:name="android.permission.INTERNET"/>
import com.storm.android.Storm;
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 **/ }
To conclude, this is how we send data with the logging library for Android apps via TCP into Splunk Storm:
- Create a Splunk Storm project at https://www.splunkstorm.com
- 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)
- 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”