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

Add envoy-json-logging-custom-fields-design doc #3042

Merged

Conversation

mike1808
Copy link
Contributor

Co-authored-by: Leah Hanson lhanson@pivotal.io

In continuation of #3032 we're making a design doc to discuss possible solutions for our problem.

@codecov
Copy link

codecov bot commented Oct 19, 2020

Codecov Report

Merging #3042 into main will decrease coverage by 0.13%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3042      +/-   ##
==========================================
- Coverage   73.35%   73.22%   -0.14%     
==========================================
  Files          95       95              
  Lines        6046     6057      +11     
==========================================
  Hits         4435     4435              
- Misses       1510     1521      +11     
  Partials      101      101              
Impacted Files Coverage Δ
cmd/contour/serve.go 0.00% <0.00%> (ø)

@jpeach jpeach added area/deployment Issues or PRs related to deployment tooling or infrastructure. kind/design Categorizes issue or PR as related to design. labels Oct 19, 2020
@jpeach jpeach added this to In progress in Contour Project Board via automation Oct 19, 2020
- This is related to [#2523](https://github.com/projectcontour/contour/issues/2523)
* Is one of the alternative approaches preferable?
- [User-defined Translation Table](#user-defined-translation-table) seems easier to implement because it was partially implemented in #3033 and because the configuration is more structured and easier to work with as there no need for additional string parsing.
- [Map Syntax](#map-syntax) is not backward-compatible, but does avoid string parsing.
Copy link
Contributor

Choose a reason for hiding this comment

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

Map syntax seems clean, but we would need to introduce it in a new config field, then deprecate the old field after a number of releases. Would still need to define what happens to the built-in field mappings.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea, since the map syntax would require deprecating the prior configuration field anyway, the new field would not have to support the built-in field mappings. In our example in this doc, we assumed that empty values would imply that the key should be looked up in the built-in field mappings, but I'm not sure whether that's desirable or not.

In favor of a built-in translation table:

  • Users of Contour only have to read Contour's docs (vs. also referencing Envoy's config syntax).
  • Users get reasonable, standardized field names because that's what's setup by the field mappings.

In favor of writing all key-value pairs out:

  • Users of Contour can read the Envoy docs to decide what config to write. They don't need to know Contour's specific translation of special keys.

Copy link
Member

Choose a reason for hiding this comment

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

I like the ease of use of having the translation table, personally. I think that having the two types seems like an okay tradeoff for that ease of use (for now at least).

Copy link
Contributor

@jpeach jpeach left a comment

Choose a reason for hiding this comment

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

This looks good to me. I'll give other maintainers a chance to review before I merge though.

- In the current implementation, `method` becomes `"method": "%REQ(:METHOD)%"`.
- When the new implementation adds a way to achieve the JSON config `"response_duration": "%RESPONSE_DURATION%"`, should the user write:
* `response_duration`, or
* `response_durationn=%RESPONSE_DURATION%`
Copy link
Contributor

Choose a reason for hiding this comment

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

The built-in mappings still need to be supported. I would not want to force people using the existing field mappings to manually remake their configuration.

Copy link
Contributor

Choose a reason for hiding this comment

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

We agree that built-in mappings need to be supported. The question here is whether fields that could be added to those mappings should be.

  • method will still work.
  • should response_duration work?

If response_duration works, then the interface is consistent, but the implication is that the translation table will be used forever (despite users having a way to write response_duration without the translation table).
If response_duration=%RESPONSE_DURATION% is the only option for users, then there is inconsistency between the original set that are in the translations and the new ones that require more spelling out.

Copy link
Member

Choose a reason for hiding this comment

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

The original intent was that we add simple translations as required to the translation table; we figured that people could just request anything they needed added. With that in mind, I'm okay with adding whatever simple translations to the translation table (like response_duration, where it's a straight mapping between field name and Envoy template string), as part of this implementation.

Obviously, this will be frozen at this point in time, but perhaps a comment saying that adding things to the standard translations is fine would make it clearer that we're open to adding more?


#### Unknown field name in old format

If the field name is not defined in the default fields transition map and the user doesn't specify the Envoy field format, then Contour will raise a validation error.
Copy link
Contributor

Choose a reason for hiding this comment

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

See #3023 for config file validation.

Copy link
Member

@youngnick youngnick left a comment

Choose a reason for hiding this comment

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

This proposal LGTM, I think it's a good balance between adding extra functionality and backward compatibility. Thanks for writing it up @mike1808 and @astrieanna!

@mike1808 mike1808 force-pushed the envoy-custom-json-fields-design branch from 921cec7 to 43602ae Compare October 19, 2020 23:58
mike1808 and others added 2 commits October 19, 2020 23:59
Co-authored-by: Leah Hanson <lhanson@pivotal.io>
Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>
Signed-off-by: Mikael Manukyan <mmanukyan@vmware.com>
Co-authored-by: Leah Hanson <lhanson@pivotal.io>
Signed-off-by: Mikael Manukyan <mmanukyan@vmware.com>
@mike1808 mike1808 force-pushed the envoy-custom-json-fields-design branch from 43602ae to 1b6c9ec Compare October 19, 2020 23:59

#### Field name is repeated

If the field name is repeated the last entry in the configuration takes precedes and overwrites the previous value.
Copy link
Member

Choose a reason for hiding this comment

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

Wonder if this should raise a validation error instead of overwriting?

Copy link
Contributor

Choose a reason for hiding this comment

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

A validation error could be OK if a field name is repeated in a single json-fields array. My original intention with suggesting overwriting was that operators should be able to use this mechanism to change the definition of builtin log fields (ie. overwriting the builtin field mapping).

Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

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

LGTM!

@jpeach
Copy link
Contributor

jpeach commented Oct 20, 2020

Last call for comments.

@@ -0,0 +1,144 @@
# Allow Envoy to output arbitrary fields for JSON logs

Status: Draft
Copy link
Member

Choose a reason for hiding this comment

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

If there are no further comments, @mike1808, could you change this to 'Accepted' before we merge?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done @youngnick

Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>
@youngnick
Copy link
Member

Okay, I'm calling this one done. Thanks @mike1808 and @astrieanna!

@youngnick youngnick merged commit c9563ed into projectcontour:main Oct 22, 2020
Contour Project Board automation moved this from In progress to 1.10 Release Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/deployment Issues or PRs related to deployment tooling or infrastructure. kind/design Categorizes issue or PR as related to design.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants