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

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