Community Articles
Find and share helpful community-sourced technical articles
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.
Labels (1)
Super Guru

Phone Tracking with OwnTracks and Apache NiFi 1.x

OwnTracks is an Open Source project which provides an iOS and an Android app with which your smartphone records its current location.

I installed the OwnTracks application for iOS and it let's you specify your own REST JSON server to receive calls. I added Apache NiFi. It can also send via MQTT direct to mosquittio on prem to NIFI or to CloudMQTT. You just need to enter your Apache NiFi address and port.

13774-phoneflow.png

Tell NiFi to listen for HTTP on port 9179 for the phone push, allow it to use GET, POST and PUT. No coding required.

13777-phonehandlehttprequest.png

Respond to the phone with HTTP Status Code 200 and use the context map to connect the HTTP flow.

13778-phonehandlehttpresponse.png

We pull out the attributes from the JSON Flow File.

13779-phoneattributes.png

Store our Phone Data in Apache Phoenix on HBase

upsert into phone  (uuid,battery,longitude ,accelerator ,velocity,vac ,latitude , tvalue ,connection , tst , altitude , messagetype , tid, httpremotehost, useragent, filename, datetime)
values ('${'uuid'}','${'battery'}','${'longitude'}','${'accelerator'}','${'velocity'}',
'${'vac'}','${'latitude'}',
'${'tvalue'}','${'connection'}','${'tst'}','${'altitude'}','${'messagetype'}','${'tid'}',
'${'http.remote.host'}','${'http.headers.User-Agent'}','${'filename'}','${now()}')

Results in Zeppelin

13773-phonezeppelin.png

Reference


phonereplacetext.pngphonepushdataflow.pngphonetracking.png
1,605 Views
Don't have an account?
Coming from Hortonworks? Activate your account here
Version history
Revision #:
2 of 2
Last update:
‎08-17-2019 01:44 PM
Updated by:
 
Contributors
Top Kudoed Authors