DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

How To: Send SMS Messages to Logentries in Under 5 Minutes (Maybe 10)

The “Internet Of Things” continues to be talked about a lot with an increasing number of devices now containing some sort of smart functionality which can be interacted with.

Eoin Shanley user avatar by
Eoin Shanley
·
May. 04, 16 · Opinion
Like (2)
Save
Tweet
Share
3.16K Views

Join the DZone community and get the full member experience.

Join For Free

how-to-send-sms-logs-to-logentriesThe “Internet Of Things” continues to be talked about a lot with an increasing number of devices now containing some sort of smart functionality which can be interacted with. Here’s a great article about end-to-end IoT monitoring by colleague David Tracey.

However, not all IoT devices can be in locations with WiFi or 3/4G coverage, so they can not easily (or at all) send or receive data over the internet, and instead rely on standard cellular connectivity – or the devices may simply not need to send data frequently enough to need an internet connection. This is where the ability to send SMS messages to alert you of any issues can be useful.

Luckily, this can be done very easily using a service like Twilio, which provides a rich set of APIs that allow you to (among other things) send and receive text messages.

I wanted to try this out, and found that it was really quick to configure Twilio to receive SMS messages to a virtual number (availability does depend on your region), and then have any messages relayed on to Logentries.

So What Do You Need?

The first thing is the token for the Log file you want to write to (Don’t yet have a Logentries account? You can sign up for a free trial, it’s really quick).

Either create a new log using the “manual” option and take a note of the newly created token, or if you want to write to an existing log then browse to the Logset and click on the “token” link for the log. A modal will appear with the log token.

Sign up for your free Twilio trial. To receive SMS messages, you’ll need to add some funds to your account.

Browse to the “messaging / phone numbers” area. Select a phone number in the region you want – remember to ensure it has the “SMS” service available.

You’ll now be prompted to configure it. The bit we’re interested in is the Messaging section. Select “URL” and enter the following value into the Request URL:

https://js.logentries.com/v1/noformat/<Your Log Token>

Screen Shot 2016-04-14 at 18.40.55
 Make sure that HTTP POST is selected, and then press Save – and that’s pretty much all your configuration done.

Let’s send a message:

iPhoneMessage

And check the inbound messages in Twilio – the message has been received.

TwilioCP

And now let’s check my log in Logentries

LogentriesMessages

Note that it is not possible to format the request we get from Twilio – everything is URL encoded. This isn’t a big deal, as the message has Key Value Pairs that can be searched for in Logentries. If you want, you can write your own Twilio app that can accept the message, format it and then send it on to Logentries.

The messages look good – I can create an alert based on the message body, but there’s one small problem. The From number has the leading “+” encoded, which means that it can’t be searched for using a KVP search.

This is where Regular Expressions come in handy. The named capture group below allows me to group the incoming SMS messages by the number that sent them in.

where(/From=%2B(?P<FromNum>\d*)/) groupby(FromNum) sort(desc)

When I run this query, I get the number of SMS messages grouped by the number that sent them in – thereby identifying the devices that triggered the messages.

GroupbyResults

Hopefully, this simple demo shows that you don’t need to depend on all your devices having internet access in order to send log messages to Logentries.

SMS

Published at DZone with permission of Eoin Shanley. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • A Simple Union Between .NET Core and Python
  • Data Mesh vs. Data Fabric: A Tale of Two New Data Paradigms
  • The Top 3 Challenges Facing Engineering Leaders Today—And How to Overcome Them
  • How and Why You Should Start Automating DevOps

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: