Skip to content

stats: add universal tag support #1975

Description

@kevintchan

I'd like to tag all metrics exported by Envoy with a tag unique to that instance. This tag would allow me to isolate metrics to debug an instance. The tag value would be based on a command line argument (e.g. --service-node) or environment variable so that each Envoy instance could share a config file.

Thanks!

Activity

  1. added
    enhancement
    help wanted
    on Oct 31, 2017
  2. taiki45 commented on Dec 20, 2017

    @taiki45
    Member

    I'll take this one. I'm just thinking using environment variable will be more extendable way and won't change current behavior until specified the same config as before. So how about adding new field to TagSpecifier message:

    message TagSpecifier {
      string tag_name = 1;
      oneof tag_value {
        string regex = 2;
        string environment_variable = 3;
      }
    }

    Then Envoy will getenv with the env var and add the returned value. If no tag_value is specified, find from TagNames and add default regex for backward compat (current behavior).

    I feel environment_variable is a little bit log name, so want comments about it. env_var might be better?

  3. mattklein123 commented on Dec 21, 2017

    @mattklein123
    Member

    @taiki45 this sounds reasonable to me, but if we are going to add additional tag filling options, I would also support direct string add in addition to pull from env variable. I think some (most?) people would just specify the fixed tag directly in the config.

    @mrice32 WDYT?

  4. taiki45 commented on Dec 21, 2017

    @taiki45
    Member

    @mattklein123 I'm also thinking about supporting fixed string or not. I'll do that.

  5. mrice32 commented on Dec 21, 2017

    @mrice32
    Member

    @mattklein123 absolutely. At Google, we will use the fixed string in the config rather than the environment variable. Thanks, @taiki45!

  6. ggreenway commented on Dec 21, 2017

    @ggreenway
    Member

    If this uses an environment variable, I believe this would be the first case that envoy looks at the environment at all. I think it would be preferable to put it in the config or on the commandline, for consistency with how everything else in envoy is configured.

  7. mattklein123 commented on Dec 21, 2017

    @mattklein123
    Member

    Initially I had the same reaction about env vars as @ggreenway did, but then I thought about it and I'm OK with it if people want it. I think in certain cases supporting env var interpolation might be convenient for people. This case comes to mind, as does logging/dynamic headers.

    I don't really feel strongly about it though if there is strong objection. I think as long as it is clearly documented it's fine either way.

  8. taiki45 commented on Dec 22, 2017

    @taiki45
    Member

    For consistency, I actually slightly felt the same thing when I thought about error handling of missing environment variables: since Envoy has put configuration in the config file or on the commandline, the missing environemnt variables error might be a little bit confusing.

    Then I'm thinking about passing default tags as commandline args like --stats-tag=service_cluster:local --stats-tag=my_tag:a. With it, uses can use the same configuration for different Envoy instances (this issue requires), and it can accept arbitrary tags.

    We might use env var interpolation in other cases, but in my current opinion, supporting universal tags with commandline args is better way in this case. WDYT? Please tell me if I missed the downside of this. Maybe commandline args can be long sometimes, but I don't think it can be a problem in most cases (not certainly).

  9. mattklein123 commented on Dec 22, 2017

    @mattklein123
    Member

    Sure, CLI SGTM and per @ggreenway I think fits better with that Envoy typically does. If this works for you we can skip env var until if/when someone really needs it. If you add the CLI support, the values can just be passed to the stats store on startup.

  10. added a commit that references this issue on Oct 30, 2018
  11. 5 remaining items

  12. davinci26 commented on Sep 27, 2021

    @davinci26
    Member

    @jmarantz the scenario that I am looking at we have envoy deployed into a set of machines and all the envoys are statically configured and they dont talk to an XDS server.

    We want to tag Envoy stats with the machine name for filtering purposes. This machine name is an environment variable.

    AFAICT the existing framework does not support this because the config.metrics.v3.TagSpecifier only supports a fixed value.

    edit: the env variable can be easily passed to envoy as a CLI argument so I am not making a case for env variables over cli params.

  13. ggreenway commented on Sep 27, 2021

    @ggreenway
    Member

    FWIW, I accomplish the same thing by running the bootstrap config through envsubst before starting Envoy. The advantage of this approach is that you can change anything in the config without requiring an envoy change for each one.

  14. davinci26 commented on Sep 27, 2021

    @davinci26
    Member

    I was also thinking of a similar approach as a backup but the environment I am work on does not have envsubst so I will have to write a script to do the replacement.

    Thinking that this might be the case for multiple users, it makes sense to me to have envoy do this for all users.

    The advantage of this approach is that you can change anything in the config without requiring an envoy change for each one.

    Agree on that. For now, I only have the tagging requirement.

  15. davinci26 commented on Sep 28, 2021

    @davinci26
    Member

    Is there any concern if I go ahead and implement this feature?

  16. self-assigned this
    on Oct 14, 2021
  17. added a commit that references this issue on Nov 4, 2021
    c75c141
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementhelp wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions