Increase the number of open sockets on Chronograf server
Hi
I installed Chronograf on the same server with kapacitor and influxDB. Right after that I noticed the huge increase of open sockets.

Is it expected?
Hi @alyan2008, I'll check it out. What version of chronograf are you using?
@alyan2008 I've been able to reproduce this.
To reproduce run
watch -n1 "sudo lsof -i|grep chronograf"
..play around in the kapacitor rules page by saving a rule over and over again; watch the number of sockets established go up.
Got a theory on this one. We're creating a new http.Transport for each query when InsecureSkipVerify is desired for HTTPS. This happens here: https://github.com/influxdata/chronograf/blob/master/influx/influx.go#L77-L80 . The docs for http.Transport state:
By default, Transport caches connections for future re-use. This may leave many open connections when accessing many hosts. [...] Transports should be reused instead of created as needed. Transports are safe for concurrent use by multiple goroutines.
I couldn't find a runtime.SetFinalizer for http.Transport in the stdlib that would automagically clean up open sockets on GC, so my guess is when that happens the sockets are orphaned but still allocated to the process and left open?
@timraymond just tried that out for influx queries... yup, we need to keep around the transport.
I haven't figured out kapacitor proxying yet. I wonder if I need to reuse the Transport here: https://github.com/influxdata/chronograf/blob/master/server/proxy.go#L58
Hi @alyan2008, we fixed the socket leaks for queries to Influx in PR #942. Thanks for reporting it!
We were commenting that it was pretty cool that you found a problem with chronograf using chronograf 👍