Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Windows containers #4666

Closed
olljanat opened this issue Sep 10, 2018 · 17 comments · Fixed by #10382
Closed

Support for Windows containers #4666

olljanat opened this issue Sep 10, 2018 · 17 comments · Fixed by #10382
Labels
feature request Requests for new plugin and for new features to existing plugins platform/windows

Comments

@olljanat
Copy link
Contributor

olljanat commented Sep 10, 2018

Feature Request

Currently containerized version of Telegraf is only available for Linux and it would be very useful to have it for native Windows containers too.

Proposal:

Use case:

Windows container host monitoring.

Extra comments

I can start look this one but let me know if you have any requirements/comments how you want it to be implemented.

@glinton glinton added platform/windows feature request Requests for new plugin and for new features to existing plugins labels Sep 10, 2018
@danielnelson
Copy link
Contributor

@olljanat That would be great if you could look into this. I haven't researched this at all but the main question I have is if the image would have to be built on a Windows machine or if it can be created from Linux.

@olljanat
Copy link
Contributor Author

@danielnelson it need to be created on Windows. That is only way.

Btw. Is there some reason that Docker client is set to use 1.21 version instead of some newer one? (https://github.com/influxdata/telegraf/blob/master/plugins/inputs/docker/client.go#L14)
1.24 is first one which is supported by Windows containers.

@glinton
Copy link
Contributor

glinton commented Sep 12, 2018

The docker client is set to 1.21 to support older docker versions. Iirc, it will still work with newer server versions, let me know if you find differently.

@zentron
Copy link

zentron commented Nov 14, 2018

We are hitting this issue with version 18.03.1-ee-3 of the docker engine. It currently requires minimum of 1.24

Error in plugin [inputs.docker]: Error response from daemon: client version 1.21 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

Interestingly it looks like it was using 1.24 but was downgraded.

Would it be possible to get this version to be configurable?

@olljanat
Copy link
Contributor Author

docker version command very cleary says that minimum version 1.24

PS C:\> docker version
Client:
 Version:      18.03.1-ee-1
 API version:  1.37
 Go version:   go1.10.2
 Git commit:   d5375b4
 Built:        Wed Jun 27 01:28:56 2018
 OS/Arch:      windows/amd64
 Experimental: true

Server:
 Engine:
  Version:      18.03.1-ee-1
  API version:  1.37 (minimum version 1.24)
  Go version:   go1.10.2
  Git commit:   d5375b4
  Built:        Wed Jun 27 01:45:19 2018
  OS/Arch:      windows/amd64
  Experimental: false`

Btw. We decided to not use Telegraf so I will not implement this one.

@danielnelson
Copy link
Contributor

As a workaround, you should be able to use the environment configuration to manually set the api version, in your environment set these variables as needed:

// DOCKER_HOST to set the url to the docker server.
// DOCKER_API_VERSION to set the version of the API to reach, leave empty for latest.
// DOCKER_CERT_PATH to load the TLS certificates from.
// DOCKER_TLS_VERIFY to enable or disable TLS verification, off by default.

Then use endpoint = "ENV" in the plugin configuration:

[[inputs.docker]]
  endpoint = "ENV"

We should investigate if we can use NegotiateAPIVersion and verify that it will work with 1.8 as well as the latest docker version.

@TerraVenil
Copy link

Hi, @danielnelson. Suggested workaround not worked for me, seems like env variables DOCKER_HOST/DOCKER_API_VERSION ignored by telegraf service.

@olljanat
Copy link
Contributor Author

Docker code very clearly sets minimum API version for Windows to 1.24 https://github.com/moby/moby/blob/8e610b2b55bfd1bfa9436ab110d311f5e8a74dcb/api/common_windows.go#L8 co you cannot override that.

Also notice that oldest supported Docker version is 17.06 and that contains already API version 1.30.

@danielnelson
Copy link
Contributor

@TerraVenil Looked over the code and it seems like it should work, and definitely working in Linux. Can you double check the environment variables are set when Telegraf is ran? If you are running Telegraf as a service you may need to set it explicitly for the service. It may be simpler to test from a cmd window.

@TerraVenil
Copy link

TerraVenil commented Jan 15, 2019

@danielnelson let me provide additional info about env. I use Telegraf as a service from Windows Container to grab Docker host metrics.
Docker Host

PS C:\> docker version
Client: Docker Engine - Community
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:47:51 2018
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.0
  API version:      1.39 (minimum version 1.24)
  Go version:       go1.10.4
  Git commit:       4d60db4
  Built:            Wed Nov  7 00:56:41 2018
  OS/Arch:          windows/amd64
  Experimental:     true

Windows Container
docker run -d -v \\.\pipe\docker_engine:\\.\pipe\docker_engine telegraf

.\telegraf.exe -version
Telegraf 1.9.1 (git: HEAD 20636091)

telegraf.conf

[[inputs.docker]]
   endpoint = "ENV"
PS C:\> Get-ChildItem Env:

Name                           Value
----                           -----
ALLUSERSPROFILE                C:\ProgramData
DOCKER_API_VERSION             1.39
DOCKER_HOST                    tcp://172.25.112.1:2375
USERNAME                       ContainerAdministrator
USERPROFILE                    C:\Users\ContainerAdministrator
windir                         C:\Windows

2019-01-15T11:27:40Z E! [inputs.docker]: Error in plugin: error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.37/containers/json?filters=%7B%22status%22%3A%7B%22running%22%3Atrue%7D%7D&limit=0: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.

From another point if I use telegraf.conf

[[inputs.docker]]
   endpoint = "tcp://172.25.112.1:2375"

I received as expected
2019-01-15T11:36:40Z E! [inputs.docker]: Error in plugin: Error response from daemon: client version 1.21 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

@hoerup
Copy link

hoerup commented Feb 21, 2020

By using
endpoint = "npipe:////./pipe/docker_engine"
telegraf connects - but then fails on the client version to old.

@olljanat
Copy link
Contributor Author

@hoerup try set environment variable DOCKER_API_VERSION=1.24

@hoerup
Copy link

hoerup commented Feb 22, 2020

Got it working with changing https://github.com/influxdata/telegraf/blob/master/plugins/inputs/docker/client.go#L14 to 1.24 and building a new binary

@danielnelson danielnelson modified the milestones: 1.14.0, 1.15.0 Mar 13, 2020
@danielnelson danielnelson removed this from the 1.15.0 milestone Jun 26, 2020
@wyaopeng
Copy link

wyaopeng commented Sep 3, 2020

Did fix it for 1.15.0 ?

@hoerup
Copy link

hoerup commented Sep 3, 2020

@wyaopeng still broken

@dani-pisca
Copy link

How can this issue still be open 3 years later?

@wyaopeng
Copy link

wyaopeng commented Sep 6, 2021

Did fix it now ?

powersj added a commit to powersj/telegraf that referenced this issue Jan 5, 2022
Telegraf manually sets the API version in the docker client. We are
using the 20.10 version of docker, which cooresponds to a newer API
version that we can bump up to.

Fixes: influxdata#4666
Fixes: influxdata#10380
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Requests for new plugin and for new features to existing plugins platform/windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants