-
Notifications
You must be signed in to change notification settings - Fork 1
Examples-pilot fixes #63
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,48 +1,26 @@ | ||||
| #Файл конфигурации GMonit. Пожалуйста переименуйте его в ".env". | ||||
|
|
||||
| # Версия GMonit | ||||
| TAG= | ||||
| TAG=v3-3135 | ||||
|
|
||||
| # GMonit linense key | ||||
| LICENSE_KEY= | ||||
|
|
||||
| # random string | ||||
| SECRET_TOKEN= | ||||
|
|
||||
| # Пароль для логина admin применяется при первом запуске | ||||
| GRAFANA_ADMIN_PASSWORD=password | ||||
|
|
||||
| # В этом примере мы используeм домены: | ||||
|
|
||||
| GRAFANA_DOMAIN=gmonit.example | ||||
| COLLECTOR_DOMAIN=gmonit-collector.example | ||||
| LICENSE_KEY=xxx #укажите здесь лицензионный ключ GMonit | ||||
|
|
||||
| # Чтобы открыть их в браузере нужно добавить в файл /etc/hosts на вашей машине: | ||||
| # # /etc/hosts | ||||
| # 127.0.0.1 gmonit.example | ||||
| # 127.0.0.1 gmonit-collector.example | ||||
| # random string - укажите случайную строку | ||||
| SECRET_TOKEN=AAZtUvIaAagdlZGl0aW9uagplbnRlcnByaXN | ||||
|
|
||||
| # Для этих доменов выпущен самоподписанный сертификат на 100 лет. | ||||
| # Команды для выпуска сертификата вы найдете в директории ./ssl | ||||
| # Passwords | ||||
| GRAFANA_ADMIN_PASSWORD=123456789 #пароль для admin в Grafana | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. так делать нельзя, т.к. из-за ошибок у клиентов будет дефолтный пароль, и этот дефолтный пароль общедоступен
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line 27 in f66e11c
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Не совсем корректно, так как |
||||
| CLICKHOUSE_PASSWORD=123456789 #задайте пароль для БД Clickhouse | ||||
| POSTGRES_PASSWORD=123456789 #задайте пароль для БД PostgreSQL | ||||
| COLLECTOR_DATASOURCE_PASSWORD=123456789 #задайте пароль для коллектора | ||||
|
|
||||
| # ./ssl внутри контейнеров смонтирована в /gmonit/ssl | ||||
| # Domains - задайте домены и обеспечьте их разрешение | ||||
| GRAFANA_DOMAIN=gmonit.example #домен для интерфейса | ||||
| COLLECTOR_DOMAIN=gmonit-collector.example #домен для коллектора | ||||
|
|
||||
| CA_FILE=/gmonit/ssl/rootCA.crt | ||||
| #Certificates - сгенерированные сертификаты | ||||
| CA_FILE=/gmonit/ssl/rootCA.pem | ||||
| CERT_FILE=/gmonit/ssl/server.crt | ||||
| KEY_FILE=/gmonit/ssl/server.key | ||||
|
|
||||
| # Вы можете настроить в вашем DNS произвольные домены и выпустить собственные сертификаты: | ||||
|
|
||||
| # GRAFANA_DOMAIN=gmonit.company.ru | ||||
| # COLLECTOR_DOMAIN=gmonit-collector.company.ru | ||||
| # CA_FILE=/gmonit/ssl/company-rootCA.crt | ||||
| # CERT_FILE=/gmonit/ssl/company-server.crt | ||||
| # KEY_FILE=/gmonit/ssl/company-server.key | ||||
|
|
||||
| #== Обязательно установите пароли! ==# | ||||
| # ClickHouse | ||||
| CLICKHOUSE_PASSWORD= | ||||
|
|
||||
| # Postgres | ||||
| POSTGRES_PASSWORD= | ||||
|
|
||||
| # COLLECTOR DATASOURCE | ||||
| COLLECTOR_DATASOURCE_PASSWORD= | ||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,7 +118,7 @@ services: | |
| condition: service_healthy | ||
| volumes: | ||
| - ./ssl:/gmonit/ssl | ||
| - ./***.mmdb:/gmonit/geoip.mmdb | ||
| - ./geoip.mmdb:/gmonit/geoip.mmdb | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. это наверное в .env вынести просто и здесь подставлять |
||
| <<: *logging | ||
|
|
||
| collector: | ||
|
|
@@ -174,7 +174,7 @@ services: | |
| restart: unless-stopped | ||
| image: umputun/nginx-le:v1.7.0 | ||
| volumes: | ||
| - ./nginx/ssl:/etc/nginx/ssl | ||
| - ./ssl:/gmonit/ssl | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. зачем?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| - ./nginx/conf.d-le:/etc/nginx/conf.d-le | ||
| - ./nginx/templates:/etc/nginx/templates | ||
| ports: | ||
|
|
@@ -244,6 +244,7 @@ services: | |
| NRIA_IDENTITY_URL: https://${COLLECTOR_DOMAIN}/infra/identity-api | ||
| NRIA_CA_BUNDLE_FILE: ${CA_FILE} | ||
| POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} | ||
|
|
||
| # не работает на самоподписанных сертификатах | ||
| # NRIA_SELF_INSTRUMENTATION: newrelic | ||
| # NRIA_SELF_INSTRUMENTATION_APM_HOST: ${COLLECTOR_DOMAIN} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,213 @@ | ||
| # Инструкция по подготовке и запуску GMonit | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. файл должен называться |
||
|
|
||
| В этой инструкции описывается процесс подготовки и запуска GMonit с использованием самоподписанных сертификатов. Используется Docker Compose. | ||
|
|
||
| ## Содержание | ||
| - Настройка доменов и файла `.env` с параметрами GMonit. | ||
| - Добавление доменов в файлы `hosts`, если отсутствует DNS. | ||
| - Генерация самоподписанныч сертификаты и настроить их использование. | ||
| - Установка Docker и Docker Compose. | ||
| - Авторизация в Yandex Container Registry. | ||
| - Скачивание и подготовка базы данных GeoIP. | ||
| - Запуск GMonit и проверка его работоспособности. | ||
|
|
||
| После завершения всех шагов можно приступить к установке агентов сбора данных. | ||
|
|
||
| ## Шаги настройки | ||
|
|
||
| ### 1. Настройка доменов | ||
| Прописать в файле `.env` заранее созданные домены: | ||
| - Для коллектора | ||
| - Для Grafana | ||
|
|
||
| ### 2. Настроить .env файл | ||
| - `TAG` — версия GMonit | ||
| - `LICENSE_KEY` — ключ лицензии GMonit. | ||
| - `SECRET_TOKEN` — случайная строка (например, 32-значный алфавитно-цифровой токен). | ||
| - `GRAFANA_ADMIN_PASSWORD` — пароль для авторизации в UI GMonit. | ||
| - `CLICKHOUSE_PASSWORD` — пароль для базы данных ClickHouse. | ||
| - `POSTGRES_PASSWORD` — пароль для базы данных PostgreSQL. | ||
| - `COLLECTOR_DATASOURCE_PASSWORD` — пароль для доступа к источнику данных коллектора. | ||
| - `GRAFANA_DOMAIN` — grafana.address домен пользовательского интерфейса. | ||
| - `COLLECTOR_DOMAIN` — collector.address домен коллектора сбора данных. | ||
|
|
||
| ### 3. Добавить домены для разрешения (если без DNS) | ||
| - На машине пользователя (Windows) добавить домены в `C:\Windows\System32\drivers\etc\hosts`. | ||
| - На Linux машине: `sudo nano /etc/hosts`. | ||
|
|
||
| ### 4. Выпустить Root Certificate Authority (CA) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Отмечу еще, что если клиенту нужны самоподписанные сертификаты, то почти наверняка Может быть не стоит здесь давать эти рекомендации.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Наша задача: сделать установку нашего дистрибутива гладкой и понятной. Я отметил, что при наличии сертификатов, эти шаги можно пропустить. А для тестовой установки проверенные шаги по генерации сертификатов позволят сотруднику не совершить ошибок при создании сертификатов.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Чтобы не было ошибок для QA там лежали сертификаты, выпущенные на 100 лет или вроде того |
||
| - Если используются существующие сертификаты, пропустите этот и следующий шаги. | ||
| ```bash | ||
| # Всё на Linux машине | ||
| # Создать директорию для сертификатов | ||
| mkdir ~/certificates | ||
| cd ~/certificates | ||
|
|
||
| # Сгенерировать Root CA private key | ||
| openssl genrsa -out rootCA.key 2048 | ||
|
|
||
| # Выпустить Root CA certificate с увеличенным сроком действия | ||
| openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1825 -out rootCA.pem -config cert.conf | ||
|
|
||
| # Сделать Root CA certificate в crt | ||
| openssl x509 -in rootCA.pem -outform pem -out rootCA.crt | ||
| ``` | ||
|
|
||
| ### 5. Выпустить SSL-сертификат | ||
| - Создать конфигурационный файл. | ||
| ```bash | ||
| nano cert.conf | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cat <<EOF > cert.conf
[req]
default_bits = 2048
default_md = sha256
...
EOF |
||
|
|
||
| # Пример содержимого: | ||
|
|
||
| [req] | ||
| default_bits = 2048 | ||
| default_md = sha256 | ||
| distinguished_name = req_distinguished_name | ||
| req_extensions = v3_req | ||
| prompt = no | ||
|
|
||
| [req_distinguished_name] | ||
| C = RU | ||
| ST = Moscow | ||
| L = Moscow | ||
| O = GMonitOrg | ||
| CN = *.ubuntu24 | ||
|
|
||
| [v3_req] | ||
| keyUsage = keyEncipherment, dataEncipherment, digitalSignature | ||
| extendedKeyUsage = serverAuth, clientAuth | ||
| subjectAltName = @alt_names | ||
|
|
||
| [alt_names] | ||
| DNS.1 = *.ubuntu24 | ||
| DNS.2 = ubuntu24 | ||
| DNS.3 = ui.ubuntu24 | ||
| DNS.4 = collector.ubuntu24 | ||
| ``` | ||
|
|
||
| - Выпустить сертификат. | ||
| ```bash | ||
| # Сгенерировать server private key | ||
| openssl genrsa -out server.key 2048 | ||
|
|
||
| # Создать Certificate Signing Request (CSR) с использованием cert.conf | ||
| openssl req -new -key server.key -out server.csr -config cert.conf | ||
|
|
||
| # Подписать CSR созданным Root CA с увеличенным сроком действия | ||
| openssl x509 -req -in server.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out server.crt -days 1825 -sha256 -extfile cert.conf -extensions v3_req | ||
| ``` | ||
|
|
||
| ### 6. Разместить файлы сертификатов | ||
| - Скопировать созданные сертификаты в директорию `gmonit/ssl` дистрибутива GMonit. | ||
| - Файл `rootCA.crt` на сервере `sudo cp rootCA.crt /usr/local/share/ca-certificates/` -> `sudo update-ca-certificates`. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. так нельзя делать по соображениям безопасности, и нет причины это делать
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Напиши пожалуйста подробнее, как надо делать.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Тебе нужно понять что именно ты тут делаешь. |
||
| - Файл `rootCA.crt` скопировать на Windows-машину пользователя и установить (Install Certificate -> Local Machine -> Trusted Root Certification Authorities). | ||
|
|
||
| ### 7. Прописать пути к сертификатам | ||
| - Проверить, что эти сертификаты есть в `gmonit/ssl` папке. | ||
| ```bash | ||
| # Файл .env | ||
| CA_FILE=/gmonit/ssl/rootCA.pem | ||
| CERT_FILE=/gmonit/ssl/server.crt | ||
| KEY_FILE=/gmonit/ssl/server.key | ||
| ``` | ||
|
|
||
| ### 8. Установить Docker+Compose | ||
| - Проверить установку, если есть, пропускаем этот шаг. | ||
| ```bash | ||
| docker compose version | ||
| ``` | ||
| - Установить докер. | ||
| ```bash | ||
| # Подготовить систему | ||
| sudo apt-get update | ||
| sudo apt-get install \ | ||
| ca-certificates \ | ||
| curl \ | ||
| gnupg \ | ||
| lsb-release | ||
|
|
||
| # Добавить GPG-ключ Docker | ||
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg \ | ||
| | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | ||
|
|
||
| # Добавить репозиторий Docker | ||
| echo \ | ||
| "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ | ||
| $(lsb_release -cs) stable" \ | ||
| | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
|
|
||
| # Установить Docker Engine | ||
| sudo apt-get update | ||
| sudo apt-get install docker-ce docker-ce-cli containerd.io | ||
|
|
||
| # Добавить пользователя в группу docker (выйдите из системы и зайдите снова после этого) | ||
| sudo usermod -aG docker $USER | ||
|
|
||
| # Проверить плагин Docker Compose | ||
| docker compose version | ||
| ``` | ||
|
|
||
| ### 9. Авторизация в Yandex Container Registry | ||
| - Скопировать ключ Яндекс в файл `/home/user/key.json`. | ||
| - Произвести логин. | ||
| ```bash | ||
| cat key.json | docker login \ | ||
| --username json_key \ | ||
| --password-stdin \ | ||
| cr.yandex | ||
| ``` | ||
| - Проверить, что ключ сохранился. | ||
| ```bash | ||
| cat ~/.docker/config.json | ||
| ``` | ||
| - После успешного выполнения key.json можно с машины удалить. | ||
|
|
||
| ### 10. Скопировать gmonit каталог на сервер | ||
| - `gmonit` скопировать в `/home/user/`. | ||
|
|
||
| ### 11. Загрузить базу данных GeoIP | ||
| - Проверить текущую версию базы данных и ссылку на `https://db-ip.com/db/download/ip-to-city-lite`. | ||
| - Скачать базу данных на сервере. | ||
| ```bash | ||
| # Зайти в папку gmonit | ||
| cd ~/gmonit | ||
|
|
||
| # Загрузить базу данных GeoIP | ||
| wget https://download.db-ip.com/free/dbip-city-lite-2025-01.mmdb.gz | ||
|
|
||
| # Распаковать скачанный файл | ||
| gzip -d *.mmdb.gz | ||
|
|
||
| # Переименование файла для использования в GMonit | ||
| mv "$(find . -maxdepth 1 -name '*.mmdb' | head -n 1)" geoip.mmdb | ||
| ``` | ||
|
|
||
| ### 12. Запуск приложения | ||
| ```bash | ||
| cd ~/gmonit | ||
|
|
||
| # Обновить образы Docker (опционально) | ||
| docker compose pull | ||
|
|
||
| # Запустить контейнеры и ожидать их готовности | ||
| docker compose up --wait | ||
| ``` | ||
| ## Проверить, что работает | ||
| - Проверить статус контейнеров. | ||
| ```bash | ||
| docker compose ps | ||
| ``` | ||
| - Зайти на сервер, убедиться, что открывается. | ||
| ```bash | ||
| https://grafana.address | ||
| ``` | ||
| - Такой запрос к коллектору должен вернуть JSON с версией. | ||
| ```bash | ||
| https://collector.address/about | ||
| ``` | ||
|
|
||
| ## Редкации и проверка | ||
| Редакция инструкции от 18 января 2025 года. | ||
| Проверено на Ubuntu 24.04.1 LTS. 18 января 2025 года. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,11 +13,18 @@ server { | |
| # https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass | ||
| resolver 127.0.0.11; | ||
|
|
||
| ssl_certificate SSL_CERT; | ||
| ssl_certificate_key SSL_KEY; | ||
| ssl_trusted_certificate SSL_CHAIN_CERT; | ||
| ssl_certificate ${SSL_CERT}; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. отступы не стоит менять |
||
| ssl_certificate_key ${SSL_KEY}; | ||
| ssl_trusted_certificate ${SSL_CHAIN_CERT}; | ||
|
Comment on lines
-16
to
+18
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. зачем?[2] |
||
|
|
||
| # in caddy it's also unlimited, leaving it as is for now | ||
| ssl_protocols TLSv1.2 TLSv1.3; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ssl_ciphers HIGH:!aNULL:!MD5; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| ssl_stapling off; | ||
| ssl_stapling_verify off; | ||
|
Comment on lines
+23
to
+24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. оно и так выключено |
||
|
|
||
|
|
||
| # in caddy it's also unlimited, leaving it as is for now | ||
| client_max_body_size 0; | ||
|
|
||
| location / { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это приведет к ошибкам, не стоит прописывать конкретные значения.
Например, кто-то забудет и будет использовать старую версию
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нам обязательно надо указывать ту версию, на которой проверялся этот дистрибутив. Поэтому считаю, что надо указывать версию на которой этот дистрибутив проходил QA.