当前位置: 首页 > news >正文

搭建grafana+loki+promtail日志收集系统

准备工作

下载地址

https://github.com/grafana/loki/releases

安装包放在服务器目录:/opt

wget https://github.com/grafana/loki/releases/download/v2.4.2/loki-linux-amd64.zip
wget https://github.com/grafana/loki/releases/download/v2.4.2/promtail-linux-amd64.zip

1、启动loki

1)解压loki-linux-amd64.zip

unzip loki-linux-amd64.zip 

2)授权

chmod a+x loki-linux-amd64

3)配置文件loki.yaml

vi loki.yamlauth_enabled: falseserver:http_listen_port: 3100grpc_listen_port: 3110grpc_server_max_recv_msg_size: 1073741824  #grpc最大接收消息值,默认4mgrpc_server_max_send_msg_size: 1073741824  #grpc最大发送消息值,默认4mingester:lifecycler:address: 127.0.0.1ring:kvstore:store: inmemoryreplication_factor: 1final_sleep: 0schunk_idle_period: 5mchunk_retain_period: 30smax_transfer_retries: 0max_chunk_age: 20m  #一个timeseries块在内存中的最大持续时间。如果timeseries运行的时间超过此时间,则当前块将刷新到存储并创建一个新块schema_config:configs:- from: 2021-01-01store: boltdbobject_store: filesystemschema: v11index:prefix: index_period: 168hstorage_config:boltdb:directory: /opt/loki/index #存储索引地址filesystem:directory: /opt/loki/chunkslimits_config:enforce_metric_name: falsereject_old_samples: truereject_old_samples_max_age: 168hingestion_rate_mb: 30  #修改每用户摄入速率限制,即每秒样本量,默认值为4Mingestion_burst_size_mb: 15  #修改每用户摄入速率限制,即每秒样本量,默认值为6Mchunk_store_config:#max_look_back_period: 168h   #回看日志行的最大时间,只适用于即时日志max_look_back_period: 0stable_manager:retention_deletes_enabled: false #日志保留周期开关,默认为falseretention_period: 0s  #日志保留周期

4)启动进程

nohup /opt/loki/loki-linux-amd64 -config.file=/opt/loki/loki.yaml >loki.out 2>&1 &

2、启动promtail

1)解压loki-linux-amd64.zip

unzip promtail-linux-amd64.zip

2)授权

chmod a+x promtail-linux-amd64

3)配置文件promtail.yaml

vi promtail.yamlserver:http_listen_port: 9080grpc_listen_port: 0grpc_server_max_recv_msg_size: 15728640grpc_server_max_send_msg_size: 15728640positions:filename: /opt/loki/positions.yaml # This location needs to be writeable by promtail.client:url: http://xx.xx.xx.xx:3100/loki/api/v1/push#https://grafana.com/docs/loki/latest/clients/promtail/configuration/
scrape_configs:
- job_name: systemstatic_configs:- targets:- localhostlabels:job: messages__path__: /var/log/messages
- job_name: systemstatic_configs:- targets:- localhostlabels:job: varlogs__path__: /var/log/*log
- job_name: systemstatic_configs:- targets:- localhostlabels:job: secure__path__: /var/log/secure
#lastlog
- job_name: systemstatic_configs:- targets:- localhostlabels:job: lastlog__path__: /var/log/lastlog
#cron
- job_name: systemstatic_configs:- targets:- localhostlabels:job: cron__path__: /var/log/cron

4)启动进程

nohup /opt/loki/promtail-linux-amd64 -config.file=/opt/loki/promtail.yaml >promtail.out 2>&1 &

3、启动grafana

1)安装

官网安装教程地址:Download Grafana | Grafana Labs

wget https://dl.grafana.com/oss/release/grafana-7.4.3-1.x86_64.rpm 
sudo yum install grafana-7.4.3-1.x86_64.rpm 

2)启动

systemctl start grafana-server

3)查看状态

systemctl status grafana-server

4、logcli

1)下载

wget https://github.com/grafana/loki/releases/download/v2.4.2/logcli-linux-amd64.zip

2)解压logcli-linux-amd64.zip

unzip logcli-linux-amd64.zip

3)授权

chmod a+x logcli-linux-amd64.zip

4)查看


{job="cron"} |~ "ERROR"!= "(python3)"

http://www.lryc.cn/news/124375.html

相关文章:

  • Electron+vue3项目使用SQLite3数据库
  • SpringSpringBoot常用注解
  • 题目:2566.替换一个数字后的最大差值
  • 使用 NLP 进行文本摘要
  • vue3挂载全局方法和组件
  • mybatisplus学习笔记
  • go mod 添加私有库GOPRIVATE
  • 07-HDFS入门及shell命令
  • TiDB在科捷物流神州金库核心系统的应用与实践
  • React 18 更新 state 中的数组
  • 【css】css中使用变量var
  • 判断自己网络所在的NAT类型
  • ClickHouse(十九):Clickhouse SQL DDL操作-1
  • 小程序保留2位小数据,不四舍五入
  • 【linux-nginx】nginx限流以及控制访问方法
  • 菜单和内容滚动的联动原理及代码
  • Python爬虫:单线程、多线程、多进程
  • 超强的Everything,吊打系统自带文件搜索功能!
  • flink配置参数
  • 学习Vue:安装Vue.js和设置开发环境
  • 代理技术在网络安全、爬虫和数据隐私中的多重应用
  • Python 3 使用Hadoop 3之MapReduce总结
  • KU Leuven TU Berlin 推出“RobBERT”,一款荷兰索塔 BERT
  • Postern中配置和使用Socks5代理指南
  • android 窗口级模糊实现方式
  • 面试热题(数组中的第K个最大元素)
  • HTTP2协议介绍
  • 矩阵的转置
  • web集群学习:nginx+keepalived实现负载均衡高可用性
  • MFC第二十九天 CView类的分支(以及其派生类的功能)、MFC六大关键技术