-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(scaffold): provide script about filebeat
- Loading branch information
Showing
3 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
filebeat.inputs: | ||
- type: log | ||
paths: | ||
- /var/logs/*.log | ||
multiline: | ||
pattern: ^\d{4} | ||
negate: true | ||
match: after | ||
tail_files: true | ||
fields: | ||
app_id: ${artifactId} | ||
pattern_type: java | ||
env: <%= "{{elk_env}}" %> # 应用部署环境,方便多环境共用elk时区分(根据实际情况也可以考虑去掉这个字段) | ||
|
||
output.logstash: | ||
hosts: ["<%= "{{elk_logstash}}" %>"] # logstash地址 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
cd `dirname $0` | ||
|
||
# 必填部署变量 | ||
# elk_env="local" | ||
# elk_logstash="47.92.70.95:5044" | ||
|
||
img_fb='docker.elastic.co/beats/filebeat:7.0.0' | ||
|
||
source ./common.sh | ||
|
||
h1 '准备启动filebeat['$img_fb']' | ||
|
||
h2 '修改filebeat.yml配置' | ||
|
||
git checkout -- filebeat.yml | ||
<%= "sed -i '' s/{{elk_env}}/$elk_env/ filebeat.yml" %> | ||
<%= "sed -i '' s/{{elk_logstash}}/$elk_logstash/ filebeat.yml" %> | ||
|
||
h2 '准备启动容器' | ||
|
||
info '删除已存在的容器' | ||
docker rm -f fb-${artifactId} | ||
|
||
info '准备启动Docker容器' | ||
docker run -d \ | ||
--name fb-${artifactId} \ | ||
-v $PWD/filebeat.yml:/usr/share/filebeat/filebeat.yml \ | ||
-v $PWD/logs/:/var/logs/ \ | ||
$img_fb | ||
|