Я буду оновлювати звʼязку з версії 0.9.15 (python-2.7) на 1.1.10 (python-3.11). Нову версію буду піднімати у python venv, щоб потім було легше переносити.
Підготовка
$ export PYTHONPATH="/opt/graphite/lib/:/opt/graphite/webapp/"
$ python3.11 -m venv graphite
$ source ./graphite/bin/activate
$ cd graphite
$ pip install https://github.com/graphite-project/carbon/tarball/1.1.10
$ pip install https://github.com/graphite-project/whisper/tarball/1.1.10
$ pip install https://github.com/graphite-project/graphite-web/tarball/1.1.10
Встановлення
Копіюємо local_settings.py і запускаємо install:
(graphite) skeletor@graphite:/opt/graphite$ python3 setup.py install --prefix=/opt/graphite
(graphite) skeletor@graphite:/opt/graphite$ cd lib/python3.11/site-packages
(graphite) skeletor@graphite:/opt/graphite/lib/python3.11/site-packages$ ln -s ../../../webapp/content
(graphite) skeletor@graphite:/opt/graphite/lib/python3.11/site-packages$ cd ../../../
(graphite) skeletor@graphite:/opt/graphite$ python3 webapp/manage.py collectstatic
478 static files copied to '/opt/graphite/static'.
Міграція
Далі запускаємо міграцію зі старої БД
(graphite) skeletor@graphite:/opt/graphite$ webapp/manage.py migrate --settings=graphite.settings --pythonpath /opt/graphite/lib/:/opt/graphite/webapp/
Якщо при цьому отримуємо помилку
django.db.utils.OperationalError: table "dashboard_dashboard" already exists
То скоріш за все БД дуже стара і мігратор не може це зробити в 1 крок. Робимо наступне:
(graphite) skeletor@graphite:/opt/graphite$ webapp/manage.py migrate --settings=graphite.settings --fake --pythonpath /opt/graphite/lib/:/opt/graphite/webapp/ Operations to perform: Apply all migrations: account, admin, auth, contenttypes, dashboard, events, sessions, tagging, tags, url_shortener Running migrations: Applying dashboard.0001_initial... FAKED Applying events.0001_initial... FAKED Applying tagging.0002_on_delete... FAKED Applying tags.0001_initial... FAKED Applying url_shortener.0001_initial... FAKED (graphite) skeletor@graphite:/opt/graphite$ webapp/manage.py showmigrations --settings=graphite.settings --pythonpath /opt/graphite/lib/:/opt/graphite/webapp/ account [X] 0001_initial admin [X] 0001_initial [X] 0002_logentry_remove_auto_add [X] 0003_logentry_add_action_flag_choices auth [X] 0001_initial [X] 0002_alter_permission_name_max_length [X] 0003_alter_user_email_max_length [X] 0004_alter_user_username_opts [X] 0005_alter_user_last_login_null [X] 0006_require_contenttypes_0002 [X] 0007_alter_validators_add_error_messages [X] 0008_alter_user_username_max_length [X] 0009_alter_user_last_name_max_length [X] 0010_alter_group_name_max_length [X] 0011_update_proxy_permissions contenttypes [X] 0001_initial [X] 0002_remove_content_type_name dashboard [X] 0001_initial events [X] 0001_initial sessions [X] 0001_initial tagging [X] 0001_initial [X] 0002_on_delete tags [X] 0001_initial url_shortener [X] 0001_initial
І знову пробуємо міграцію:
(graphite) skeletor@graphite:/opt/graphite$ webapp/manage.py migrate --settings=graphite.settings --pythonpath /opt/graphite/lib/:/opt/graphite/webapp/ Operations to perform: Apply all migrations: account, admin, auth, contenttypes, dashboard, events, sessions, tagging, tags, url_shortener Running migrations: No migrations to apply. Your models have changes that are not yet reflected in a migration, and so won't be applied. Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
(graphite) skeletor@graphite:/opt/graphite$ webapp/manage.py makemigrations --settings=graphite.settings --pythonpath /opt/graphite/lib/:/opt/graphite/webapp/ Migrations for 'account': lib/python3.11/site-packages/graphite/account/migrations/0002_auto_20250507_0744.py - Alter field history on profile Migrations for 'events': lib/python3.11/site-packages/graphite/events/migrations/0002_auto_20250507_0744.py - Alter field tags on event
(graphite) skeletor@graphite:/opt/graphite$ webapp/manage.py migrate --settings=graphite.settings --pythonpath /opt/graphite/lib/:/opt/graphite/webapp/ Operations to perform: Apply all migrations: account, admin, auth, contenttypes, dashboard, events, sessions, tagging, tags, url_shortener Running migrations: Applying account.0002_auto_20250507_0744... OK Applying events.0002_auto_20250507_0744... OK
Покращення
Для нормальної роботи нам треба буде встановити такі шрифти: system/font/truetype/cantarell, system/font/truetype/croscorefonts, system/font/truetype/dejavu, а також gunicorn для запуску graphite-web через fastCGI:
(graphite) skeletor@graphite:/opt/graphite$ pip install gunicorn
і готуємо стартовий скрипт:
#!/bin/sh /opt/graphite/bin/gunicorn \ --daemon \ --chdir /opt/graphite/webapp \ --pythonpath /opt/graphite/lib:/opt/graphite/webapp \ graphite.wsgi:application \ --workers 30 \ --threads 200 \ --max-requests 200 \ --log-file=/opt/graphite/var/log/gunicorn.log \ --bind unix:/opt/graphite/var/run/graphite.sock \ --pid /opt/graphite/var/run/graphite.pid
А ще мені не подобається, коли при відкритті dashboard’y третину екрану займає смуга з керування, тому я її одразу ховаю. Нижче patch для цього:
graphite-web 1.1.10: --- webapp/content/js/dashboard.js 2025-05-07 09:17:17.795268150 +0000 +++ webapp/content/js/dashboard.js 2025-05-07 09:17:52.569058869 +0000 @@ -791,8 +791,8 @@ // Load initial dashboard state if it was passed in if (initialState) { applyState(initialState); - navBar.collapse(false); } + navBar.collapse(false); if(window.location.hash != '') { ========================================= graphite-web 0.9.15: --- webapp/content/js/dashboard.js 2025-05-07 09:15:14.731723466 +0000 +++ webapp/content/js/dashboard.js 2025-05-07 09:14:42.050163125 +0000 @@ -719,8 +719,8 @@ // Load initial dashboard state if it was passed in if (initialState) { applyState(initialState); - navBar.collapse(); } + navBar.collapse(); if(window.location.hash != '') {