Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make stackdriver agent work for detecting Json log #1169

Merged
merged 4 commits into from
Jun 13, 2018

Conversation

yanweiguo
Copy link
Contributor

For a json log emitted by user, for example,

{
  "log": "hello",
  "foo": "bar"
}

In fluentd event flows, before operator output configuration, we convert it to

{
  "log": "{\"log\": \"hello\", \"foo\": \"bar\"}",
  "foo": "bar",
  "kubernetes": {
      # kubernetes metadata
  }
  "stream": "stderr", # or "stdout" or "varlog"
  ...
}

For stderr/stdout, kubernetes_metadata plugin does the json parsing, which is a responsibility shouldn't belong to kubernetes_metadata. (This feature was removed since version kubernetes_metadata 2.1.0). For varlog, we parse the json in tail.

Then operator configure the destination backend and other extra process. This works fine for Elasticsearch, but it doesn't work for Stackdriver. Stackdriver will only try to parse log field as json if there're only the following fields: log(or message), time, severity, docker, kubernetes.

Proposed Changes

  • Do not parse json before operator output configuration. For example, the log entry before operator configuration flows is:
{
  "log": "{\"log\": \"hello\", \"foo\": \"bar\"}",
  "kubernetes": {
      # kubernetes metadata
  }
  "stream": "stderr", # or "stdout" or "varlog"
  ...
}
  • Let the operator to decide how they want to deal with the log field, which can be a json payload:
    • For ElasticSearch, use parser to parse the json.
    • For Stackdriver, turn on detect_json parameter in google_cloud plugin.

@yanweiguo yanweiguo requested a review from mdemirhan June 12, 2018 17:52
@google-prow-robot google-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 12, 2018
@@ -230,7 +230,15 @@ func logHandler(client *http.Client) http.HandlerFunc {

data := map[string]string{
"log": "A log in json format to STDOUT",
"foo": "bar",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To indicate any random key-value pair in json log emitted by the app can be collected/processed.

@mdemirhan
Copy link
Contributor

/lgtm
/approve

@google-prow-robot google-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 13, 2018
@vaikas
Copy link
Contributor

vaikas commented Jun 13, 2018

/lgtm
/approve

@google-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mdemirhan, vaikas-google, yanweiguo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-prow-robot google-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 13, 2018
@google-prow-robot google-prow-robot merged commit a67cd50 into knative:master Jun 13, 2018
markusthoemmes referenced this pull request in openshift/knative-serving Apr 3, 2019
* change fluentd config

* rename

* change kubernetes_metadata version requirement
skonto added a commit to skonto/serving that referenced this pull request Jul 14, 2022
* inject images, generate manifests (knative#1150)

* Revert temoprary branch for image injection (knative#1159)

Co-authored-by: Kenjiro Nakayama <[email protected]>
skonto added a commit to skonto/serving that referenced this pull request Jul 27, 2022
* inject images, generate manifests (knative#1150)

* Revert temoprary branch for image injection (knative#1159)

Co-authored-by: Kenjiro Nakayama <[email protected]>
skonto added a commit to skonto/serving that referenced this pull request Jul 27, 2022
* inject images, generate manifests (knative#1150)

* Revert temoprary branch for image injection (knative#1159)

Co-authored-by: Kenjiro Nakayama <[email protected]>
skonto added a commit to skonto/serving that referenced this pull request Jul 27, 2022
* inject images, generate manifests (knative#1150)

* Revert temoprary branch for image injection (knative#1159)

Co-authored-by: Kenjiro Nakayama <[email protected]>
skonto added a commit to skonto/serving that referenced this pull request Jul 29, 2022
* [RELEASE-1.4] Inject images, generate manifests (knative#1169)

* inject images, generate manifests (knative#1150)

* Revert temoprary branch for image injection (knative#1159)

Co-authored-by: Kenjiro Nakayama <[email protected]>

* fixes for 1.5

* Kourier image injection (knative#1173)

* Revert temoprary branch for image injection (knative#1186)

Co-authored-by: Kenjiro Nakayama <[email protected]>
nak3 added a commit to nak3/serving that referenced this pull request Aug 3, 2022
* [RELEASE-1.4] Inject images, generate manifests (knative#1169)

* inject images, generate manifests (knative#1150)

* Revert temoprary branch for image injection (knative#1159)

Co-authored-by: Kenjiro Nakayama <[email protected]>

* fixes for main

* Kourier image injection (knative#1173)

* Revert temoprary branch for image injection (knative#1186)

* add pdb fix

* Revert "add pdb fix"

This reverts commit 1790632.

Co-authored-by: Kenjiro Nakayama <[email protected]>
mgencur pushed a commit to mgencur/serving-1 that referenced this pull request Sep 6, 2022
* [RELEASE-1.4] Inject images, generate manifests (knative#1169)

* inject images, generate manifests (knative#1150)

* Revert temoprary branch for image injection (knative#1159)

Co-authored-by: Kenjiro Nakayama <[email protected]>

* fixes for 1.6

* Kourier image injection (knative#1173)

* Revert temoprary branch for image injection (knative#1186)

Co-authored-by: Kenjiro Nakayama <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants