Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No graphite composer #1173

Closed
sglwlb opened this issue Feb 27, 2015 · 27 comments

Comments

Projects
None yet
@sglwlb
Copy link

commented Feb 27, 2015

I install the graphite-web and config it, after that, i access it from browser, there is no "graphite composer". I use develop tool to catch the problem, the errors are:
Uncaught ReferenceError: Ext is not defined
(index):91 Uncaught ReferenceError: Ext is not defined
(index):101 Uncaught ReferenceError: GraphiteBrowser is not defined
but, the Ext and GraphiteBroser are all there.

And, i found the response body length is zero, like follow:

Remote Address:[::1]:9999
Request URL:http://localhost:9999/content/js/ext/resources/css/ext-all.css
Request Method:GET
Status Code:200 OK (from cache)
Request Headers
Provisional headers are shown
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36
Response Headers
Access-Control-Allow-Headers:origin, authorization, accept
Access-Control-Allow-Methods:GET, OPTIONS
Access-Control-Allow-Origin:*
Connection:close
Content-Length:0
Content-Type:text/css
Date:Fri, 27 Feb 2015 02:03:20 GMT
Last-Modified:Wed, 21 Aug 2013 17:11:04 GMT
Server:Apache/2.2.15 (CentOS)
Vary:Accept-Encoding

Follow are the error message when i config the database, is it relate to this problem?
/etc/graphite-web/local_settings.py.back
/usr/lib/python2.6/site-packages/graphite/settings.py:231: UserWarning: SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security
warn('SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security')
/usr/lib/python2.6/site-packages/django/conf/init.py:75: DeprecationWarning: The ADMIN_MEDIA_PREFIX setting has been removed; use STATIC_URL instead.
"use STATIC_URL instead.", DeprecationWarning)
/usr/lib/python2.6/site-packages/django/core/cache/init.py:82: DeprecationWarning: settings.CACHE_* is deprecated; use settings.CACHES instead.
DeprecationWarning
Creating tables ...
Creating table account_profile
Creating table account_variable
Creating table account_view
Creating table account_window
Creating table account_mygraph
Creating table dashboard_dashboard_owners
Creating table dashboard_dashboard
Creating table events_event
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table django_session
Creating table django_admin_log
Creating table django_content_type
Creating table tagging_tag
Creating table tagging_taggeditem

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/graphite/manage.py", line 13, in
execute_from_command_line(sys.argv)
File "/usr/lib/python2.6/site-packages/django/core/management/init.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.6/site-packages/django/core/management/init.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(_args, *_options.dict)
File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(_args, _options)
File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(
_options)
File "/usr/lib/python2.6/site-packages/django/core/management/commands/syncdb.py", line 110, in handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive, db)
File "/usr/lib/python2.6/site-packages/django/core/management/sql.py", line 189, in emit_post_sync_signal
interactive=interactive, db=db)
File "/usr/lib/python2.6/site-packages/django/dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, *_named)
File "/usr/lib/python2.6/site-packages/django/contrib/auth/management/init.py", line 73, in create_superuser
call_command("createsuperuser", interactive=True, database=db)
File "/usr/lib/python2.6/site-packages/django/core/management/init.py", line 150, in call_command
return klass.execute(_args, *_defaults)
File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(_args, *_options)
File "/usr/lib/python2.6/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 70, in handle
default_username = get_default_username()
File "/usr/lib/python2.6/site-packages/django/contrib/auth/management/init.py", line 105, in get_default_username
default_username = get_system_username()
File "/usr/lib/python2.6/site-packages/django/contrib/auth/management/init.py", line 85, in get_system_username
return getpass.getuser().decode(locale.getdefaultlocale()[1])
File "/usr/lib64/python2.6/locale.py", line 478, in getdefaultlocale
return _parse_localename(localename)
File "/usr/lib64/python2.6/locale.py", line 410, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

@sglwlb

This comment has been minimized.

Copy link
Author

commented Feb 27, 2015

Anyone can help me? Very strange problem.

@fferner

This comment has been minimized.

Copy link

commented Mar 4, 2015

@sglwlb which version of Django have you got installed? I've run into the same problem after upgrading the Django14 rpm from version 1.4.14-1.el6 to 1.4.18-1.el6. Downgrading again fixed it for me.

