开启了influxdb后,会监听8086端口
下载客户端代码
git clone https://github.com/influxdata/influxdb1-client.git $GOPATH/src/github.com/influxdata/influxdb1-client
package main import ( "fmt" _ "github.com/influxdata/influxdb1-client" // this is important because of the bug in go mod client "github.com/influxdata/influxdb1-client/v2" ) func main() { c, err := client.NewHTTPClient(client.HTTPConfig{ Addr: "http://172.17.0.3:8086", }) if err != nil { fmt.Println("Error creating InfluxDB Client: ", err.Error()) } defer c.Close() q := client.NewQuery("SELECT *FROM webmail_log", "sinamail", "") if response, err := c.Query(q); err == nil && response.Error() == nil { fmt.Println(response.Results) } }