k8s nginx controller中日志切片配置

2021/7/23 7:11:42

本文主要是介绍k8s nginx controller中日志切片配置,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

只需要添加如下信息至configmap

apiVersion: v1
data:
  compute-full-forwarded-for: "true"
  enable-real-ip: "true"
  keep-alive-requests: "5000"
  log-format-upstream: '{"time": "$time_iso8601", "k8s_service_name":"$service_name",
    "remote_addr": "$proxy_protocol_addr", "x_forward_for": "$proxy_add_x_forwarded_for",
    "request_id": "$req_id", "remote_user": "$remote_user", "bytes_sent": $bytes_sent,
    "request_time": $request_time, "status": $status, "vhost": "$host", "request_proto":
    "$server_protocol", "path": "$uri", "request_query": "$args", "request_length":
    $request_length, "duration": $request_time,"method": "$request_method", "http_referrer":
    "$http_referer", "http_user_agent": "$http_user_agent" }'
  server-snippet: |
    if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})") {
        set $year $1;
        set $month $2;
        set $day $3;
        set $hour $4;
        set $minutes $5;
        set $seconds $6;
    }
    access_log  /var/log/nginx/access_log_$ingress_name-$year-$month-$day-$hour.log upstreaminfo  if=$loggable;
  upstream-keepalive-connections: "1000"
  use-forwarded-headers: "true"
kind: ConfigMap
metadata:
  annotations:
    meta.helm.sh/release-name: ingress-nginx
    meta.helm.sh/release-namespace: ingress-nginx
  creationTimestamp: "2021-04-08T10:09:29Z"
  labels:
    app.kubernetes.io/component: controller
    app.kubernetes.io/instance: ingress-nginx
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/version: 0.44.0
    helm.sh/chart: ingress-nginx-3.26.0
  name: ingress-nginx-controller
  namespace: ingress-nginx
  resourceVersion: "6564521"
  selfLink: /api/v1/namespaces/ingress-nginx/configmaps/ingress-nginx-controller
  uid: 74f466c8-5d0e-4b27-bc96-e1a92d75113f

  



这篇关于k8s nginx controller中日志切片配置的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程