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

Feature request: Websocket endpoint for service logs #35324

Open
cghislai opened this issue Oct 28, 2017 · 7 comments
Open

Feature request: Websocket endpoint for service logs #35324

cghislai opened this issue Oct 28, 2017 · 7 comments
Labels
area/api area/logging kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny

Comments

@cghislai
Copy link

cghislai commented Oct 28, 2017

There is already a websocket endpoint to attach to a container.
Now that service logs are available in the API, I'd be happy to be able to use websocket to fetch them.
Hijacking a TCP connection is not something we can easily do in a browser.

@boaz0
Copy link
Member

boaz0 commented Oct 28, 2017

@cghislai can you tell what is your use case here? What will web-socket solve for you?

Thanks.

@cghislai
Copy link
Author

I can't use the hijacking technique to gather container/service logs in a web browser javascript context.
Neither the XMLHttpRequest interface, neither higher-level API allow me to do so - unless Ive missed something.

Websockets however are already handled by most web browsers and web servers. No special technique is required and existing libraries could be leveraged to gather logs.
A websocket endpoint for service logs would allow me to fetch logs using the XmlHttpRequest or fetch API. Just like the exsting /ws endpoint for container logs.

@thaJeztah thaJeztah added the kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny label Oct 28, 2017
@ghost
Copy link

ghost commented Sep 7, 2019

@thaJeztah @boaz0
it still relevant, i am willing to open PR?

@cpuguy83
Copy link
Member

cpuguy83 commented Sep 7, 2019

Logs don't hijack the tcp connect, IIRC.
The main thing is that we have this multiplexed stream format that requires demuxing on the client.

What I'd like to see is for the API to not use this stream format if a single stream (egg stdout) was requested. Then you can make two requests, one for each stream.
If we support http2 these requests would go over a single connection.

@cpuguy83
Copy link
Member

cpuguy83 commented Sep 7, 2019

btw, the attach endpoint for websockets has always looked wrong to me since everything seems to be sent down a single stream and there is no way to differentiate stdout from stderr.

@ghost
Copy link

ghost commented Sep 7, 2019

@cpuguy83
I've tested the containers logs with the following JS

const http = require('http');

http.get('http://127.0.0.1:8080/containers/d2cf357d5602918f3dfbd50e7a7f37f72788a42091eb46856e890329a2628877/logs?stdout=1&follow=1', (resp) => {
  let data = '';

  // A chunk of data has been recieved.
  resp.on('data', (chunk) => {
    data += chunk;
    console.log(data.toString('utf8'));
  });

  // The whole response has been received. Print out the result.
  resp.on('end', () => {
    console.log();
  });

}).on("error", (err) => {
  console.log("Error: " + err.message);
});
 

its work corretly since there no conn Hijack,
its confusing me to atttach ws to grab the containers/service logs
but différents users have différents use cases and i belive API should be able to honor this feature
eventually do we need to support ws ?

@cpuguy83
Copy link
Member

cpuguy83 commented Sep 7, 2019

I'm not saying that attach should grab the container or service logs.
I'm saying the attach ws endpoint is incorrect because it cannot differentiate between container i/o streams.

What I am saying is:

  1. The service logs endpoint is not doing a hijack.
  2. All the logs endpoints (and attach) really should be updated to support getting a single stream without having the mux headers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api area/logging kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny
Projects
None yet
Development

No branches or pull requests

4 participants