Add Kibana component for Elasticsearch (#1710)

### What problem does this PR solve?
Add Kibana component for Elasticsearch

### Type of change

- [ ] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)

---------

Co-authored-by: Theta Wang (ncu) <chunshan.connect@gmail.com>
This commit is contained in:
Wang 2024-07-26 10:34:35 +08:00 committed by GitHub
parent 3f495b2d22
commit 548f01850f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 72 additions and 2 deletions

View File

@ -10,6 +10,8 @@ ELASTIC_PASSWORD=infini_rag_flow
# Port to expose Kibana to the host
KIBANA_PORT=6601
KIBANA_USER=rag_flow
KIBANA_PASSWORD=infini_rag_flow
# Increase or decrease based on the available host memory (in bytes)

View File

@ -0,0 +1,33 @@
services:
kibana:
image: kibana:${STACK_VERSION}
container_name: ragflow-kibana
environment:
ELASTICSEARCH_USERNAME: ${KIBANA_USER}
ELASTICSEARCH_PASSWORD: ${KIBANA_PASSWORD}
ELASTICSEARCH_HOSTS: "http://es01:9200"
ports:
- ${KIBANA_PORT}:5601
depends_on:
es01:
condition: service_healthy
kibana-user-init:
condition: service_completed_successfully
networks:
- ragflow
kibana-user-init:
image: appropriate/curl
depends_on:
es01:
condition: service_healthy
volumes:
- ./init-kibana.sh:/app/init-kibana.sh
environment:
- ELASTIC_PASSWORD=${ELASTIC_PASSWORD}
- KIBANA_USER=${KIBANA_USER}
- KIBANA_PASSWORD=${KIBANA_PASSWORD}
command: /bin/sh -c "sh /app/init-kibana.sh"
networks:
- ragflow
restart: 'no'

View File

@ -1,7 +1,8 @@
include:
- path: ./docker-compose-base.yml
env_file: ./.env
- path: ./docker-compose-admin-tool.yml
env_file: ./.env
services:
ragflow:
depends_on:
@ -27,4 +28,4 @@ services:
- MACOS=${MACOS}
networks:
- ragflow
restart: always
restart: always

30
docker/init-kibana.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
# 等待 Elasticsearch 啟動
until curl -u "elastic:${ELASTIC_PASSWORD}" -s http://es01:9200 >/dev/null; do
echo "等待 Elasticsearch 啟動..."
sleep 5
done
echo "使用者: elastic:${ELASTIC_PASSWORD}"
PAYLOAD="{
\"password\" : \"${KIBANA_PASSWORD}\",
\"roles\" : [ \"kibana_admin\",\"kibana_system\" ],
\"full_name\" : \"${KIBANA_USER}\",
\"email\" : \"${KIBANA_USER}@example.com\"
}"
echo "新用戶帳戶: $PAYLOAD"
# 創建新用戶帳戶
curl -X POST "http://es01:9200/_security/user/${KIBANA_USER}" \
-u "elastic:${ELASTIC_PASSWORD}" \
-H "Content-Type: application/json" \
-d "$PAYLOAD"s
echo "新用戶帳戶已創建"
exit 0

View File

@ -17,6 +17,10 @@ es:
hosts: 'http://es01:9200'
username: 'elastic'
password: 'infini_rag_flow'
kibana:
hosts: 'http://${host}:6601'
username: 'rag_flow'
password: 'infini_rag_flow'
redis:
db: 1
password: 'infini_rag_flow'