其他分享
首页 > 其他分享> > 日志系统 - Garylog 一键部署

日志系统 - Garylog 一键部署

作者:互联网

使用Garylog收集日志

安装最新版本




在这里能找到最新的版本,我自己改了一个yml

安装V3 版本

# vim docker-compose.yml
version: '3'
services:
    # MongoDB: https://hub.docker.com/_/mongo/
    mongo:
      image: mongo:4.2
      networks:
        - graylog
    # Elasticsearch: https://www.elastic.co/guide/en/elasticsearch/reference/7.10/docker.html
    elasticsearch:
      image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2
      environment:
        - http.host=0.0.0.0
        - transport.host=localhost
        - network.host=0.0.0.0
        - "ES_JAVA_OPTS=-Dlog4j2.formatMsgNoLookups=true -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:4.2
      environment:
        # CHANGE ME (must be at least 16 characters)!
        - GRAYLOG_PASSWORD_SECRET=somepasswordpepper
        # Password: admin
        - GRAYLOG_ROOT_PASSWORD_SHA2=xxx
        - GRAYLOG_HTTP_EXTERNAL_URI=http://127.0.0.1:9000/
        - GRAYLOG_ROOT_TIMEZONE=Asia/Shanghai
      entrypoint: /usr/bin/tini -- wait-for-it elasticsearch:9200 --  /docker-entrypoint.sh
      networks:
        - graylog
      restart: always

  1. - GRAYLOG_ROOT_TIMEZONE=Asia/Shanghai 不设置会导致时区错误
  2. - GRAYLOG_ROOT_PASSWORD_SHA2=xxx 设置密码,密码sha256加密的自己加密一下就好

安装

  1. 装好 dockerdocker-compose
  2. 运行docker-compose up -d 自动会安装相应的东西

简易配置




除了title 其他不用改

http上传日志

简易封装上传

 * @param data
 */
const graylog = (data : LogModelReq) => {
  data.project = projectName
  return http.post<ApiResult<PageModelRes<WebSiteRes>>>({
    baseURL: 'http://localhost:12201',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    url: '/gelf',
    data: JSON.stringify(data)
  })
}

export const LogDebug = async (message : string) => {
  const s: LogModelReq = {
    level: 1,
    message: message
  }
  return graylog(s)
}


标签:http,一键,GRAYLOG,Garylog,graylog,elasticsearch,docker,data,日志
来源: https://www.cnblogs.com/xslx/p/15985121.html