DataDog / datadogpy

The Datadog Python library
https://datadoghq.com/
Other
611 stars 302 forks source link

Using dogshell with keys supplied in env variables doesn't work for datadoghq.eu #652

Closed janorn closed 2 years ago

janorn commented 3 years ago

If you try to supply API and APP keys via env variables in a container and your Datadog site is datadoghq.eu it will fail. This is due to dogshell lacking a site config parameter or environment variable.

I have tried a workaround by supplying the site config in a dogrc file while the KEYs via env variables. However due to this code the dogrc file will never be used if you supply keys via env variables.

https://github.com/DataDog/datadogpy/blob/ec571f6593c983c0228fd7b6019bced1c5e7fc93/datadog/dogshell/common.py#L49-L56

Adding the keys to a config file in the container is not a viable solution.

janorn commented 3 years ago

Just to clarify. It does not "fail" with an error. But the posted data ends up in datadoghq.com. Or somewhere in binary space. No error message.

github-actions[bot] commented 3 years ago

Thanks for your contribution!

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of this project.

  2. Comment that the issue is still reproducible and include updated details requested in the issue template.

aquiladayc commented 2 years ago

@janorn Hey, would you try this? It worked for me. export DATADOG_HOST=https://api.datadoghq.eu/ and run dog commmand.

janorn commented 2 years ago

Seems to work

(dogshell) root@laptop:~# env | grep DATADOG
DATADOG_API_KEY=XXXXXXXXXXXXXXXXXXXX
DATADOG_APP_KEY=YYYYYYYYYYYYYYYYYYYYYYYYYYYYY
DATADOG_HOST=https://api.datadoghq.eu/
(dogshell) root@laptop:~# dogshell search query test
metrics synthetics.test_runs
metrics datadog.estimated_usage.synthetics.api_test_runs
metrics synthetics.pl.worker.pulled_tests
metrics synthetics.browser.test_duration
metrics datadog.estimated_usage.synthetics.browser_test_runs

However it doesn't seem to work with --site.

(dogshell) root@laptop:~# env | grep DATADOG
(dogshell) root@laptop:~# dogshell --api-key XXXXXXXXXXXXXXXXXXXX--application-key YYYYYYYYYYYYYYYYYYYYYYYYYYYYY--site https://api.datadoghq.eu/ search query test
usage: dogshell [-h] [--config CONFIG] [--api-key API_KEY] [--application-key APP_KEY] [--pretty] [--raw] [--timeout TIMEOUT] [-v]  {comment,search,metric,tag,event,monitor,timeboard,dashboard,screenboard,dashboard_list,host,downtime,service_check,service_level_objective} ...
dogshell: error: argument mode: invalid choice: 'https://api.datadoghq.eu/' (choose from 'comment', 'search', 'metric', 'tag', 'event', 'monitor', 'timeboard', 'dashboard', 'screenboard', 'dashboard_list', 'host', 'downtime', 'service_check', 'service_level_objective')
therve commented 2 years ago

Hi, are you using a git version? The --site option has been merged but not released.

janorn commented 2 years ago

No didn't try the git version.

therve commented 2 years ago

This has been released with 0.43, let us know if it doesn't work for you, thanks.