Prometheus 主要面向的是metrics,可是loki 是log,這樣加上grafana 強大的可視化以及alert能力,
咱們能夠作好多事情,loki 的設計來源於Prometheus。git
loki 包含三個組件github
version: "3"
services:
loki:
image: grafana/loki:master
ports:
- "3100:3100"
volumes:
- $PWD:/etc/loki
command: -config.file=/etc/loki/loki-local-config.yaml
promtail:
image: grafana/promtail:make-images-static-26a87c9
volumes:
- $PWD:/etc/promtail
- ./log:/var/log
command:
-config.file=/etc/promtail/promtail-docker-config.yaml
grafana:
image: grafana/grafana:master
ports:
- "3000:3000"
environment:
GF_EXPLORE_ENABLED: "true"
auth_enabled: false
server:
http_listen_port: 3100
ingester:
lifecycler:
address: 127.0.0.1
ring:
store: inmemory
replication_factor: 1
schema_config:
configs:
- from: 0
store: boltdb
object_store: filesystem
schema: v9
index:
prefix: index_
period: 168h
storage_config:
boltdb:
directory: /tmp/loki/index
filesystem:
directory: /tmp/loki/chunks
promtail agent 配置docker
server:
http_listen_port: 0
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
client:
url: http://loki:3100/api/prom/push
scrape_configs:
- job_name: system
entry_parser: raw
static_configs:
- targets:
- localhost
labels:
job: varlogs
__path__: /var/log
一個包含log 的文件 log/app.infoapi
docker-compose up -d
loki 也是剛開源出來,後邊的發展還有待看,可是從使用上來講,仍是很不錯的,同時對於k8s 的支持很不錯,咱們能夠用來
方便的手機k8s pod 的日誌。。。。app
https://github.com/grafana/loki#getting-started
https://github.com/rongfengliang/grafana-loki-demo測試