Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
483 views
in Technique[技术] by (71.8m points)

kubernetes - what do you need to do to get fluentd to send logs as httpRequest property, instead of textPayload

In my cluster in GCP, I have multiple services(all python being served by either gunicorn or hypercorn) that get a http request and log out an entry like this:

::ffff:127.0.0.1:52726 - - [10/Jan/2021:19:56:36 +0000] "GET /health-check 1.1" 200 2 "-" "kube-probe/1.16+" -

I want it to get parsed into this format in stackdriver:

"httpRequest": {
    "requestMethod": "GET",
    "requestUrl": "/health-check",
    "requestSize": "148",
    "status": 200,
    "responseSize": "2",
    "userAgent": "kube-probe/1.16+",
    "remoteIp": "::ffff:127.0.0.1:52726",
    "serverIp": "127.0.0.1",
    "latency": "0.043219s"
}

Besides the log matching what the nginx fluentd plugin is looking for, what else do I need to do to make this happen?

We haven't done anything with the fluentd setup in the cluster, it is just the default that is installed when you create a cluster in GCP.

I have seen people say just create a single line json, which could work, but seems sort of hacky and potentially prone to error if a " is in any of the fields I am trying to report.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.7k users

...