loki安装配置
/lib/systemd/system/loki.service
[Unit] Description=loki After=syslog.target network.target [Service] Type=simple WorkingDirectory=/opt/loki/ ExecStart=/opt/loki/loki --config.file=loki-config.yaml ExecStop=/bin/kill -9 $MAINPID User=root Group=root UMask=0007 RestartSec=10 Restart=always [Install] WantedBy=multi-user.target
loki-config.yaml

auth_enabled: false server: http_listen_port: 3100 grpc_listen_port: 0 common: instance_addr: 10.22.32.2 path_prefix: /opt/loki/data storage: filesystem: chunks_directory: /opt/loki/data/chunks rules_directory: /opt/loki/data/rules replication_factor: 1 ring: kvstore: store: inmemory query_range: results_cache: cache: embedded_cache: enabled: true max_size_mb: 100 schema_config: configs: - from: 2020-10-24 store: tsdb object_store: filesystem schema: v13 index: prefix: index_ period: 24h storage_config: # New tsdb-shipper configuration tsdb_shipper: active_index_directory: /opt//loki/tsdb/tsdb-index cache_location: /opt/loki/tsdb/tsdb-cache query_scheduler: # the TSDB index dispatches many more, but each individually smaller, requests. # We increase the pending request queue sizes to compensate. max_outstanding_requests_per_tenant: 32768 limits_config: max_query_lookback: 672h # 28 days retention_period: 672h # 28 days per_stream_rate_limit: 5M # setting per_stream_rate_limit no higher than 5MB, and per_stream_rate_limit_burst no higher than 20MB per_stream_rate_limit_burst: 20M #max_active_streams: 50000 max_streams_per_user: 50000 ingestion_rate_mb: 80 ingestion_burst_size_mb: 256 compactor: working_directory: /opt/loki/data/retention delete_request_store: filesystem retention_enabled: true querier: max_concurrent: 16 ruler: alertmanager_url: http://localhost:9093 frontend: encoding: protobuf max_outstanding_per_tenant: 4096 compress_responses: true
docker pull grafana/promtail:3.0.0
#!/bin/bash logdir=/opt/logs docker run --restart=always -d -v /opt/promtail/config:/mnt/config -v ${logdir}:/var/log grafana/promtail:3.0.0 --config.file=/mnt/config/promtail-local-config.yaml
promtail-local-config.yaml

server: http_listen_port: 9080 grpc_listen_port: 0 positions: filename: /opt/promtail-positions.yaml clients: - url: http://10.22.32.2:3100/loki/api/v1/push scrape_configs: - job_name: openresty decompression: enabled: true initial_delay: 10s format: gz static_configs: - targets: - localhost labels: job: applog host: 10.16.2.19 __path__: /var/log/*.log pipeline_stages: - regex: # expression: '^((?P<ip>\\S+) - - \\[(?P<timestamp>.+?)\\] "(?P<method>\\S+) (?P<request>.+?) HTTP/(?P<version>\\S+)" (?P<status>\\d+) (?P<size>\\d+) "(?P<referer>.*)" "(?P<useragent>.*)" "(?P<request_id>.*)" (?P<response_time>\\S+))' expression: '^(?P<ip>\S+) - - \[(?P<timestamp>.*?)\] "(?P<method>\S+) (?P<request>.+?) HTTP/(?P<version>\S+)" (?P<status>\d+) (?P<size>\d+) "(?P<referer>.*?)" "(?P<useragent>[^"]+)" "(?P<request_id>.*?)" (?P<response_time>\S+)' - labels: ip: status: method:
配置loki数据源,可以直接在expoler设置查看
坚持到无能为力,拼搏到感动自己
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?