hopsoft / docker-graphite-statsd

Docker image for Graphite & Statsd
MIT License
867 stars 308 forks source link

Graphite is broken #33

Open jwalton opened 9 years ago

jwalton commented 9 years ago

On the latest version, when I try to access port 80, I get:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 101, in get_response
    request.path_info)
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 252, in resolve
    sub_match = pattern.resolve(new_path)
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 158, in resolve
    return ResolverMatch(self.callback, args, kwargs, self.name)
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 164, in _get_callback
    self._callback = get_callable(self._callback_str)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 124, in wrapper
    result = func(*args)
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 91, in get_callable
    lookup_view = getattr(import_module(mod_name), func_name)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/opt/graphite/webapp/graphite/browser/views.py", line 20, in <module>
    from graphite.util import getProfile, getProfileByUsername, defaultUser, json
  File "/opt/graphite/webapp/graphite/util.py", line 69, in <module>
    defaultUser = User.objects.get(username='default')
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 132, in get
    return self.get_query_set().get(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 344, in get
    num = len(clone)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 82, in __len__
    self._result_cache = list(self.iterator())
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 273, in iterator
    for row in compiler.results_iter():
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 680, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py", line 234, in execute
    return Database.Cursor.execute(self, query, params)
DatabaseError: no such table: auth_user
jwalton commented 9 years ago

Oh, hang on, I think this might be my fault... :P

jwalton commented 9 years ago

The problem happens when you try to use a custom storage directory for Graphite:

docker run -d --name statsd --restart=always \
    -p 8080:80 \
    -v /mnt/graphite-storage:/opt/graphite-storage \
    -e GRAPHITE_STORAGE_DIR=/opt/graphite-storage \
    hopsoft/graphite-statsd
jwalton commented 9 years ago

Can fix this by running:

docker run --rm \
    -v /mnt/graphite-storage:/opt/graphite-storage \
    -e GRAPHITE_STORAGE_DIR=/opt/graphite-storage \
    hopsoft/graphite-statsd \
    python /opt/graphite/webapp/graphite/manage.py syncdb --noinput

before I run graphite "for reals". You should think about adding this to your startup script, though, as I'm sure I'm not the only one keeping my graphite data outside the container.

hopsoft commented 9 years ago

Yeah... I've had several requests to automagically setup the dir structure for logs & graphite regardless of where you've mounted the volumes. I've been thinking through this quite a bit & will have a solution pushed up soon

chengweiv5 commented 9 years ago

continue this issue, I see /opt/graphite is not empty but exported as volume, if I start a container as -v /data/graphite/:/opt/graphite option, it always fail to start. So what's the point to export /opt/graphite as a volume?

BTW, what is /opt/graphite-storage? I didn't see it in README or Dockerfile as a volume.

chengweiv5 commented 9 years ago

OK, I saw GRAPHITE_STORAGE_DIR in conf/graphite/carbon.conf. But still confused why it says /opt/graphite is a volume? Because you can't mount an empty volume to it, that will break graphite service, so as /etc/nginx, /opt/statsd, /etc/logrotate.d and /var/log.

chengweiv5 commented 9 years ago

em, after go-through docker document again, I think I understand how I should use these volumes, my bad, sorry.

YannRobert commented 9 years ago

I went thru this volume initialization problem too.

I created a script that initializes the file structure by starting the container once, then docker cp the files to the volumes. I just then have to start a new container with those volumes mounted and it works.

I shared the script in this gist : https://gist.github.com/YannRobert/3aa307a5e5d510d58e23

mikelehen commented 9 years ago

Yeah, I ran into this too...

dbeckham commented 9 years ago

See #43