Grafna +Loki +Promtail GLP日志可视化企业级实战( 五 )


配置优化 file 动态发现机制
修改配置而不需要重启,基于文件的服务发现提供了一种更通用的方式来配置静态目标 。它读取一组包含零个或多个列表的文件 。对所有定义文件的改变通过监视磁盘变化来应用 。文件可以以 YAML 或 JSON 格式提供 。JSON 文件必须包含一个静态配置的列表,使用这种格式 。
启动
systemctl start promtail
参考
https://grafana.com/docs/loki/latest/clients/promtail/configuration/
【3】接入qms ap log 和nginx日志 1、安装 2、准备接入nginx和qms的配置只需要修改配置文件
适用于其他ap log
#==============================================================## File:promtail.yml# Ctime:2022-10-03# Mtime:2022-10-13# Desc:Promtail logging collector agent# Path:/etc/promtail.yml# Copyright (C) 2018-2022 ninesun#==============================================================#server:http_listen_port: 9080grpc_listen_port: 9097positions:# location of position status filefilename: ${PROMTAIL_POSITIONS:/var/log/positions.yaml}sync_period: 10s# How often to update the positions fileignore_invalid_yaml: true# Whether to ignore & later overwrite positions files that are corruptedclients:- url: http://10.50.10.25:3100/loki/api/v1/pushexternal_labels:ip:10.50.10.209cls: qms-clsins: qms1scrape_configs:#################################################################Nodes Logs################################################################## collect /var/log/messages dmesg cron logs on all nodes- job_name: nodesstatic_configs:- targets:- localhostlabels:src: syslogjob: nodes__path__: /var/log/messages- targets:- localhostlabels:src: crontabjob: nodes__path__: /var/log/cron- targets:- localhostlabels:src: dmesgjob: nodes__path__: /var/log/dmesg#################################################################infra Log################################################################## collect nginx & qms ap logs on 209 nodes- job_name: infrastatic_configs:- targets:- localhostlabels:src: nginx-accessjob: infra__path__: /usr/local/nginx/logs/access.log- targets:- localhostlabels:src: nginx-errorjob: infra__path__: /usr/local/nginx/logs/error.log- targets:- localhostlabels:src: 209-8086-infojob: infra__path__: /aplog/qms/8086/info.log- targets:- localhostlabels:src: 209-8086-errorjob: infra__path__: /aplog/qms/8086/error.log- targets:- localhostlabels:src: 209-8087-infojob: infra__path__: /aplog/qms/8087/info.log- targets:- localhostlabels:src: 209-8087-errorjob: infra__path__: /aplog/qms/8087/error.log# 204#==============================================================## File:promtail.yml# Ctime:2022-10-03# Mtime:2022-10-14# Desc:Promtail logging collector agent# Path:/etc/promtail.yml# Copyright (C) 2018-2022 ninesun#==============================================================#server: