### RelativeDatetime() examples for start period Source: https://elma365.com/ru/help/platform/eql-syntax.html Examples of start parameter values: 0h, +1m, -1w+1d. These define the beginning of the period. ```text 0h ``` ```text +1m ``` ```text -1w+1d ``` -------------------------------- ### Install KEDA chart with Helm Source: https://elma365.com/ru/help/platform/install-keda.html Install the KEDA chart into the keda namespace. Use the first command for online installation and the second for offline installation from the directory containing the downloaded chart. ```bash helm upgrade --install keda elma365/keda -f values-keda.yaml -n keda --create-namespace ``` ```bash helm upgrade --install keda ./keda -f values-keda.yaml -n keda --create-namespace ``` -------------------------------- ### Install MinIO Client Source: https://elma365.com/ru/help/platform/configure-minio.html Downloads the latest stable MinIO Client binary and installs it to /usr/local/bin/. ```bash wget https://dl.min.io/client/mc/release/linux-amd64/mc chmod +x mc sudo mv mc /usr/local/bin/ ``` -------------------------------- ### Install MinIO binary Source: https://elma365.com/ru/help/platform/configure-minio.html Downloads the latest stable MinIO binary and installs it to /usr/local/bin/. ```bash wget https://dl.min.io/server/minio/release/linux-amd64/minio chmod +x minio sudo mv minio /usr/local/bin/ ``` -------------------------------- ### Enable and start rabbitmq-server Source: https://elma365.com/ru/help/platform/configure-rabbitmq.html Enables and starts the rabbitmq-server service. ```bash sudo systemctl enable --now rabbitmq-server ``` -------------------------------- ### Install hostpath-provisioner chart via Helm (online) Source: https://elma365.com/ru/help/platform/install-hostpath-provisioner.html Installs or upgrades the hostpath-provisioner chart from the elma365 repository into the kube-system namespace using the values file. Use this for installation with internet access. ```bash helm upgrade --install hostpath-provisioner elma365/hostpath-provisioner -f values-hostpath-provisioner.yaml -n kube-system ``` -------------------------------- ### Install hostpath-provisioner chart via Helm (offline) Source: https://elma365.com/ru/help/platform/install-hostpath-provisioner.html Installs or upgrades the hostpath-provisioner chart from a local directory into the kube-system namespace using the values file. Run this from the directory containing the downloaded chart for offline installation. ```bash helm upgrade --install hostpath-provisioner ./hostpath-provisioner -f values-hostpath-provisioner.yaml -n kube-system ``` -------------------------------- ### Enable containerd and kubelet services Source: https://elma365.com/ru/help/platform/kubernetes-on-redos.html Starts containerd and adds it to startup, then enables kubelet.service. Run as root on all nodes. ```bash systemctl enable --now containerd ``` ```bash systemctl enable kubelet.service ``` -------------------------------- ### Get installed values-elma365.yaml Source: https://elma365.com/ru/help/platform/change-settings-enterprise.html Reads the parameters file used during the ELMA365 installation. Optionally specify a namespace with -n. ```bash helm [-n namespace] list helm [-n namespace] get values elma365 > values-elma365-installed.yaml ``` -------------------------------- ### values-envoy-gateway.yaml - Envoy Gateway Configuration Source: https://elma365.com/ru/help/platform/envoy-gateway.html Example configuration for Envoy Gateway installation, including gateway-helm deployment settings and envoyGateway controller configuration. Used in Step 2 of the installation process. ```yaml ## Настройки envoy-gateway gateway-helm: deployment: envoyGateway: resources: limits: memory: 1024Mi requests: cpu: 100m memory: 256Mi ## Настройки конфигурации config: envoyGateway: gateway: controllerName: gateway.envoyproxy.io/gatewayclass-controller provider: type: Kubernetes --- ``` -------------------------------- ### resources example Source: https://elma365.com/ru/help/business_solutions/configmap.html Пример настройки ресурсов микросервиса: requests указывают выделяемые память и CPU, limits — максимальные значения. Значения из официальной документации Kubernetes. ```yaml resources: requests: memory: "512Mi" cpu: "500m" limits: memory: "2048Mi" cpu: "1000m" ``` -------------------------------- ### destroy() example: clear interval on page close Source: https://elma365.com/ru/help/crm/widget_functions.html Stops an automatic refresh interval when the widget is destroyed. The example includes onInit() to start the interval, a setIntervalRefresh() function, and destroy() to clear the interval, preventing server errors from overlapping timers. ```typescript async function onInit(): Promise { // await refresh(); setIntervalRefresh(); } let intervalID: number; declare const window: { setInterval: (fn: () => void, interval: number) => number; clearInterval: (clearInterval: number) => void; }; async function setIntervalRefresh () { intervalID = window.setInterval(() => { refresh(); }, 3000); } async function destroy(): Promise { window.clearInterval(intervalID); } ``` -------------------------------- ### Create and configure /etc/patroni/config.yml Source: https://elma365.com/ru/help/configure-postgresql.html Create the Patroni configuration file /etc/patroni/config.yml and populate it with the initial configuration example. Replace IP addresses with your own on each cluster node; note the comments in the file. ```bash sudo nano /etc/patroni/config.yml ``` ```yaml scope: postgres-cluster # одинаковое значение на всех узлах name: postgresql-server1 # разное значение на всех узлах namespace: /service/ # одинаковое значение на всех узлах restapi: listen: postgres-server1.your_domain:8008 # адрес узла, на котором находится этот файл connect_address: postgres-server1.your_domain:8008 # адрес узла, на котором находится этот файл etcd: hosts: postgres-server1.your_domain:2379,postgres-server2.your_domain:2379,postgres-server3.your_domain:2379 # список всех узлов, на которых установлен etcd bootstrap: method: initdb dcs: ttl: 30 loop_wait: 10 retry_timeout: 10 maximum_lag_on_failover: 1048576 master_start_timeout: 300 synchronous_mode: **false** synchronous_mode_strict: **false** synchronous_node_count: 1 postgresql: use_pg_rewind: **true** use_slots: **true** parameters: max_connections: 2000 superuser_reserved_connections: 5 max_locks_per_transaction: 64 max_prepared_transactions: 0 huge_pages: **try** shared_buffers: 512MB work_mem: 128MB maintenance_work_mem: 256MB effective_cache_size: 4GB checkpoint_timeout: 15min checkpoint_completion_target: 0.9 wal_compression: on min_wal_size: 2GB max_wal_size: 4GB wal_buffers: 32MB default_statistics_target: 1000 seq_page_cost: 1 random_page_cost: 4 effective_io_concurrency: 2 synchronous_commit: on autovacuum: on autovacuum_max_workers: 5 autovacuum_vacuum_scale_factor: 0.1 autovacuum_analyze_scale_factor: 0.05 autovacuum_vacuum_cost_limit: 200 autovacuum_vacuum_cost_delay: 20 autovacuum_naptime: 15s max_files_per_process: 4096 archive_mode: on archive_timeout: 1800s archive_command: cd . wal_level: replica wal_keep_segments: 130 max_wal_senders: 10 max_replication_slots: 10 hot_standby: on hot_standby_feedback: True wal_log_hints: on shared_preload_libraries: pg_stat_statements,auto_explain pg_stat_statements.max: 10000 pg_stat_statements.track: all pg_stat_statements.save: off auto_explain.log_min_duration: 10s auto_explain.log_analyze: **true** auto_explain.log_buffers: **true** auto_explain.log_timing: **false** auto_explain.log_triggers: **true** auto_explain.log_verbose: **true** auto_explain.log_nested_statements: **true** standard_conforming_strings: true track_io_timing: on log_lock_waits: on log_temp_files: 3 track_activities: on track_counts: on track_functions: all log_checkpoints: on logging_collector: on log_truncate_on_rotation: on log_rotation_age: 1d log_rotation_size: 0 log_line_prefix: '%t [%p-%l] %r %q%u@%d ' log_filename: 'postgresql-%a.log' log_directory: /**var** /log/postgresql initdb: # List options to be passed on to initdb - encoding: UTF8 - locale: en_US.UTF-8 - data-checksums pg_hba: # должен содержать адреса ВСЕХ машин, используемых в кластере - local all postgres peer - local all all peer - host all all 0.0.0.0/0 md5 - host replication replicator localhost trust - host replication replicator 192.168.1.1/32 md5 - host replication replicator 192.168.1.2/32 md5 - host replication replicator 192.168.1.3/32 md5 postgresql: listen: 192.168.1.1,127.0.0.1:5432 # адрес узла, на котором находится этот файл connect_address: 192.168.1.1:5432 # адрес узла, на котором находится этот файл use_unix_socket: **true** data_dir: /**var** /lib/postgresql/13/main # каталог данных bin_dir: /usr/lib/postgresql/13/bin config_dir: /etc/postgresql/13/main pgpass: /**var** /lib/postgresql/.pgpass_patroni authentication: replication: username: replicator password: ReplicatorPassword superuser: username: postgres password: PostgresPassword parameters: unix_socket_directories: /**var** /run/postgresql pg_hba: # должен содержать адреса ВСЕХ машин, используемых в кластере - local all postgres peer - local all all peer - host all all 0.0.0.0/0 md5 - host replication replicator localhost trust - host replication replicator 192.168.1.1/32 md5 - host replication replicator 192.168.1.2/32 md5 - host replication replicator 192.168.1.3/32 md5 remove_data_directory_on_rewind_failure: **false** remove_data_directory_on_diverged_timelines: **false** **** create_replica_methods: - basebackup basebackup: max-rate: '100M' checkpoint: 'fast' ``` -------------------------------- ### Get OpenELB values-openelb.yaml via Helm Source: https://elma365.com/ru/help/platform/fail-safe-kubernetes-cluster.html Adds the elma365 Helm repository, updates it, and writes the default OpenELB chart values to values-openelb.yaml for internet-based installation. ```bash helm repo add elma365 https://charts.elma365.tech helm repo update helm show values elma365/openelb > values-openelb.yaml ``` -------------------------------- ### onInit() example - load users into a table Source: https://elma365.com/ru/help/crm/widget_functions.html Example onInit() that searches for up to 100 users, inserts them into the context table 'users', and formats birth date if present. This snippet assumes the widget has a table variable 'users' with string fields 'name' and 'birthDate'. ```typescript async function onInit(): Promise { const users = await System.users.search().size(100).sort('__name', true).all(); for (const user of users) { let item = Context.data.users!.insert(); item.name = user.data.__name; item.birthDate = user.data.birthDate ? user.data.birthDate.format('L') : ''; } Context.data.users = Context.data.users; } ``` -------------------------------- ### Get Linkerd values file from Helm repository Source: https://elma365.com/ru/help/platform/install-linkerd.html Adds the ELMA365 Helm repository, updates it, and writes the default Linkerd chart values to values-linkerd.yaml for online installation. ```bash helm repo add elma365 https://charts.elma365.tech ``` ```bash helm repo update ``` ```bash helm show values elma365/linkerd > values-linkerd.yaml ``` -------------------------------- ### Count() examples for table and application Source: https://elma365.com/ru/help/platform/360027003711.html Shows how to use Count() to get the number of rows in a report table and the number of elements in a linked application. The output is shown after the arrow. ```plaintext {Count({$report_table})} —> 12. ``` ```plaintext {Count({$app})} —> 3. ``` -------------------------------- ### Инициализация master-узла: kubeadm init Source: https://elma365.com/ru/help/platform/kubernetes-on-redos.html Команда инициализации master-узла Kubernetes. Ключ --pod-network-cidr задает адрес внутренней подсети для будущего кластера. ```bash kubeadm init --pod-network-cidr=10.244.0.0/16 ``` -------------------------------- ### Configure values-jaeger.yaml for Jaeger Source: https://elma365.com/ru/help/platform/installation-jaeger.html Example values-jaeger.yaml configuration for Jaeger installation. Includes resource limits, tolerations, nodePort service, ingress settings, secret options, memory_max_traces, and replicaCount. ```yaml # Настройки jaeger jaeger: resources: requests: cpu: 100m memory: 256Mi limits: cpu: 500m memory: 8Gi tolerations: - effect: NoSchedule key: dedicated **operator** : Equal value: monitoring service: name: jaeger-nodeport # Порт для доступа к jaeger при выключенном ingress nodePort: 32121 ingress: # включение host в ingress enabled: **false** className: "" annotations: kubernetes.io/ingress.**class** : nginx # аннотации для работы cert-manager # certmanager.io/cluster-issuer: letsencrypt hosts: # домен (FQDN), по которому будет доступна система - host: example.ru paths: - path: / pathType: ImplementationSpecific # включение шифрования, при использовании cert-manager указать используемый secretName letsencrypt # tls: # - secretName: example-ru-cert # hosts: # - example.ru # включить создание secret с собственными сертификатами # указать путь до сертификата в строках key: и cert: secret: enabled: **false** key: "files/my_cert.key" cert: "files/my_cert.crt" # Чтобы предотвратить проблему нехватки памяти задайте целочисленное значение трассировки memory_max_traces: 50000 # количество реплик для обеспечения высокой доступности replicaCount: 1 ... ``` -------------------------------- ### Шаблон onInit() Source: https://elma365.com/ru/help/platform/widget_functions.html Базовый шаблон функции onInit(). Вызывается при инициализации виджета, когда в контексте уже заполнены входные данные Context.data.*. В теле можно дополнить данные, обратиться к API или вызвать серверные функции. ```typescript async function onInit (): Promise { // Тело функции } ``` -------------------------------- ### Run the diagnostic script Source: https://elma365.com/ru/help/cortex/cortex-troubleshooting.html Navigate to the ELMA Cortex installation directory, set execute permissions on the diagnostic script on first run, and start the diagnostic collection. By default, logs from the last 30 days are collected. ```bash cd ~/elma-cortex ``` ```bash chmod +x ./diagnose.sh ``` ```bash ./diagnose.sh ``` -------------------------------- ### Create and open the new HAProxy configuration file Source: https://elma365.com/ru/help/platform/fail-safe-haproxy.html Opens /etc/haproxy/haproxy.cfg in the nano editor to replace the default with the custom configuration. ```bash sudo nano /etc/haproxy/haproxy.cfg ``` -------------------------------- ### Docker run command with OnlyOffice configuration flags Source: https://elma365.com/ru/help/platform/onlyoffice.html Example Docker command to start the OnlyOffice container with flags for private address and self-signed certificate support. Use 'ALLOW_PRIVATE_IP_ADDRESS=true' for private addresses, and 'USE_UNAUTHORIZED_STORAGE=true' and 'JWT_IN_BODY=true' for self-signed certificates. ```bash sudo docker run -i -t -d -p 443:443 --restart=always \ … -e ALLOW_PRIVATE_IP_ADDRESS=true \ -e USE_UNAUTHORIZED_STORAGE=true \ -e JWT_IN_BODY=true onlyoffice/documentserver:8.3.3.1 ``` -------------------------------- ### onInit(): заполнение таблицы users Source: https://elma365.com/ru/help/platform/widget_functions.html Пример использования onInit() для заполнения таблицы users данными пользователей (ФИО и дата рождения). Требует переменную users типа Таблица с полями name и birthDate типа Строка. Использует System.users.search() с сортировкой и ограничением 100 записей. ```typescript async function onInit (): Promise { const users = await System.users.search().size(100).sort('__name', true).all(); for (const user of users) { let item = Context.data.users!.insert(); item.name = user.data.__name; item.birthDate = user.data.birthDate ? user.data.birthDate.format('L') : ''; } Context.data.users = Context.data.users; } ``` -------------------------------- ### onLoad() example: change button color Source: https://elma365.com/ru/help/crm/widget_functions.html Changes the background color and text color of a system button labeled 'Назначить' on a process start event form. The button is found by its class and text, then styled with green background and white text. ```typescript async function onLoad (): Promise { const processButton: any = Array.from(document.querySelectorAll('button.btn.btn-primary')).find((btn: any) => btn.innerText.includes('Назначить')); processButton.style.backgroundColor = '#28a745'; processButton.style.color = '#ffffff'; } ``` -------------------------------- ### Скрипт onInit для сохранения данных пользователя в переменную user_data Source: https://elma365.com/ru/help/crm/livechat-auto-login.html Код добавляется в функцию onInit() на вкладке Скрипты. Сохраняет данные текущего пользователя в переменную user_data в формате строки JSON. Использует константу HASH_KEY, которую необходимо заменить на реальный ключ. ```javascript const user = await System.users.getCurrentUser(); const HASH_KEY = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'; Context.data.user_data = JSON.stringify({ id: user.data.__id, hash: HASH_KEY, name: user.data.__name, email: user.data.email ?? ' ', phone: user.data.phone ?? ' ' }); ``` -------------------------------- ### Install elma365-dbs Helm chart Source: https://elma365.com/ru/help/platform/embedded-databases-settings.html Install the elma365-dbs Helm chart into the elma365-dbs namespace. The first command installs from the internet; the second installs offline from a local chart directory. ```bash helm upgrade --install elma365-dbs elma365/elma365-dbs -f values-elma365-dbs.yaml -n elma365-dbs --create-namespace ``` ```bash helm upgrade --install elma365-dbs ./elma365-dbs -f values-elma365-dbs.yaml -n elma365-dbs --create-namespace ``` -------------------------------- ### Install Patroni and dependencies Source: https://elma365.com/ru/help/configure-postgresql.html Install Patroni and its dependencies on all cluster nodes. The first command installs Patroni and required system packages; the second installs Python dependencies for Patroni. ```bash sudo apt-get install python3-pip python3-dev libpq-dev -y sudo apt-get install patroni -y ``` ```bash pip3 install psycopg2-binary pip3 install wheel pip3 install python-etcd ``` -------------------------------- ### Start MinIO service on each node Source: https://elma365.com/ru/help/platform/minio-cluster.html Run these commands on each node to start the MinIO service. The commands reload the systemd daemon, enable the service to start on boot, and start it immediately. ```bash sudo systemctl daemon-reload sudo systemctl enable minio.service sudo systemctl start minio.service ``` -------------------------------- ### Create keyfile Source: https://elma365.com/ru/help/platform/mongodb.html Generate a keyfile for authentication and set appropriate permissions and ownership. ```bash openssl rand -base64 756 > /var/lib/mongodb/keyfile chmod 400 /var/lib/mongodb/keyfile chown mongodb:mongodb /var/lib/mongodb/keyfile ``` -------------------------------- ### Install Vault with Helm Source: https://elma365.com/ru/help/platform/install-vault.html Install Vault into the 'vault' namespace. The first command installs from the internet; the second installs from a local directory when there is no internet access. The namespace is created automatically if it does not exist. ```bash helm upgrade --install vault elma365/vault -f values-vault.yaml -n vault --create-namespace ``` ```bash helm upgrade --install vault ./vault -f values-vault.yaml -n vault --create-namespace ``` -------------------------------- ### Initialize Certificate Folder Source: https://elma365.com/ru/help/cortex/cortex-tls-settings.html Initializes the certificate folder structure. ```bash ./manage-certs.sh init ``` -------------------------------- ### Install Valkey on Ubuntu Source: https://elma365.com/ru/help/platform/valkey.html Install the required packages for adding the ELMA365 repository and installing Valkey on Ubuntu 22.04/24.04. ```bash sudo apt install -y apt-transport-https ca-certificates curl sudo curl -fsSL https://repo.elma365.tech/deb/elma365-keyring.gpg | gpg --dearmor > /etc/apt/trusted.gpg.d/elma365-keyring.gpg echo "deb [arch=amd64] https://repo.elma365.tech/deb $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/elma365.list sudo apt update sudo apt install elma365-valkey-server ``` -------------------------------- ### Start ELMA365 Standard with elma365-docker.sh --start Source: https://elma365.com/ru/help/platform/embedded-to-external-database-standard.html Starts the ELMA365 Standard application after creating a backup or restoring data. ```bash sudo ./elma365-docker.sh --start ``` -------------------------------- ### MinIO environment configuration in /etc/default/minio Source: https://elma365.com/ru/help/platform/minio-cluster.html Example environment file for MinIO servers. Sets MINIO_VOLUMES with expansion notation for four hosts and drives, MINIO_OPTS for console address and certs directory, MINIO_REGION, root credentials, and an optional MINIO_SERVER_URL. The root user has unrestricted permissions; use a long random password. The server URL must match across all servers or use one host temporarily. ```bash MINIO_VOLUMES="http://minio-server{1...4}.your_domain:9000/var/lib/minio/data{1...4}/minio" MINIO_OPTS="--certs-dir /etc/minio/certs --console-address :9001" MINIO_REGION="ru-central-1" MINIO_ROOT_USER=elma365user MINIO_ROOT_PASSWORD=SecretPassword # MINIO_SERVER_URL="https://minio.example:9000" ``` -------------------------------- ### Example pgbouncer.ini configuration Source: https://elma365.com/ru/help/platform/pgbouncer-installation.html Example configuration for /etc/pgbouncer/pgbouncer.ini. Defines database routing and pool settings. Key parameters: listen_addr, listen_port, pool_mode, auth_type, max_client_conn, default_pool_size, reserve_pool_size, max_db_connections. ```ini [databases] postgres = host=127.0.0.1 port=5432 dbname=elma365 * = host=127.0.0.1 port=5432 [pgbouncer] logfile = /**var** /log/postgresql/pgbouncer.log pidfile = /**var** /run/postgresql/pgbouncer.pid listen_addr = * listen_port = 6432 unix_socket_dir = /**var** /run/postgresql auth_type = md5 auth_file = /etc/pgbouncer/userlist.txt admin_users = postgres ignore_startup_parameters = extra_float_digits,geqo pool_mode = session server_reset_query = DISCARD ALL max_client_conn = 10000 default_pool_size = 800 reserve_pool_size = 150 reserve_pool_timeout = 1 max_db_connections = 1000 pkt_buf = 8192 listen_backlog = 4096 log_connections = 0 log_disconnections = 0 ``` -------------------------------- ### Install keepalived Source: https://elma365.com/ru/help/platform/fail-safe-haproxy.html Install keepalived on all nodes. ```bash sudo apt update sudo apt install keepalived ``` -------------------------------- ### Применение обновления: запуск install.sh Source: https://elma365.com/ru/help/cortex/update-cortex-docker-swarm.html Переходит в папку с установочными файлами и запускает скрипт установки. Скрипт загрузит новые Docker-образы и перезапустит сервисы с обновлённой версией. ```bash cd ~/elma-cortex/docker-swarm ./install.sh ``` -------------------------------- ### Install Jaeger chart with Helm (offline) Source: https://elma365.com/ru/help/platform/installation-jaeger.html Installs or upgrades the Jaeger Helm chart from a local directory (offline installation) in the monitoring namespace. ```bash helm upgrade --install jaeger ./jaeger -f values-jaeger.yaml -n monitoring ``` -------------------------------- ### Start ELMA365 Standard after restore (source typo) Source: https://elma365.com/ru/help/platform/embedded-to-external-database-standard.html Starts the ELMA365 Standard application after restoring data. Note the missing space before --start in the source. ```bash sudo ./elma365-docker.sh--start ``` -------------------------------- ### Install kubernetes-event-exporter via Helm (online) Source: https://elma365.com/ru/help/platform/event-monitoring.html Installs or upgrades the kubernetes-event-exporter chart in the monitoring namespace using the downloaded configuration file. Requires internet access to fetch the chart. ```bash helm upgrade --install -n monitoring kubernetes-event-exporter elma365/kubernetes-event-exporter -f values-kubernetes-event-exporter.yaml ``` -------------------------------- ### Install SeaweedFS Client (mc) Source: https://elma365.com/ru/help/platform/seaweedfs.html Downloads the latest stable SeaweedFS Client binary and installs it to /usr/local/bin/. Note the typo in the source: 'chmod +x mс' uses a Cyrillic 'с'. ```bash wget https://dl.min.io/client/mc/release/linux-amd64/mc chmod +x mс sudo mv mc /usr/local/bin/ ```