We are trying to integrate DataDog with our Ruby On Rails app. Our ROR app will continuously add users, update users and delete users every second.
I have integrated Datadog to monitor the no. of users added, updated and deleted through the graph provided by Datadog.
I installed the datadog agent using the command for Ubuntu Aws instance.
I got a free trial for 14 days.
I followed this document for dogstatd-ruby gem : https://github.com/DataDog/dogstatsd-ruby
After that i wrote the code in my ruby project like below :
require 'statsd'
dogstatsd = Statsd.new('MY_API_KEY')
user_data = ExportUser.find_by_userID(user["userId"].to_s)
if user_data.nil?
dogstatsd.increment('custom.users.added') #increment dogstat if a user is added and below query is run
#new record, go ahead with insertion
user_new = ExportUser.new(user)
@status = user_new.save
else
dogstatsd.increment('custom.users.updated') #increment dogstat if a user is updated and below query is run
#existing record, go ahead with updation
@status = user_data.update_attributes(user)
end
Here i dont see "custom.users.updated" and "custom.users.added" graph in the metrics explorer.
I would really appreciate if any1 help me out to set the graph for these 2 metrics in Datadog account. please let me know if i missed anything here.
Just a few items to note to get this working:
dogstatsd = Statsd.new('MY_API_KEY')
This line of code is trying to use your API key to establish a statsD connection, but this should actually be trying to establish the statsD connection via the statsD port currently configured on your Agent as seen here:
Create a stats instance.
statsd = Statsd.new('localhost', 8125)
The easiest way to get your custom metrics into Datadog is to send them to DogStatsD, a metrics aggregation server bundled with the Datadog Agent (in versions 3.0 and above). DogStatsD implements the StatsD protocol, along with a few extensions for special Datadog features.
http://docs.datadoghq.com/guides/dogstatsd/
If you would not like to deploy an Agent on the host running the RoR application, you can utilize DogAPI gem:
https://github.com/DataDog/dogapi-rb
Which has additional documentation to get this custom metrics submitted:
require 'rubygems'
require 'dogapi'
api_key = "abcdef123456"
dog = Dogapi::Client.new(api_key)
dog.emit_point('some.metric.name', 50.0, :host => "my_host", :device => "my_device")
If you have additional questions, please reach out to [email protected]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With