mirror of
https://gitea.bearcatlog.com/Bryant/chassis-agent
synced 2025-01-18 18:13:12 +08:00
添加 elk
This commit is contained in:
parent
22424e2b81
commit
fe7b5bd14f
@ -6,12 +6,12 @@ chassis 微服务基座依赖的服务
|
||||
- Metrics
|
||||
- Statsd
|
||||
- Statsd-exporter
|
||||
- Logging
|
||||
- 整合 ELK
|
||||
|
||||
TODO:
|
||||
- Metrics
|
||||
- 整合 Prometheus
|
||||
- 整合 Grafana
|
||||
- Logging
|
||||
- 整合 ELK
|
||||
- Error Reporting
|
||||
- 整合 Sentry
|
43
docker-compose-logging.yml
Normal file
43
docker-compose-logging.yml
Normal file
@ -0,0 +1,43 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
kibana:
|
||||
image: kibana:8.7.1
|
||||
ports:
|
||||
- "5610:5601"
|
||||
networks:
|
||||
chassis_agent_logging:
|
||||
links:
|
||||
- "elasticsearch"
|
||||
elasticsearch:
|
||||
image: elasticsearch:8.7.1
|
||||
hostname: "elasticsearch"
|
||||
environment:
|
||||
- "discovery.type=single-node" #单机模式启动
|
||||
- "TZ=Asia/Shanghai" # 设置时区
|
||||
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" # 设置jvm内存大小
|
||||
- "xpack.security.enabled=false"
|
||||
ports:
|
||||
- "9200:9200"
|
||||
expose:
|
||||
- 9200
|
||||
networks:
|
||||
chassis_agent_logging:
|
||||
fluentd:
|
||||
build:
|
||||
context: ./fluentd
|
||||
volumes:
|
||||
- ./fluentd/conf/fluent.conf:/opt/bitnami/fluentd/conf/fluentd.conf
|
||||
links:
|
||||
- "elasticsearch"
|
||||
ports:
|
||||
- "24224:24224"
|
||||
- "24224:24224/udp"
|
||||
networks:
|
||||
chassis_agent_logging:
|
||||
|
||||
networks:
|
||||
chassis_agent_logging:
|
||||
driver: bridge
|
||||
|
||||
|
@ -10,7 +10,7 @@ services:
|
||||
volumes:
|
||||
- "./statsd_config.js:/usr/src/app/config.js"
|
||||
networks:
|
||||
chassis_agent:
|
||||
chassis_agent_metrics:
|
||||
statsd-exporter:
|
||||
image: prom/statsd-exporter:latest
|
||||
hostname: "statsd-exporter"
|
||||
@ -21,10 +21,10 @@ services:
|
||||
volumes:
|
||||
- "./statsd_mapping.yml:/tmp/statsd_mapping.yml"
|
||||
networks:
|
||||
chassis_agent:
|
||||
chassis_agent_metrics:
|
||||
|
||||
networks:
|
||||
chassis_agent:
|
||||
chassis_agent_metrics:
|
||||
driver: bridge
|
||||
|
||||
|
12
fluentd/Dockerfile
Normal file
12
fluentd/Dockerfile
Normal file
@ -0,0 +1,12 @@
|
||||
# fluentd/Dockerfile
|
||||
FROM bitnami/fluentd:1.16.1-debian-11-r13
|
||||
USER root
|
||||
RUN ["gem", "sources", "--remove", "https://rubygems.org/"]
|
||||
RUN ["gem", "sources", "--add", "https://gems.ruby-china.com/"]
|
||||
RUN ["gem", "sources", "-u"]
|
||||
RUN ["gem", "install", "fluent-plugin-elasticsearch", "--version", "5.3.0"]
|
||||
RUN ["gem", "install", "fluent-plugin-typecast", "--version", "0.2.0"]
|
||||
|
||||
|
||||
|
||||
|
31
fluentd/conf/fluent.conf
Normal file
31
fluentd/conf/fluent.conf
Normal file
@ -0,0 +1,31 @@
|
||||
# fluentd/conf/fluent.conf
|
||||
<source>
|
||||
@type forward # source表示日志源来自转发,forward与http是默认安装的组件,不需要额外的插件支持。
|
||||
port 24224 # 在24224端口启动forward接收转发
|
||||
bind 0.0.0.0 # 允许接收任意IP的转发
|
||||
</source>
|
||||
|
||||
<match *.**>
|
||||
@type copy
|
||||
<store>
|
||||
@type elasticsearch # 转发日志到es,这需要安装es的插件
|
||||
host elasticsearch # es的配置信息
|
||||
port 9200
|
||||
index_name fluentd
|
||||
logstash_format true # 启动转发
|
||||
logstash_prefix fluentd-${tag} # 转发到es的索引名称
|
||||
logstash_dateformat %Y.%m # 按月来划分索引,可以删除无用数据
|
||||
include_tag_key true
|
||||
type_name application_log
|
||||
tag_key @log_name
|
||||
reconnect_on_error true
|
||||
reload_on_failure true
|
||||
reload_connections false
|
||||
<buffer>
|
||||
flush_interval 2s # 每2s刷新一次
|
||||
</buffer>
|
||||
</store>
|
||||
<store>
|
||||
@type stdout # 搜索到数据后立即转发到es
|
||||
</store>
|
||||
</match>
|
Loading…
Reference in New Issue
Block a user