[chef] Re: Re: Re: Re: Issue with datadog mysql


Chronological Thread 
  • From: koteswara rao Sakhamuri < >
  • To:
  • Subject: [chef] Re: Re: Re: Re: Issue with datadog mysql
  • Date: Fri, 21 Nov 2014 10:31:50 +0530

Thanks a lot Jose Luis Ferrer, This helped me a lot. 

Regards,
Sakhamuri.

On Thu, Nov 20, 2014 at 5:49 PM, Jose Luis Ferrer < " target="_blank"> > wrote:

Hi, 

Not all the fields are mandatory, only 'server','user' and 'pass'; 'tags' and 'options' are useful for datadog dashboards.

datadog_monitor 'mysql' do
  instances [
   {
     'server' => "localhost",
     'user' => "root",
     'pass' => "mysql",
     'sock' => "/var/lib/mysql/mysql.sock"     
   }
 ]
end

However, this is not the best way to deal with chef node attributes. Check [1] for chef-client run phases and [2] for node attributes. Node attributes are computed at compile-time, using attribute files from recipes, roles, environment definitions, etc.

You should define your default datadog instances value in an attributes file of your cookbook that acts as a wrapper for the datadog cookbook.

Sample of content for keas-datadog/attributes/datadog.rb :

default['datadog']['mysql']['instances'] =    [{
     'server' => "localhost",
     'user' => "root",
     'pass' => "mysql",
     'sock' => "/var/lib/mysql/mysql.sock"     
   }
]


And including datadog::mysql recipe will do the rest, as the node has the attribute datadog.mysql.instances

Sample of content for keas-datadog/recipes/mysql.rb :

include_recipe "datadog::mysql"


Regards,

JL


On Thu, Nov 20, 2014 at 12:07 PM, koteswara rao Sakhamuri < " target="_blank"> > wrote:
Hi Jose Luis Ferrer,

I have made some changes in the mysql.rb file by declaring username, password etc. I'm confused with tag field, Do i have to include node name in the tags or the Hostname? 


datadog_monitor 'mysql' do
  instances node['datadog']['mysql']['instances'] = [
   {
     'server' => "localhost",
     'user' => "root",
     'pass' => "mysql",
     'sock' => "/var/lib/mysql/mysql.sock",
     'tags' => [],
     'options' => [
       "replication: 0",
       "galera_cluster: 1"
     ]
   },
 ]
end

On Thu, Nov 20, 2014 at 4:25 PM, Jose Luis Ferrer < " target="_blank"> > wrote:
Hello,

It seems that your node['datadog']['mysql']['instances'] attribute is empty, you have to declare it somewhere (role, or your wrapper cookbook), see https://github.com/DataDog/chef-datadog/blob/master/recipes/mysql.rb#L5 for the connection parameters you have to include.

e.g. declaring the instance in your wrapper recipe :

```
node.default['datadog']['mysql']['instances']= [
 {
   ##your instances object here ##
 }
]

include_recipe "datadog::mysql"
```

Regards,

JL


On Thu, Nov 20, 2014 at 11:30 AM, koteswara rao Sakhamuri < " target="_blank"> > wrote:
Hi Chefs,
I'm facing issue with mysql in datadog. Please help me to find out the solution. Am i doing anything wrong? od do i have to include the information of DB like database credentials etc.

========================================================
192.168.204.75
192.168.204.75 NoMethodError
192.168.204.75 -------------
192.168.204.75 undefined method `[]' for nil:NilClass
192.168.204.75
192.168.204.75 Cookbook Trace:
192.168.204.75 ---------------
192.168.204.75   /var/chef/cache/cookbooks/datadog/recipes/mysql.rb:24:in `block in from_file'
192.168.204.75   /var/chef/cache/cookbooks/datadog/recipes/mysql.rb:23:in `from_file'
192.168.204.75   /var/chef/cache/cookbooks/keas-datadog/recipes/mysql.rb:3:in `from_file'
192.168.204.75   /var/chef/cache/cookbooks/keas-percona/recipes/default.rb:19:in `from_file'
192.168.204.75
192.168.204.75 Relevant File Content:
192.168.204.75 ----------------------
192.168.204.75 /var/chef/cache/cookbooks/datadog/recipes/mysql.rb:
192.168.204.75
192.168.204.75  17:  #       "replication: 0",
192.168.204.75  18:  #       "galera_cluster: 1"
192.168.204.75  19:  #     ]
192.168.204.75  20:  #   },
192.168.204.75  21:  # ]
192.168.204.75  22:
192.168.204.75  23:  datadog_monitor 'mysql' do
192.168.204.75  24>>   instances node['datadog']['mysql']['instances']
192.168.204.75  25:  end
192.168.204.75  26:
192.168.204.75  27:
192.168.204.75  28:
192.168.204.75
192.168.204.75
192.168.204.75 Running handlers:
192.168.204.75 [2014-11-20T15:50:04+05:30] ERROR: Running exception handlers
192.168.204.75 Running handlers complete
192.168.204.75 [2014-11-20T15:50:04+05:30] ERROR: Exception handlers complete
192.168.204.75 [2014-11-20T15:50:04+05:30] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
192.168.204.75 Chef Client failed. 0 resources updated in 2.890363666 seconds
192.168.204.75 [2014-11-20T15:50:04+05:30] ERROR: undefined method `[]' for nil:NilClass
192.168.204.75 [2014-11-20T15:50:04+05:30] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsucce
sfully (exit code 1)


Regards,
Sakhamuri.







Archive powered by MHonArc 2.6.16.

§