djoos-cookbooks / newrelic

Development repository for the newrelic cookbook
https://supermarket.chef.io/cookbooks/newrelic
MIT License
143 stars 245 forks source link

newrelic-infra.yml - Unable to parse configuration file #341

Closed crLawther closed 6 years ago

crLawther commented 6 years ago

I am using the newrelic infrastructure LWRP and passing values from a json into the customer_attribute property.

newrelic_agent_infrastructure 'Install' do
  display_name         node['fqdn']
  proxy                      node['proxy']['http_proxy']
  custom_attributes   node['newrelic']['application_monitoring']
end

My Json for node['newrelic']['application_monitoring'] is as follows:

 "newrelic": {
     "log_level":   "info",
     "application_monitoring": {
       "app_name": "my-app-name"
     }

This populates newrelic-infra.yml with the following values:

license_key: xx123xx display_name: default-oel65-64.vagrantup.com verbose: 0 proxy: http://myproxy.com:80 custom_attributes: license: daemon: {"proxy"=>nil, "logfile"=>"/var/log/newrelic/newrelic-daemon.log", "loglevel"=>nil, "port"=>nil, "max_threads"=>nil, "ssl"=>nil, "ssl_ca_path"=>nil, "ssl_ca_bundle"=>nil, "pidfile"=>nil, "location"=>nil, "collector_host"=>nil, "dont_launch"=>nil, "proxy_host"=>"myproxy.com", "proxy_port"=>"80"} enabled: logfile: logfile_path: loglevel: app_name: my-app-name high_security: capture_params: cross_application_tracer: {"enable"=>nil} thread_profiler: {"enable"=>nil} labels: ignored_params: error_collector: {"enable"=>nil, "ignore_errors"=>nil, "ignore_classes"=>nil, "ignore_status_codes"=>nil, "record_database_errors"=>nil, "prioritize_api_errors"=>nil} browser_monitoring: {"auto_instrument"=>nil} transaction_tracer: {"enable"=>nil, "threshold"=>nil, "detail"=>nil, "slow_sql"=>nil, "stack_trace_threshold"=>nil, "explain_threshold"=>nil, "record_sql"=>nil, "custom"=>nil} framework: webtransaction: {"name"=>{"remove_trailing_path"=>nil, "functions"=>nil, "files"=>nil}}

The issue is that the additional these values being added to this template, such as {"enable"=>nil} are unable to be parsed by newrelic and the newrelic-infra process terminates.

Apr 4 14:27:54 oracle newrelic-infra: time="2018-04-04T14:27:54Z" level=fatal msg="can't load configuration file" error="Unable to parse configuration file : yaml: line 12: did not find expected ',' or '}'" Apr 4 14:27:54 oracle init: newrelic-infra main process (29142) terminated with status 1 Apr 4 14:27:54 oracle init: newrelic-infra respawning too fast, stopped

If I delete the lines with values surrounded by {} the file parses successfully leaving me to believe this to be the issue.

djoos commented 6 years ago

Hi @crLawther,

the custom_attributes attribute of the cookbook's New Relic infrastructure agent LWRP is expected to be a hash of custom attributes, rather than JSON objects. eg. {"customAttribute_1" => "SOME_ATTRIBUTE", "customAttribute_2" => "SOME_ATTRIBUTE_2"} It's iterated upon in the template to create the YAML for the newrelic infrastructure agent custom attributes configuration.

Please let me know how it goes!

Kind regards, David

djoos commented 6 years ago

Closing this one for now as per the custom_attributes info above - happy to discuss further here though if needed!