私信  •  关注

bmikaili

bmikaili 最近创建的主题
bmikaili 最近回复了
6 年前
回复了 bmikaili 创建的主题 » 默认情况下放置ElasticSearch摄取管道

我们使用了类似于ozlevka的方法,在自定义elasticsearch图像的构建过程中运行一个脚本。

这是我们的剧本:

#!/bin/bash
# This script sets up the Elasticsearch docker instance with the correct pipelines and templates

baseUrl='localhost:9200'
contentType='Content-Type:application/json'

# filebeat
ingestUrl=$baseUrl'/_ingest/pipeline/our-pipeline?pretty'
payload='/usr/share/elasticsearch/config/our-pipeline.json'

/usr/share/elasticsearch/bin/elasticsearch -p /tmp/pid > /dev/null & 
# wait until Elasticsearch is up
# you can get logs if you change /dev/null to /dev/stderr
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -XPUT $ingestUrl -H$contentType -d@$payload)" != "200" ]]; do
    echo "Waiting for Elasticsearch to start and posting pipeline..."
    sleep 5
done

kill -SIGTERM $(cat /tmp/pid) 
rm /tmp/pid
echo -e "\n\n\nCompleted Elasticsearch Setup, refer to logs for details"