Skip to content

stats: universal tag support with cli option - #2264

Closed
taiki45 wants to merge 1 commit into
envoyproxy:masterfrom
taiki45:cli-universal-tag
Closed

taiki45 wants to merge 1 commit into
envoyproxy:masterfrom
taiki45:cli-universal-tag

Conversation

@taiki45

@taiki45 taiki45 commented Dec 22, 2017

Copy link
Copy Markdown
Member

Description:
Support universal tag, the tags which will be added to all metrics. The main use case is to distinguish each Envoy instance by the the tag. This universal tag accepts arbitrary pairs of tag name and tag value.
The tags will be specified with commandline argument --stats-tag. The argument can be specified multiple times so that users can add multiple tags.

The original issue is #1975.

Risk Level:
Medium - New features that are not enabled by default.

Testing:
unit test, manual testing with statsd_exporter v0.5.0 and Prometheus v2.0.0.

Docs Changes:
envoyproxy/data-plane-api#361

Release Notes:
Added.

Fixes #1975

API Changes:
N/A

*Description*:
Support [universal tag](envoyproxy#1975),
the tags which will be added to all metrics. The main use case is to
distinguish each Envoy instance by the the tag. This universal tag
accepts arbitrary pairs of tag name and tag value. The tags will be
specified with commandline argument `--stats-tag`. The argument can be
specified multiple times so that users can add multiple tags.

The original issue is envoyproxy#1975.

*Risk Level*:
Medium

*Testing*:
unit test, manual testing with statsd_exporter v0.5.0 and Prometheus v2.0.0.

*Docs Changes*:
envoyproxy/data-plane-api#361

*Release Notes*:
Added.

Fixes envoyproxy#1975

*API Changes*:
N/A

Signed-off-by: Taiki Ono <[email protected]>
/**
* @return const std::vector<Stats::Tag> default stats tags.
*/
virtual const std::vector<Stats::Tag> statsTags() PURE;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm thinking about whether it is better to return and handle Tags via pointer (with unique_ptr?) here and rest of this PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why can't this be a const std::vector<Stats::Tag>& return? I don't think a single copy when this later gets used in the tag bucket is particularly bad at startup.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right. I'm working for that.

@htuch htuch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

At a design level, I'm wondering if we want to do lots of adhoc CLI overrides/extensions of the bootstrap config, or we want to just allow a bootstrap proto to be passed on CLI and then merge it with any static bootstrap proto.

The advantage of merging from a CLI proto is you have a very general mechanism for overriding things like node IDs, stats tags and other configuration on a per instance basis while maintaining a shared static bootstrap config file.

The disadvantage is you have to use complex proto syntax and it's less human friendly.

If we push these static instance tags into a field in the bootstrap proto, I can also imagine a syntax like --bootstrap-override stats_config.extra_tags=some_tag:some_value.

I'm really just brainstorming through the design space here. What do you and other in the community think?

@taiki45

taiki45 commented Dec 24, 2017

Copy link
Copy Markdown
Member Author

At first, I agree to avoid implementing new CLI flag of which aim is using shared bootstrap config. I'm getting the thought that by this way we will have more CLI flags and it's not good.

Then saying the CLI flag which overwrites bootstrap proto, it can solve the original issue but I slightly feel it's complex or overkill for the issue. I don't find more use cases. To saying complexity, we have to have a extra syntax to convert from CLI flag to Proto, especially for repeated values. --bootstrap-override stats_config.extra_tags=some_tag:some_value is a good example. This form seems extra_tags is just overwriting by a string value, but when the extra_tags is repeated value, the form should be adding a new element in the list. To avoid this confusion, we have to define well-formed conversion rule.

The idea to passing a piece of bootstrap config and merge into static bootstrap config seems less complex. But I'm wondering it's not so different from generating static bootstrap config.

The all above ideas have disadvantages and are not cure in my opinion.

For me, I prefer using generated static bootstrap config and fixed string idea which is suggested at #1975 (comment) and it's enough for my case. So I feel we have to hear more concrete problems with generating static bootstrap config in #1975.

I also want comments from the community.

@htuch

htuch commented Dec 24, 2017

Copy link
Copy Markdown
Member

I think there's definitely a valid use case of CLI flags to provide a per-instance override. In some deployments, all Envoys in a given zone/region may share a static configuration file, but specifics of that instance might be easier to provide operationally as a CLI flags (e.g. node ID, some stats tags).

The question then is how to do this in a way that minimizes both implementation and operational complexity. I think we have three options:

  1. Implement adhoc CLI flags that supplement/override the bootstrap config. This is basically the current state of Envoy and what this PR will align with.

  2. Allow a complete bootstrap config fragment to be provided on the CLI and then merged with the static bootstrap config fragment. Very easy to implement and use when machine generating CLI args, but fairly clunky when writing text proto fragments by hand on the CLI.

  3. Add special flags to allow you to go in and override individual proto files in the bootstrap (--bootstrap-override stats_config.extra_tags=some_tag:some_value). This would be some work to implement (probably requires proto reflection for the typing), is fairly clean for providing config overrides on the CLI by hand, but is quite non-standard as you point out and has corner cases.

Maybe there are other alternatives not considered as well.

@taiki45

taiki45 commented Dec 25, 2017

Copy link
Copy Markdown
Member Author

Okay, now I'm getting the use case of CLI flags overwriting. Although, I think generating configuration per Envoy instances is more simple and clear. So I'm not willing to support CLI flags overwriting yet. It's helpful if you show your idea for pros of CLI flags overwriting against generating configuration.

For implementing CLI flags overwriting, my question is ad-hoc CLI flags like --concurrency should be in Bootstrap message or not. If so, I vote for (3), because it's more general than others and it can deprecate current ad-hoc CLI flags in the future. The down-side of (3) can be handled by our effort.

And I disagree with (2) because it's not so different with generating Bootstrap messages.

Another option just appears but:

  1. Extract stats config as a xDS. If the stats configuration grows, it can be reasonable? I don't have the confidence for it though.

@mattklein123

Copy link
Copy Markdown
Member

Thanks for the design discussion on this. I think it's a useful conversation to have.

re: @htuch design options, here are my thoughts:

I agree with @taiki45 that (2) is really not that much different from custom bootstrap configs. If someone can generate an override snippet they can probably generate a custom bootstrap config with the stuff already merged, so I'm not sure how valuable this would be.

I like the idea of (3). That sounds generally useful to me, but it does seem like a non-trivial amount of work. I would suggest that we don't block this work on the creation of (3), but it would be good to track (3) as a discrete issue.

For this particular issue, I think I'm ok with (1). I'm honestly not sure how often this is going to come up. It hasn't really come up that often in the lifetime of Envoy. So I guess I would say I'm fine with going ahead with (1), or, if as you say @taiki45 you don't actually need CLI and can just generate the bootstrap for each host, we can drop CLI altogether for now.

@htuch WDYT?

@htuch

htuch commented Dec 25, 2017

Copy link
Copy Markdown
Member

Sounds good. I've filed #2269 to track the generic override CLI flag and will continue to review this change as is.

@htuch htuch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, looks good, can you add an integration test or something that validates that the default tags are included in the stats output?

Comment thread RAW_RELEASE_NOTES.md
* Added idle timeout to TCP proxy.
* Added support for dynamic headers generated from upstream host endpoint metadata
(`UPSTREAM_METADATA(...)`).
* Added universal tag support, the tags which will be added to all metrics. The tags can be specified

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: s/universal/CLI configurable/

/**
* @return const std::vector<Stats::Tag> default stats tags.
*/
virtual const std::vector<Stats::Tag> statsTags() PURE;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why can't this be a const std::vector<Stats::Tag>& return? I don't think a single copy when this later gets used in the tag bucket is particularly bad at startup.

return Stats::Tag{key_value[0], key_value[1]};
}

