mirror of
https://gitee.com/kennylee/docker.git
synced 2024-11-29 10:29:07 +08:00
完成promtail抓取日志目录的例子,方便应用输出日志时获取pod-name的情况。
This commit is contained in:
parent
2cdab7741b
commit
3ce38baecf
@ -3,7 +3,7 @@ root = true
|
||||
[*.yml]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
@ -4,3 +4,10 @@
|
||||
* [Run Grafana Docker image](https://grafana.com/docs/grafana/latest/installation/docker/)
|
||||
* [Deploy Grafana on Kubernetes](https://grafana.com/docs/grafana/latest/installation/kubernetes/)
|
||||
|
||||
## 使用
|
||||
|
||||
初始化账号/密码 `admin/admin`
|
||||
|
||||
## 数据目录
|
||||
|
||||
`/var/lib/grafana/`
|
||||
|
@ -2,7 +2,7 @@ auth_enabled: false
|
||||
|
||||
server:
|
||||
http_listen_port: 3100
|
||||
grpc_listen_port: 9096
|
||||
grpc_listen_port: 9096 #grpc监听端口,默认为9095
|
||||
|
||||
ingester:
|
||||
wal:
|
||||
@ -16,7 +16,7 @@ ingester:
|
||||
replication_factor: 1
|
||||
final_sleep: 0s
|
||||
chunk_idle_period: 1h # Any chunk not receiving new logs in this time will be flushed
|
||||
max_chunk_age: 1h # All chunks will be flushed when they hit this age, default is 1h
|
||||
max_chunk_age: 1h # 一个timeseries块在内存中的最大持续时间。如果timeseries运行的时间超过此时间,则当前块将刷新到存储并创建一个新块, default is 1h
|
||||
chunk_target_size: 1048576 # Loki will attempt to build chunks up to 1.5MB, flushing first if chunk_idle_period or max_chunk_age is reached first
|
||||
chunk_retain_period: 30s # Must be greater than index read cache TTL if using an index cache (Default index read cache TTL is 5m)
|
||||
max_transfer_retries: 0 # Chunk transfers disabled
|
||||
@ -47,13 +47,15 @@ compactor:
|
||||
limits_config:
|
||||
reject_old_samples: true
|
||||
reject_old_samples_max_age: 168h
|
||||
ingestion_rate_mb: 4 #修改每用户摄入速率限制,即每秒样本量,默认值为4M
|
||||
ingestion_burst_size_mb: 6 #修改每用户摄入速率限制,即每秒样本量,默认值为6M
|
||||
|
||||
chunk_store_config:
|
||||
max_look_back_period: 0s
|
||||
max_look_back_period: 0s #回看日志行的最大时间,可参考 168h,即只看即时日志,可以减少存储消耗。
|
||||
|
||||
table_manager:
|
||||
retention_deletes_enabled: false
|
||||
retention_period: 0s
|
||||
retention_deletes_enabled: false #日志保留周期开关,默认为false
|
||||
retention_period: 0s #日志保留周期
|
||||
|
||||
ruler:
|
||||
storage:
|
||||
|
1
promtail/.env
Normal file
1
promtail/.env
Normal file
@ -0,0 +1 @@
|
||||
LOKI_ADDR=192.168.0.206
|
@ -6,12 +6,33 @@ positions:
|
||||
filename: /tmp/positions.yaml
|
||||
|
||||
clients:
|
||||
- url: http://192.168.1.96:30191/loki/api/v1/push
|
||||
- url: http://k8s.foo.com:30191/loki/api/v1/push
|
||||
|
||||
scrape_configs:
|
||||
- job_name: promtail-test-logs
|
||||
- job_name: test-nginx-logs
|
||||
static_configs:
|
||||
- labels:
|
||||
app: 'test-logs'
|
||||
job: 'test-nginx-logs'
|
||||
__path__: /tmp/logs/*.log
|
||||
|
||||
- job_name: test-app-logs
|
||||
static_configs:
|
||||
- labels:
|
||||
job: 'test-app-logs'
|
||||
__path__: /tmp/logs/app-*/*.log
|
||||
pipeline_stages:
|
||||
- match:
|
||||
selector: '{job="test-app-logs"}'
|
||||
stages:
|
||||
- regex:
|
||||
source: filename
|
||||
expression: '(?:logs)/(?P<pod_name>\S+?)/'
|
||||
- labels:
|
||||
pod_name:
|
||||
- match:
|
||||
selector: '{job="test-app-logs"}'
|
||||
stages:
|
||||
- regex:
|
||||
source: pod_name
|
||||
expression: '^(?P<pod_collection>.+)-[^-]+$'
|
||||
- labels:
|
||||
pod_collection:
|
@ -1,16 +1,20 @@
|
||||
version: '2.4'
|
||||
services:
|
||||
promtail:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/kennylee/promtail:2.2.1
|
||||
container_name: promtail
|
||||
restart: on-failure
|
||||
command: '-config.file=/promtail/config/promtail-config.yaml'
|
||||
volumes:
|
||||
- ./config:/promtail/config:z
|
||||
# 用于测试,读取的日志
|
||||
- ./logs:/tmp/logs
|
||||
logging:
|
||||
driver: 'json-file'
|
||||
options:
|
||||
max-size: '10m'
|
||||
max-file: '1'
|
||||
promtail:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/kennylee/promtail:2.2.1
|
||||
container_name: promtail
|
||||
restart: on-failure
|
||||
command: '-config.file=/promtail/config/promtail-config.yaml'
|
||||
ports:
|
||||
- 9080
|
||||
extra_hosts:
|
||||
- "k8s.foo.com:${LOKI_ADDR}"
|
||||
volumes:
|
||||
- ./config:/promtail/config:z
|
||||
# 用于测试,读取的日志
|
||||
- ./logs:/tmp/logs
|
||||
logging:
|
||||
driver: 'json-file'
|
||||
options:
|
||||
max-size: '10m'
|
||||
max-file: '1'
|
||||
|
3
promtail/logs/app-88944fdd8-8xrqc/app.log
Normal file
3
promtail/logs/app-88944fdd8-8xrqc/app.log
Normal file
@ -0,0 +1,3 @@
|
||||
2021-06-26 18:18:35.165 WARN [tksite-dev,e4838a12138a7943,e4838a12138a7943,true] 11 --- [http-nio-8080-exec-9] c.a.druid.pool.DruidAbstractDataSource : discard long time none received connection. , jdbcUrl : jdbc:mysql://db-mysql:3306/tksite?useUnicode=true&characterEncoding=UTF-8, version : 1.2.4, lastPacketReceivedIdleMillis : 1877901
|
||||
2021-06-24 00:54:19.438 ERROR [tksite-dev,,,] 11 --- [main] c.c.t.c.w.a.h.LoggingHealthIndicator : LoggingHealthIndicator hello: 1
|
||||
2021-06-26 17:33:39.045 INFO [tksite-dev,,,] 11 --- [main] io.lettuce.core.KqueueProvider : Starting without optional kqueue library
|
Loading…
Reference in New Issue
Block a user