Skip to content

Commit

Permalink
📝 loki,tempo,grafana examples
Browse files Browse the repository at this point in the history
  • Loading branch information
itmisx committed Aug 30, 2022
1 parent 4ede3c2 commit d3e40c6
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 0 deletions.
75 changes: 75 additions & 0 deletions example/grafana/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
version: "3"
# logging模板
x-logging: &tpl-logging
driver: loki
options:
loki-url: "http://localhost:31000/loki/api/v1/push"
services:
# loki 日志搜集
loki:
image: grafana/loki:2.4.1
container_name: grafana_loki
depends_on:
- tempo
ports:
- "31000:3100"
volumes:
- ./loki/etc:/etc/loki
#environment:
#- JAEGER_AGENT_HOST=tempo
#- JAEGER_ENDPOINT=http://tempo:14268/api/traces # send traces to Tempo
#- JAEGER_SAMPLER_TYPE=const
#- JAEGER_SAMPLER_PARAM=1
networks:
- grafana
restart: "always"
logging:
driver: json-file
options:
max-size: "200k" # 单个文件大小为200k
max-file: "10" # 最多10个文件

# promtail 日志搜集
promtail:
image: grafana/promtail:2.4.1
container_name: grafana_promtail
networks:
- grafana
restart: "always"
logging: *tpl-logging

# tempo 日志追踪
tempo:
image: grafana/tempo:1.4.1
command: ["-config.file=/etc/tempo.yaml"]
container_name: grafana_tempo
volumes:
- ./tempo/tempo-local.yaml:/etc/tempo.yaml
#- ./tempo/data:/tmp/tempo
ports:
- "14268:14268" # jaeger ingest
- "3200:3200" # tempo
- "55680" # otlp grpc
- "55681" # otlp http
- "9411" # zipkin
restart: "always"
networks:
- grafana
logging: *tpl-logging

# grafana 界面查看
grafana:
image: grafana/grafana:8.2.6
container_name: grafana
ports:
- "30000:3000"
volumes:
- ./grafana/data:/var/lib/grafana
- ./grafana/conf:/usr/share/grafana/conf
networks:
- grafana
restart: "always"
logging: *tpl-logging
networks:
grafana:
external: true
42 changes: 42 additions & 0 deletions example/grafana/loki/etc/local-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
auth_enabled: false

server:
http_listen_port: 3100

common:
path_prefix: /loki
storage:
filesystem:
chunks_directory: /loki/chunks
rules_directory: /loki/rules
replication_factor: 1
ring:
instance_addr: 127.0.0.1
kvstore:
store: inmemory

schema_config:
configs:
- from: 2020-10-24
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 24h

ruler:
alertmanager_url: http://localhost:9093
storage_config:
boltdb:
directory: /tmp/loki/index
filesystem:
directory: /tmp/loki/chunks
limits_config:
enforce_metric_name: false
reject_old_samples: true
reject_old_samples_max_age: 168h
# 表的保留期7天
table_manager:
retention_deletes_enabled: true
retention_period: 168h
44 changes: 44 additions & 0 deletions example/grafana/tempo/tempo-local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
server:
http_listen_port: 3200
distributor:
receivers: # this configuration will listen on all ports and protocols that tempo is capable of.
jaeger: # the receives all come from the OpenTelemetry collector. more configuration information can
protocols: # be found there: https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver
thrift_http: #
grpc: # for a production deployment you should only enable the receivers you need!
thrift_binary:
thrift_compact:
zipkin:
otlp:
protocols:
http:
grpc:
opencensus:

ingester:
trace_idle_period: 5s # the length of time after a trace has not received spans to consider it complete and flush it
max_block_bytes: 1073741824 # cut the head block when it hits this size or ...
max_block_duration: 1h # this much time passes

compactor:
compaction:
compaction_window: 1h # blocks in this time window will be compacted together
max_block_bytes: 100000000 # maximum size of compacted blocks
block_retention: 168h
compacted_block_retention: 1h

storage:
trace:
backend: local # backend configuration to use
block:
bloom_filter_false_positive: .05 # bloom filter false positive rate. lower values create larger filters but fewer false positives
index_downsample_bytes: 1000 # number of bytes per index record
encoding: zstd # block encoding/compression. options: none, gzip, lz4-64k, lz4-256k, lz4-1M, lz4, snappy, zstd, s2
wal:
path: /tmp/tempo/wal # where to store the the wal locally
encoding: snappy # wal encoding/compression. options: none, gzip, lz4-64k, lz4-256k, lz4-1M, lz4, snappy, zstd, s2
local:
path: /tmp/tempo/blocks
pool:
max_workers: 100 # worker pool determines the number of parallel requests to the object store backend
queue_depth: 10000

0 comments on commit d3e40c6

Please sign in to comment.