updates on influxdb url
This commit is contained in:
parent
72e5b16b7a
commit
966a6355d9
17
.vscode/launch.json
vendored
Normal file
17
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Launch",
|
||||||
|
"type": "go",
|
||||||
|
"request": "launch",
|
||||||
|
"mode": "auto",
|
||||||
|
"program": "${fileDirname}",
|
||||||
|
"env": {},
|
||||||
|
"args": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -16,8 +16,7 @@ go build
|
|||||||
|
|
||||||
```ini
|
```ini
|
||||||
[influxdb]
|
[influxdb]
|
||||||
hostname=influxdb
|
url=http://influxdb:8086/
|
||||||
port=8086
|
|
||||||
username=influxdb
|
username=influxdb
|
||||||
password=password
|
password=password
|
||||||
database=database
|
database=database
|
||||||
|
@ -37,8 +37,7 @@ func GetConfig(weatherconfig *WeatherConfig, configfile string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
influxdbSection := config.Section("influxdb")
|
influxdbSection := config.Section("influxdb")
|
||||||
wc.InfluxHost = influxdbSection.Key("hostname").MustString("localhost")
|
wc.InfluxURL = influxdbSection.Key("url").MustString("http://localhost:8086")
|
||||||
wc.InfluxPort = influxdbSection.Key("port").MustInt(8086)
|
|
||||||
wc.InfluxUser = influxdbSection.Key("username").MustString("username")
|
wc.InfluxUser = influxdbSection.Key("username").MustString("username")
|
||||||
wc.InfluxPass = influxdbSection.Key("password").MustString("password")
|
wc.InfluxPass = influxdbSection.Key("password").MustString("password")
|
||||||
wc.InfluxDB = influxdbSection.Key("database").MustString("me")
|
wc.InfluxDB = influxdbSection.Key("database").MustString("me")
|
||||||
@ -86,9 +85,8 @@ func FetchData(wc *WeatherConfig, city string) (Data, error) {
|
|||||||
// SendToInflux sends time series data to influxdb
|
// SendToInflux sends time series data to influxdb
|
||||||
func SendToInflux(wc *WeatherConfig, d Data) error {
|
func SendToInflux(wc *WeatherConfig, d Data) error {
|
||||||
|
|
||||||
wc.InfluxAddr = fmt.Sprintf("http://%s:%d", wc.InfluxHost, wc.InfluxPort)
|
|
||||||
httpClient, err := client.NewHTTPClient(client.HTTPConfig{
|
httpClient, err := client.NewHTTPClient(client.HTTPConfig{
|
||||||
Addr: wc.InfluxAddr,
|
Addr: wc.InfluxURL,
|
||||||
Username: wc.InfluxUser,
|
Username: wc.InfluxUser,
|
||||||
Password: wc.InfluxPass,
|
Password: wc.InfluxPass,
|
||||||
})
|
})
|
||||||
|
3
types.go
3
types.go
@ -5,8 +5,7 @@ type WeatherConfig struct {
|
|||||||
WeatherAppID string
|
WeatherAppID string
|
||||||
WeatherCities []string
|
WeatherCities []string
|
||||||
WeatherMeasurements []string
|
WeatherMeasurements []string
|
||||||
InfluxHost string
|
InfluxURL string
|
||||||
InfluxPort int
|
|
||||||
InfluxAddr string
|
InfluxAddr string
|
||||||
InfluxUser string
|
InfluxUser string
|
||||||
InfluxPass string
|
InfluxPass string
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
[influxdb]
|
[influxdb]
|
||||||
hostname=influxdb
|
url=http://influxdb:8086/
|
||||||
port=8086
|
|
||||||
username=influxdb
|
username=influxdb
|
||||||
password=password
|
password=password
|
||||||
database=database
|
database=database
|
||||||
|
Loading…
Reference in New Issue
Block a user