Skip to content

Add interpolation of environment variables.#2095

Closed
tyuio9 wants to merge 2 commits intoDataDog:masterfrom
tyuio9:master
Closed

Add interpolation of environment variables.#2095
tyuio9 wants to merge 2 commits intoDataDog:masterfrom
tyuio9:master

Conversation

@tyuio9
Copy link
Copy Markdown

@tyuio9 tyuio9 commented Nov 19, 2015

Briefly the change allows to use all environment variables that begins with DATADOG_ inside the configuration file.

@tyuio9 tyuio9 closed this Nov 19, 2015
@tyuio9 tyuio9 reopened this Nov 19, 2015
@tyuio9 tyuio9 closed this Nov 19, 2015
@tyuio9 tyuio9 reopened this Nov 19, 2015
@tyuio9
Copy link
Copy Markdown
Author

tyuio9 commented Nov 19, 2015

Looks like the first problem was the Python 2.6.x syntax issue. Anyway, it should be fixed now.

@remh
Copy link
Copy Markdown

remh commented Nov 19, 2015

@mwolny
Thanks for this.
There is a similar implementation in https://github.com/DataDog/dd-agent/pull/1343/files

We'll decide which direction we should go for 5.7.0

Thanks a lot!

@remh remh added this to the 5.7.0 milestone Nov 19, 2015
@tyuio9
Copy link
Copy Markdown
Author

tyuio9 commented Nov 20, 2015

It would be really awesome to have such functionality as soon as possible. Seriously, it simplifies a lot. Is there any deadline or planned date for 5.7.0?

@irabinovitch
Copy link
Copy Markdown
Contributor

@mwolny We're currently tracking 5.7 for January.

@tyuio9
Copy link
Copy Markdown
Author

tyuio9 commented Dec 17, 2015

Awesome, really happy to hear it!

On Thu, Dec 17, 2015 at 11:05:06AM -0800, Ilan Rabinovitch wrote:

@mwolny We're currently tracking 5.7 for January.


Reply to this email directly or view it on GitHub:
#2095 (comment)

Marcin Wolny
marcin@wutanic.com

@remh
Copy link
Copy Markdown

remh commented Dec 18, 2015

@mwolny can you describe a bit more your use case ?
What environment variables are you passing ?

@tyuio9
Copy link
Copy Markdown
Author

tyuio9 commented Dec 18, 2015

Sure. Nowadays I work with docker containers mostly. As you probably
know enviroment variables as one of the most common method to pass
parameters (not necesarrly a good method). Anyway, in my case part of
containers use dogstatsd to send metrics to forwarders that resides
behind the AWS ELB. This means that I have to set dogstatsd_target.
Obviously environment variable is the easiest choice if you want to
treat your container stateless and keep it readonly. I would prefer to
avoid hardcoding values that may influence may infrastructure. Is this
answer your question?

I also use enviroment variables for checks. But here I can take
advantage of pyaml and !!python.

On Fri, Dec 18, 2015 at 10:50:11AM -0800, Remi Hakim wrote:

@mwolny can you describe a bit more your use case ?
What environment variables are you passing ?


Reply to this email directly or view it on GitHub:
#2095 (comment)

Marcin Wolny
marcin@wutanic.com

@remh remh modified the milestones: 5.8.0, 5.7.0 Dec 22, 2015
@remh
Copy link
Copy Markdown

remh commented Dec 22, 2015

Thanks for the explanation. Can you describe where you'll be reading those settings from ?

From what i can see, all environment variables starting with DATADOG_ will be passed to the config object but it's not clear where it will be read from.

Thanks!

@tyuio9
Copy link
Copy Markdown
Author

tyuio9 commented Dec 22, 2015

This change allows you to use all environment variables starting with
DATADOG_ in agent configuration, e.g. %(DATADOG_API_KEY)s.

In other way, all environment variables starting with DATADOG_ you
will be able to interpolate in agent configuration file.

Is this answer your question?

On Tue, Dec 22, 2015 at 08:11:48AM -0800, Remi Hakim wrote:

Thanks for the explanation. Can you describe where you'll be reading those settings from ?

From what i can see, all environment variables starting with DATADOG_ will be passed to the config object but it's not clear where it will be read from.

Thanks!


Reply to this email directly or view it on GitHub:
#2095 (comment)

Marcin Wolny
marcin@wutanic.com

@tyuio9
Copy link
Copy Markdown
Author

tyuio9 commented Dec 23, 2015

Looks like this change also introduces a problem with logging configuration. Basically the code creates ConfigParser object instance twice at two different places. This makes this path kind of unusable.

@remh
Copy link
Copy Markdown

remh commented Dec 23, 2015

Yes it does answer my question, thanks!

You're right we initialize the config parser twice in the code. One for the logging config and one for the rest as we want to set up the logging as soon as possible. We should likely add the environment variable interpolation in the logging config set up code path as well. What do you think ?

@tyuio9
Copy link
Copy Markdown
Author

tyuio9 commented Dec 23, 2015

Actually I am just in the middle of creating change where env_vars is changed into global variable and re-used at both places. I think this is the easiest possible change with current architecture.

    This happens because ConfigParser object instance is created twice
    at two different places.
@andyshinn
Copy link
Copy Markdown

This change still seems to require a change to datadog.conf to add the variables, correct? It would be nice to be able to actually override the configuration with the environment variable without needing to edit the datadog.conf at all.

For example, I usually only ever set api_key. It would be great if I could just set the DATADOG_API_KEY environment variable to override whatever is in the config (then the stock installed config never needs to be touched).

@tyuio9 tyuio9 closed this Mar 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants