Grafana+loki+promtail入门级部署分布式日志系统

概念:

Grafana:用于图形展示。

    grafana 是一款采用 go 语言编写的开源应用,主要用于大规模指标数据的可视化展现,是网络架构和应用分析中最流行的时序数据展示工具,目前已经支持绝大部分常用的时序数据库。(http://docs.grafana.org/

Loki:是主服务器,负责存储日志和处理查询。grafana支持的时序数据库中的一种。除此之外还支持SqlServer、mysql等多种关系型数据库。

Promtail :是代理。负责收集日志并将其发送给loki。

安装:

本次演示windows服务器本地安装。

Grafana

  下载地址:https://grafana.com/grafana/download?platform=windows

  下载后傻瓜式安装即可,安装完毕后访问:http://localhost:3000/即可。

Loki

  下载地址:https://github.com/grafana/loki/releases

  安装说明:https://grafana.com/docs/loki/latest/installation/local/

  下载release后解压到文件夹,得到一个EXE文件,然后exe文件同目录下添加loki-config.yaml文件,内容如下:

auth_enabled: false

server:
  http_listen_port: 3100

ingester:
  lifecycler:
    address: 127.0.0.1
    ring:
      kvstore:
        store: inmemory
      replication_factor: 1
    final_sleep: 0s
  chunk_idle_period: 5m
  chunk_retain_period: 30s
  max_transfer_retries: 0

schema_config:
  configs:
    - from: 2020-06-22
      store: boltdb
      object_store: filesystem
      schema: v11
      index:
        prefix: index_
        period: 168h

storage_config:
  boltdb:
    directory: /tmp/loki/index

  filesystem:
    directory: /tmp/loki/chunks

limits_config:
  enforce_metric_name: false
  reject_old_samples: true
  reject_old_samples_max_age: 168h

chunk_store_config:
  max_look_back_period: 0s

table_manager:
  retention_deletes_enabled: false
  retention_period: 0s
View Code

  打开cmd定位到exe目录,执行命令:loki-windows-amd64.exe --config.file=loki-config.yaml,loki服务启动成功。

Promtail

  下载地址:https://github.com/grafana/loki/releases

  安装说明:https://grafana.com/docs/loki/latest/clients/promtail/installation/

  下载release文件包后解压,得到一个EXE文件,然后exe文件同目录下添加promtail-config.yaml文件,内容参考如下(jobname可以配置多个):

server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /tmp/positions.yaml

clients:
  - url: http://localhost:3100/loki/api/v1/push

scrape_configs:
- job_name: system
  static_configs:
  - targets:
      - localhost
    labels:
      job: viplogs
      __path__: D:\01Project\MicroService\TestCommon\bin\Debug\Logs\*.log
- job_name: system
  static_configs:
  - targets:
      - localhost
    labels:
      job: viplogs
      __path__: D:\01Project\MicroService\TestCommon\bin\Debug\Logs\*.log
View Code

  打开cmd定位到exe目录,执行命令:promtail-windows-amd64.exe --config.file=promtail-config.yaml,loki服务启动成功。

使用:

配置数据源和浏览数据,网上很多说明,可以参考这个:https://blog.csdn.net/qq_23598037/article/details/99850396

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章