promtail增加日志等级label

This commit is contained in:
KennyLee 2021-06-28 11:31:01 +08:00
parent 3ce38baecf
commit d90ff99866
5 changed files with 47 additions and 15 deletions

View File

@ -0,0 +1,22 @@
global:
scrape_interval: 15s # 设置抓取间隔默认为1分钟
evaluation_interval: 15s #估算规则的默认周期每15秒计算一次规则。默认1分钟
# scrape_timeout #默认抓取超时默认为10s
# Alertmanager相关配置
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# 规则文件列表,使用'evaluation_interval' 参数去抓取
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# 抓取配置列表
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: [ 'localhost:9090' ]

View File

@ -1,13 +1,14 @@
version: '2'
services:
prometheus:
image: registry.cn-hangzhou.aliyuncs.com/kennylee/prometheus:2.28.0
container_name: prometheus
restart: on-failure
volumes:
- ./data:/opt/bitnami/prometheus/data:z
logging:
driver: 'json-file'
options:
max-size: '10m'
max-file: '1'
prometheus:
image: registry.cn-hangzhou.aliyuncs.com/kennylee/prometheus:2.28.0
container_name: prometheus
restart: on-failure
volumes:
- ./data:/opt/bitnami/prometheus/data:z
- ./config/prometheus.yml:/opt/bitnami/prometheus/conf/prometheus.yml
logging:
driver: 'json-file'
options:
max-size: '10m'
max-file: '1'

View File

@ -1 +1,2 @@
LOKI_ADDR=192.168.0.206
#LOKI_ADDR=192.168.0.206
LOKI_ADDR=192.168.1.96

View File

@ -28,11 +28,18 @@ scrape_configs:
expression: '(?:logs)/(?P<pod_name>\S+?)/'
- labels:
pod_name:
- match:
- match: # for k8s Deployment Pods
selector: '{job="test-app-logs"}'
stages:
- regex:
source: pod_name
expression: '^(?P<pod_collection>.+)-[^-]+$'
- labels:
pod_collection:
pod_collection:
- match: # for SpringBoot log
selector: '{job="test-app-logs"}'
stages:
- regex:
expression: '^(?P<year_month>\S+?)-(?P<days>[\d]{1,2})\s+(?P<time>[0-9:.]+?)\s+(?P<level>[A-Z]+?)\s+'
- labels:
level:

View File

@ -1,3 +1,4 @@
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
2021-06-26 17:33:39.045 INFO [tksite-dev,,,] 11 --- [main] io.lettuce.core.KqueueProvider : Starting without optional kqueue library
2021-06-24 03:54:19.438 ERROR [tksite-dev,,,] 11 --- [main] c.c.t.c.w.a.h.LoggingHealthIndicator : Test Error