Skip to content

Commit

Permalink
feat(scaffold): provide script about filebeat
Browse files Browse the repository at this point in the history
  • Loading branch information
taccisum committed Jul 10, 2019
1 parent 4c4a678 commit f83cbf7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ server:
include-stacktrace: always
include-exception: true
logging:
file: <%='${spring.application.name}.log'%>
file: <%='logs/${spring.application.name}.log'%>
16 changes: 16 additions & 0 deletions generators/app/templates/filebeat.tmpl.yml
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地址
32 changes: 32 additions & 0 deletions generators/app/templates/start-fb.tmpl.sh
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

0 comments on commit f83cbf7

Please sign in to comment.