const std::vector<Stats::Tag> parseTags(const std::vector<std::string> tags) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

const std::Vector<std::String>&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, the const in the return doesn't do anything, since it's not a reference. This method could be made static.


const std::vector<Stats::Tag> parseTags(const std::vector<std::string> tags) {
std::vector<Stats::Tag> parsed_tags;
for (const std::string tag : tags) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

const std::string& tag


namespace Envoy {

const Stats::Tag parseTag(const std::string tag) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could consider making this a constructor for Stats::Tag?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, in my opnion. This parsing rule is only for CLI flags so it's not good to place this in the constructor. If another use case for this parsing rule happens, then we can move this into a builder method or object of Stats::Tag. I think it's not time to do that yet.

@taiki45

taiki45 commented Dec 26, 2017

Copy link
Copy Markdown
Member Author

Thanks, sounds good to me as well.

For CLI flags, I don't actually need it but I can move this PR forward to fix original issue #1975.

Then I'll make a new PR which implements the fixed value field in TagSpecifier message which was originally discussed at #1975 (comment).

@taiki45

taiki45 commented Dec 26, 2017

Copy link
Copy Markdown
Member Author

For the integration test, I'd taken a look at integration tests and tried implementing that. I'll work for the test again but it helps me if you show an entrypoint to do that (any level of detail are welcome!).

@mattklein123

Copy link
Copy Markdown
Member

For CLI flags, I don't actually need it but I can move this PR forward to fix original issue #1975.

@taiki45 if you don't want to implement the CLI flags we can revert the docs PR and you can close this. I think just adding fixed tag support to the config also fixes #1975. Up to you.

@taiki45

taiki45 commented Dec 27, 2017

Copy link
Copy Markdown
Member Author

@mattklein123 Thanks for the advice. I stop and close this PR until someone needs this. Then I will make fixed tag support PR.

@htuch Sorry but thanks for reviews!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants