阿里云日志服务自定义配置-备忘

envoy-accesslog.yaml
 
apiVersion: log.alibabacloud.com/v1alpha1
kind: AliyunLogConfig
metadata:
  name: envoy-accesslog
spec:
  logstore: access-log
  lifeCycle: 30
  logtailConfig:
    inputType: plugin
    configName: envoy-accesslog
    inputDetail:
      plugin:
        inputs:
        - type: service_docker_stdout
          detail:
            Stdout: true
            Stderr: true
            IncludeEnv:
              ISTIO_META_USER_SDS: "true"
        processors:
        - type: processor_filter_regex
          detail:
            Exclude:
              content: '.*Using deprecated option.*'
        - type: processor_regex
          detail:
            SourceKey: content
            Regex: '\[([^\]]*)] "(\S+)\s+(\S+)\s+(\S+?)" (\S+) (\S+) "(\S+)" (\S+) (\S+) (\S+) (\S+) "(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|-).*?" "([^\"]*)" "([^\"]*)" "([^\"]*)" "([^\"]*)" (\S+) .*'
            Keys: ['time', 'method', 'path', 'protocol', 'response_code', 'response_flags', 'synamic_metadata', 'bytes_received', 'bytes_sent', 'duration', 'upstream_service_time', 'remote_addr', 'user_agent', 'request_id', 'host', 'downstream_address', 'requested_server_name']
            KeepSource: true
            NoKeyError: true
            NoMatchError: true
        - type: processor_filter_regex
          detail:
            Exclude:
              user_agent: 'kube-probe.*'


logtail-log4j.yaml
 
apiVersion: log.alibabacloud.com/v1alpha1
kind: AliyunLogConfig
metadata:
  name: nest-log4j
spec:
  logstore: k8s-application-log
  lifeCycle: 60
  logtailConfig:
    inputType: plugin
    configName: nest-log4j
    inputDetail:
      plugin:
        inputs:
        - type: service_docker_stdout
          detail:
            Stdout: true
            Stderr: true
            BeginLineCheckLength: 15
            BeginLineRegex: '\d{2}:\d{2}:\d{2},.*'
            IncludeEnv:
              LOGGER: 'nest-log4j'
            ExcludeLabel: 
              "io.kubernetes.container.name": "message-server"
        processors:
        - type: processor_regex
          detail:
            SourceKey: content
            Regex: '(\d{2}:\d{2}:\d{2},\d{1,3})\s+(\w+)\s(.+?):(\d+)\s-\s(.*)'
            Keys: ['time', 'level', 'class', 'line', 'message']
            KeepSource: true
            NoKeyError: true
            NoMatchError: true


logtail-log4j-message-server.yaml

apiVersion: log.alibabacloud.com/v1alpha1
kind: AliyunLogConfig
metadata:
  name: nest-log4j-message-server
spec:
  logstore: message-server-log
  lifeCycle: 60
  logtailConfig:
    inputType: plugin
    configName: nest-log4j-message-server 
    inputDetail:
      plugin:
        inputs:
        - type: service_docker_stdout
          detail:
            Stdout: true
            Stderr: true
            BeginLineCheckLength: 15
            BeginLineRegex: '\d{2}:\d{2}:\d{2},.*'
            IncludeLabel:
              "io.kubernetes.container.name": "message-server"
            ExcludeLabel:
              "io.kubernetes.container.name": "*"
        processors:
        - type: processor_regex
          detail:
            SourceKey: content
            Regex: '(\d{2}:\d{2}:\d{2},\d{1,3})\s+(\w+)\s(.+?):(\d+)\s-\s(.*)'
            Keys: ['time', 'level', 'class', 'line', 'message']
            KeepSource: true
            NoKeyError: true
            NoMatchError: true



logtail-logback.yaml
 
apiVersion: log.alibabacloud.com/v1alpha1
kind: AliyunLogConfig
metadata:
  name: spring-logback
spec:
  logstore: k8s-application-log
  lifeCycle: 60
  logtailConfig:
    inputType: plugin
    configName: spring-logback
    inputDetail:
      plugin:
        inputs:
        - type: service_docker_stdout
          detail:
            Stdout: true
            Stderr: true
            BeginLineCheckLength: 15
            BeginLineRegex: '\d{4}-\d{2}-\d{2} .*'
            IncludeEnv:
              LOGGER: 'spring-logback'
        processors:
        - type: processor_regex
          detail:
            SourceKey: content
            Regex: '(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{1,3})\s+(\w+)\s+(\d+)\s+---\s+\[\s*([^\]]+)\]\s([^ ]+)\s*:\s*(.*)'
            Keys: ['time', 'level', 'pid', 'thread', 'class', 'message']
            timeKey: 'time'
            timeFormat: '%Y-%m-%d %H:%M:%S'
            KeepSource: true
            NoKeyError: true
            NoMatchError: true