diff --git a/example/grafana/docker-compose.yaml b/example/grafana/docker-compose.yaml new file mode 100644 index 0000000..3242530 --- /dev/null +++ b/example/grafana/docker-compose.yaml @@ -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 diff --git a/example/grafana/loki/etc/local-config.yaml b/example/grafana/loki/etc/local-config.yaml new file mode 100644 index 0000000..9f40a00 --- /dev/null +++ b/example/grafana/loki/etc/local-config.yaml @@ -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 diff --git a/example/grafana/tempo/tempo-local.yaml b/example/grafana/tempo/tempo-local.yaml new file mode 100644 index 0000000..064b163 --- /dev/null +++ b/example/grafana/tempo/tempo-local.yaml @@ -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