Repository navigation
Conversation
*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; |
There was a problem hiding this comment.
I'm thinking about whether it is better to return and handle Tags via pointer (with unique_ptr?) here and rest of this PR.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Right. I'm working for that.
htuch
left a comment
There was a problem hiding this comment.
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?
|
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. 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. |
|
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:
Maybe there are other alternatives not considered as well. |
|
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 And I disagree with (2) because it's not so different with generating Bootstrap messages. Another option just appears but:
|
|
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? |
|
Sounds good. I've filed #2269 to track the generic override CLI flag and will continue to review this change as is. |
htuch
left a comment
There was a problem hiding this comment.
Thanks, looks good, can you add an integration test or something that validates that the default tags are included in the stats output?
| * 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 |
There was a problem hiding this comment.
Nit: s/universal/CLI configurable/
| /** | ||
| * @return const std::vector<Stats::Tag> default stats tags. | ||
| */ | ||
| virtual const std::vector<Stats::Tag> statsTags() PURE; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
|
|
||
| namespace Envoy { | ||
|
|
||
| const Stats::Tag parseTag(const std::string tag) { |
There was a problem hiding this comment.
Could consider making this a constructor for Stats::Tag?
There was a problem hiding this comment.
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.
|
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). |
|
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 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! |
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