Over a million developers have joined DZone.
Platinum Partner

The Simplest Way To Collect Application Data On Heroku

· Cloud Zone

Learn about the benefits and drawbacks of microservices with best practices for your own architecture, brought to you in partnership with Iron.io.

Curator's Note: The content of this article was originally written by Masa over at the Treasure Data  blog.

At Treasure Data, we constantly try to simplify how our customers collect and interact with their data.

Over the past several months, we reached out to two dozens or so customers and listened to their feedback. One pattern emerged: they spend a lot of time on data collection and wanted something simpler.

So, we rolled up our sleeves and built a feature to simplify data collection even more: from now on, our Heroku customers can store data on Treasure Data by just printing to stdout in a specified format.

Treasure Data's Heroku Log Drain Integration

The format is very simple:

@[db_name.table_name] json_in_one_line

e.g., if you wanted to store the event { "first_name": "Bob", "last_name": "Smith" } into the table users in the database service, you just write

@[service.users] { "first_name": "Bob", "last_name": "Smith" }

into stdout. Hence, in Ruby,

puts '@[service.users] { "first_name": "Bob", "last_name": "Smith" }'

in Java,

System.out.println("@[service.users] { \"first_name\": \"Bob\", \"last_name\": \"Smith\" }")

in PHP,

echo '@[service.users] { "first_name": "Bob", "last_name": "Smith" }'.PHP_EOL;

in Node.js,

process.stdout.stream('@[service.users] { "first_name": "Bob", "last_name": "Smith" }')

and so on.

As you noticed, this new interface is language agnostic: all languages let you print out to stdout out of the box, and that’s all you need to get started with Treasure Data on Heroku now.

So, if you are a Heroku user, just run

$ heroku addons:add treasure-data:nano

and start collecting data today.


Masa, the engineer who built this new feature, likes to bike everywhere, rain or shine.

The Cloud Zone is brought to you in partnership with Iron.io.  Learn about best practices and common pitfalls for working with Iron.io. Avoid the dead ends, and take the enlightened path.


Published at DZone with permission of Sadayuki Furuhashi , DZone MVB .

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}