Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Attempting to set app name via fastcgi_param. Not working


#1

I’m using the information you have in your documentation to try to set a unique appname via the fastcgi_param config item available in Nginx/PHP-FPM.

I have a server config stanza of

fastcgi_param PHP_VALUE "newrelic.appname=example.com;All Virtual Hosts";

Followed by a location stanza of

location ~ \.php$ {
  try_files $uri /index.php =404; 

  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

  fastcgi_keep_conn on;
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  include fastcgi_params;
}

But this value is not being set. In a simple script page in that vhost where I output the newrelic.appname variable all I see is the default value as set in the newrelic.ini. In this case All Virtual Hosts. No amount of re-ordering appears to have changed the way this is working.

I am loathed to use the PHP route of adding code as I run a number of third party applications that I don’t want to have to check for code changes everytime I update.

Has anyone had any luck with this?


#2

@mr_wonka multi-valued appnames can be tricky when configuring in Nginx because the semi-colon acts as a delimiter inside the value. So, instead of your current PHP_VALUE param, configure the line like so in your Nginx configuration:

 fastcgi_param PHP_VALUE 'newrelic.appname="example.com;All Virtual Hosts"';

The change is to have the two appnames wrapped in double-quotes and the full Nginx value wrapped in single quotes. The PHP daemon can be stopped (with /etc/init.d/newrelic-daemon stop) and the running web server (Nginx & PHP-FPM) subsequently restarted to pick up the change.


#3

Mmm, Interesting. I did this and it appears not to have done anything useful. It’s done something though.

Before, although I was getting no data logged to the applications within the new relic interface I was at least seeing the applications. After implementing the changes you mention above I now have those applications listed as “No data reporting for this application” and presumably they will disappear soon.


#4

To clarify @mr_wonka, you’re seeing “example.com” as a non-reporting application? Does “All Virtual Hosts” report correctly in the dashboard?


#5

@QuietWyatt Yes. Correct. “example.com” shows as “No data reporting for this application”. I do see “All Virtual Hosts” and “PHP Application” and these appear to have correct data.


#6

Oops. Tell a lie. “PHP Application” shows no data at all but claims to be working. i.e. has a green bar on the left.


#7

@mr_wonka, you mention you set the PHP_VALUE in the server stanza.

I don’t think the issue has to do with quoting and I would continue to use your original line of:

 fastcgi_param PHP_VALUE "newrelic.appname=example.com;All Virtual Hosts";

But this cannot be in the server stanza and should instead appear in the location stanza of the nginx config.

For example, please see the following entry on the Nginx wiki:

http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_param

Quoting:

Sets a parameter that should be passed to the FastCGI server. The value can contain text, variables, and their combination. These directives are inherited from the previous level if and only if there are no fastcgi_param directives defined on the current level.

Note the highlighted third sentence. Because you have fastcgi_param directives in your location stanza, you are NOT inheriting any fastcgi_param settings from the previous level.

Would you please try putting the fastcgi_param PHP_VALUE line inside the location stanza and let us know if that resolves the issue?


#8

Hello Ilawson,

I’ve tried to setup multiple appname using fastcgi_param and there is clearly a bug…
If I use the recommended configuration that doesnt work

fastcgi_param PHP_VALUE “newrelic.appname=example.com;All Virtual Hosts”;

The data are only sent to “example.com” but “All Virtual Hosts” is empty (no data)…
If I use the workaround provided by @dulan (cf. above in this thread), that works perfectly, both “example.com” and “All Virtual Hosts” are updated correctly.

fastcgi_param PHP_VALUE ‘newrelic.appname=“example.com;All Virtual Hosts”’;

I think that might worth it to update your documentation about that…

Regards,
Vincent


#9

@vincent.deygas

Nginx is a quirky beast

fastcgi_param PHP_VALUE "newrelic.appname=\"example.com;All Virtual Hosts\"";

Try this. You escape the quotations so that the ; doesn’t get treated like an end of line.


#10

This approach might work as well but the second example in my post works perfectly and doesnt need escaped quotes :slight_smile:


#11

It looks like this simply doesn’t work!

I have tried
fastcgi_param PHP_VALUE “newrelic.appname=example.com;”;
fastcgi_param PHP_VALUE “newrelic.appname=example.com”;

makes no difference