So far I've not check what happened and which package might be at fault...

@sglwlb

This comment has been minimized.

Copy link
Author

commented Mar 5, 2015

@fferner Yeah, you are right, i also downgrading the Django14 to fix this problem. But now EPEL has updated the Django14 to the 1.4.18-1.el6, and the graphite-web on the EPEL became incompatible of the Django, that's not good. Hope graphite-web will update also.

@fferner

This comment has been minimized.

Copy link

commented Mar 5, 2015

@sglwlb FWIW, I've reported this issue as a bug to fedora-epel: https://bugzilla.redhat.com/show_bug.cgi?id=1199126

@sglwlb

This comment has been minimized.

Copy link
Author

commented Mar 6, 2015

@fferner Ah, cool, look forward some one will fix it, -:)

@mark-5

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2015

It looks like Django decided it will not serve static files, unless in debug mode or insecure mode. See --insecure documention and stackoverflow for more information.

More specifically, the problem is that staticfiles_urlpatterns in graphite.urls is not returning the appropriate regex, unless either of these modes are set.

@obfuscurity

This comment has been minimized.

Copy link
Member

commented Mar 9, 2015

This doesn't sound like a RHEL/EPEL bug to me, but a side-effect of upstream policy changes by Django. I'm not familiar with the EPEL package; do they rely on the development runserver or does the same thing happen when run via Apache/Nginx/etc? /cc @brutasse

@mark-5

This comment has been minimized.

Copy link
Contributor

commented Mar 9, 2015

As far as I can tell, it looks like this has always been the way Django behaved. I'm not actually sure why downgrading Django would have fixed this for the above users, though. When I manually install older Django releases(outside of a package manager), I still see this behavior.

It also might be worth noting that graphite didn't always use django.contrib.staticfiles, which is what causes this behavior. That seems to have been started in 1e1de1.

@jeremycrussell

This comment has been minimized.

Copy link

commented Mar 10, 2015

@obfuscurity I'm running with Apache 2.2.15-39/WSGI 3.2-7 and Django 1.4.18 and am experiencing the same issue.

@brutasse

This comment has been minimized.

Copy link
Member

commented Mar 10, 2015

Static files are served runserver only in DEBUG mode. Otherwise they're not served at all (considered insecure), hence the collectstatic step. Given that collectstatic's behavior depends on configuration, it's not easily done at packaging time or even installation time.

