工具系列 | 分佈式日誌管理graylog 實戰

Graylog是一個開源的日誌聚合、分析、審計、展現和預警工具。功能上和ELK類似,但又比ELK要簡單,依靠着更加簡潔,高效,部署使用簡單的優勢很快受到許多人的青睞。

使用Docker安裝

官方文檔:https://docs.graylog.org/en/3.3/pages/installation/docker.html

1、配置文件 docker-compose.yml

version: '3'
services:
  # MongoDB: https://hub.docker.com/_/mongo/
  mongo:
    image: mongo:3
    networks:
      - graylog
  # Elasticsearch: https://www.elastic.co/guide/en/elasticsearch/reference/6.x/docker.html
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.8.10
    environment:
      - http.host=0.0.0.0
      - transport.host=localhost
      - network.host=0.0.0.0
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    deploy:
      resources:
        limits:
          memory: 1g
    networks:
      - graylog
  # Graylog: https://hub.docker.com/r/graylog/graylog/
  graylog:
    image: graylog/graylog:3.3
    environment:
      # CHANGE ME (must be at least 16 characters)!
      - GRAYLOG_PASSWORD_SECRET=somepasswordpepper
      # Password: admin
      - GRAYLOG_ROOT_PASSWORD_SHA2=8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
      # 訪問URL
      - GRAYLOG_HTTP_EXTERNAL_URI=http://127.0.0.1:9000/
      # 設置時區,不然會時間不對
      - GRAYLOG_ROOT_TIMEZONE=Asia/Shanghai
    networks:
      - graylog
    depends_on:
      - mongo
      - elasticsearch
    ports:
      # Graylog web interface and REST API
      - 9000:9000
      # Syslog TCP
      - 1514:1514
      # Syslog UDP
      - 1514:1514/udp
      # GELF TCP
      - 12201:12201
      # GELF UDP
      - 12201:12201/udp
networks:
  graylog:
    driver: bridge

2、運行啓動所有三個Docker容器

docker-compose up

在新窗口打開,查看容器進程

 

3、瀏覽器中打開http://127.0.0.1:9000/ ,賬戶密碼:admin/admin

 

 4、手動配置input

 

 5、通過CRUL發送日誌消息

$ curl -XPOST http://127.0.0.1:12201/gelf -p0 -d '{"message":"hello Tinywan222", "host":"127.0.0.1", "facility":"test", "topic": "meme"}'

$ curl -XPOST http://127.0.0.1:12201/gelf -p0 -d '{"message":"hello Tinywan 2020", "host":"127.0.0.1", "facility":"test", "topic": "meme"}'

6、打開控制檯,查看是否接受成功

 7、結束

  

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