运行logstash
# logstash
version: '3'
services:
logstash:
image: docker.elastic.co/logstash/logstash:8.12.0
container_name: logstash_server
restart: always
ports:
- 8065:8065
environment:
- LS_JAVA_OPTS=-Xmx1024m -Xms1024m
volumes:
- ./config/logstash.conf:/etc/logstash/conf.d/logstash.conf # 读取宿主机配置
entrypoint:
- logstash
- -f
- /etc/logstash/conf.d/logstash.conf
logging:
driver: "json-file"
options:
max-size: "200m"
max-file: "3"
logstash
运行后进入容器
# 安装logstash-output-loki插件
logstash-plugin install logstash-output-loki
修改logstash
配置
// logstash.conf
input {
tcp {
port=> 8065
codec => "json"
}
}
output {
loki{
url => "http://loki:3100/loki/api/v1/push"
}
}
重启logstash
运行loki
# loki
version: '3'
services:
loki:
image: grafana/loki
container_name: loki
restart: always
ports:
- "3100:3100"
command: -config.file=/etc/loki/local-config.yaml
运行grafana
version: '3'
services:
grafana:
image: grafana/grafana
container_name: grafana
hostname: grafana
restart: always
ports:
- "3000:3000"
进入grafana
,打开左侧菜单,点击Administration
点击Plugin
,搜索loki
进入选项后点击Add new data source
输入loki
地址,http://localhost:3100
配置成功
查询日志
左侧菜单,explore
,选择过滤条件后,Run query
进行查询
https://github.com/grafana/loki/issues/9755
https://grafana.com/docs/loki/latest/send-data/logstash/
https://github.com/grafana/loki/issues/2886
标签:输出,3100,grafana,loki,conf,logstash,restart From: https://www.cnblogs.com/akapril/p/18671428