We could probably serve static files directly in the graphite webapp, using something like whitenoise (probably needs more work than what's in the quickstart docs, though).

@jeremycrussell

This comment has been minimized.

Copy link

commented Mar 10, 2015

Additionally, my installation is requesting the js and css from /content (i.e. /content/js/composer.js) and it's getting "200" responses, the content is just empty. However, the files do exist at /opt/graphite/webapp/content and permissions all appear to be fine. BTW, running graphite 0.9.12 installed via PIP.

@azikic

This comment has been minimized.

Copy link

commented Mar 10, 2015

@sglwlb I had the same problem. The apache site configuration was missing an alias for the content directory.
I added Alias /content/ "/usr/share/graphite/webapp/content/" to /etc/httpd/conf.d/graphite-web.conf to make it work.

@yoavp77

This comment has been minimized.

Copy link

commented Mar 10, 2015

@azikic can you share your entire graphite-web.conf vhost file?

@azikic

This comment has been minimized.

Copy link

commented Mar 10, 2015

@yoavp77 I am using centos 6.5 with the graphite-web package from EPEL. This is the default configuration file with the added alias configuration:

# Graphite Web Basic mod_wsgi vhost

<VirtualHost *:80>

    ServerName graphite-web
    DocumentRoot "/usr/share/graphite/webapp"
    ErrorLog /var/log/httpd/graphite-web-error.log
    CustomLog /var/log/httpd/graphite-web-access.log common
    Alias /content/ "/usr/share/graphite/webapp/content/"
    Alias /media/ "/usr/lib/python2.6/site-packages/django/contrib/admin/media/"

    WSGIScriptAlias / /usr/share/graphite/graphite-web.wsgi
    WSGIImportScript /usr/share/graphite/graphite-web.wsgi process-group=%{GLOBAL} application-group=%{GLOBAL}

    <Location "/content/">
        SetHandler None
    </Location>

    <Location "/media/">
        SetHandler None
    </Location>

</VirtualHost>
@yoavp77

This comment has been minimized.

Copy link

commented Mar 10, 2015

@azikic awesome! that's all I was missing to get it to work, also with graphite-web installed from EPEL (centos 6.2)

@mhitza

This comment has been minimized.

Copy link

commented Mar 10, 2015

@azikic thanks. Your fix couldn't have been more appropriately timed, since I've just encountered the same issue.

@sglwlb

This comment has been minimized.

Copy link
Author

commented Mar 11, 2015

@azikic Cool! Just upgrade the Django and try your fix, it works, thanks very much!

@ccoenen

This comment has been minimized.

Copy link

commented Mar 12, 2015

i can confirm that adding that line to /etc/httpd/conf.d/graphite-web.conf on CentOS fixed the issue.

Alias /content/ "/usr/share/graphite/webapp/content/"
@brutasse

This comment has been minimized.

Copy link
Member

commented Mar 19, 2015

There is a fix in master: static files are served by the webapp directly, no need to make an alias or anything. Note that whitenoise must be installed as a new dependency. The patch should be easy to port to 0.9.x if needed.

@brutasse brutasse closed this Mar 19, 2015

@gsaray101

This comment has been minimized.

Copy link

commented May 27, 2015

@brutasse, I am seeing the same problem on 0.10.0-alpha. How do you get rid of these errors?

@brutasse

This comment has been minimized.

Copy link
Member

commented May 28, 2015

@gsaray101 do you have whitenoise installed?

@gsaray101

This comment has been minimized.

Copy link

commented May 28, 2015

@brutasse, yes. I have installed whitenoise-1.0.6 and I also put this in wsgi.py file:

from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise

application = get_wsgi_application()
application = DjangoWhiteNoise(application)

I keep getting this error also in apache log, my secret key is already set:

[Thu May 28 09:41:24 2015] [error] /opt/graphite/webapp/graphite/settings.py:233: UserWarning: SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security

@brutasse

This comment has been minimized.

Copy link
Member

commented May 28, 2015

Just using DjangoWhiteNoise isn't enough -- see what's done here:

application = DjangoWhiteNoise(application)
prefix = "/".join((settings.URL_PREFIX.strip('/'), 'static'))
for directory in settings.STATICFILES_DIRS:
application.add_files(directory, prefix=prefix)
for app_path in settings.INSTALLED_APPS:
module = import_module(app_path)
directory = os.path.join(os.path.dirname(module.__file__), 'static')
if os.path.isdir(directory):
application.add_files(directory, prefix=prefix)

If you have the secret_key warning, it means your local_settings.py aren't found by graphite.

@gsaray101

This comment has been minimized.

Copy link

commented May 28, 2015

@brutasse,

I compilted mod_wsgi my wsgi.conf file under apache:/etc/apache2/conf.d looks like this:

LoadModule wsgi_module /usr/lib64/apache2/mod_wsgi.so
WSGISocketPrefix /var/run/wsg

I do see the module when I do /usr/sbin/http2 -M
wsgi_module (shared)

But I dont see this directory:

/usr/local/lib64/python2.6/site-packages/mod_wsgi-4.3.1-py2.6-linux-x86_64.egg/

WSGIPythonPath /usr/local/lib64/python2.6/site-packages does not seem to exists. Do I need this?

Do you think this is the problem

@gsaray101

This comment has been minimized.

Copy link

commented May 28, 2015

I've installed your wsgi.py, no change. I still get static errors on browser.

@gsaray101

This comment has been minimized.

Copy link

commented May 28, 2015

@brutasse , I really need help with this. I really dont know what is going on at this point. I do see this message in apache error: [Thu May 28 10:42:34 2015] [notice] Apache/2.2.12 (Linux/SUSE) mod_wsgi/4.3.0 Python/2.6.9 mod_ssl/2.2.12 OpenSSL/0.9.8j-fips configured -- resuming normal operations

Which means that mod_wsgi should be ok. Any ideas what I may be missing?

@deniszh

This comment has been minimized.

Copy link
Member

commented Mar 30, 2018

If I remember correctly this error happening if mod_wsgi and python versions are different (e.g 2.6 vs 2.7 or 2.7 vs 3.x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.