Influxdb: add insecure option (#16025)
This commit is contained in:
parent
81c8b4fc4d
commit
e627fbd32a
6 changed files with 28 additions and 2 deletions
|
|
@ -88,6 +88,7 @@ type Influx struct {
|
|||
Org string `json:"org"`
|
||||
User string `json:"user"`
|
||||
Password string `json:"password"`
|
||||
Insecure bool `json:"insecure"`
|
||||
}
|
||||
|
||||
// Redacted implements the redactor interface used by the tee publisher
|
||||
|
|
@ -98,11 +99,13 @@ func (c Influx) Redacted() any {
|
|||
Database string `json:"database"`
|
||||
Org string `json:"org"`
|
||||
User string `json:"user"`
|
||||
Insecure bool `json:"insecure"`
|
||||
}{
|
||||
URL: c.URL,
|
||||
Database: c.Database,
|
||||
Org: c.Org,
|
||||
User: c.User,
|
||||
Insecure: c.Insecure,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,6 +73,19 @@
|
|||
autocomplete="off"
|
||||
/>
|
||||
</FormRow>
|
||||
<FormRow id="influxInsecure" :label="$t('config.influx.labelInsecure')">
|
||||
<div class="d-flex">
|
||||
<input
|
||||
class="form-check-input"
|
||||
id="influxInsecure"
|
||||
type="checkbox"
|
||||
v-model="values.insecure"
|
||||
/>
|
||||
<label class="form-check-label ms-2" for="influxInsecure">
|
||||
{{ $t("config.influx.labelCheckInsecure") }}
|
||||
</label>
|
||||
</div>
|
||||
</FormRow>
|
||||
<p>
|
||||
<button
|
||||
v-if="showV1(values)"
|
||||
|
|
|
|||
|
|
@ -570,6 +570,7 @@ func configureInflux(conf *globalconfig.Influx) (*server.Influx, error) {
|
|||
conf.User,
|
||||
conf.Password,
|
||||
conf.Database,
|
||||
conf.Insecure,
|
||||
)
|
||||
|
||||
return influx, nil
|
||||
|
|
|
|||
|
|
@ -112,7 +112,9 @@ title = "HEMS"
|
|||
description = "Schreibt Ladedaten und andere Metriken in InfluxDB. Verwende Grafana oder andere Tools, um die Daten zu visualisieren."
|
||||
descriptionToken = "Siehe die InfluxDB-Dokumentation, um zu erfahren, wie du einen erstellst. https://docs.influxdata.com/influxdb/v2/admin/"
|
||||
labelBucket = "Bucket"
|
||||
labelCheckInsecure = "Erlaube unsichere Verbindungen"
|
||||
labelDatabase = "Datenbank"
|
||||
labelInsecure = "Zertifikatüberprüfung"
|
||||
labelOrg = "Organisation"
|
||||
labelPassword = "Passwort"
|
||||
labelToken = "API-Token"
|
||||
|
|
|
|||
|
|
@ -112,7 +112,9 @@ title = "HEMS"
|
|||
description = "Writes charging data and other metrics to InfluxDB. Use Grafana or other tools to visualize the data."
|
||||
descriptionToken = "Check the InfluxDB documentation to learn how to create one. https://docs.influxdata.com/influxdb/v2/admin/"
|
||||
labelBucket = "Bucket"
|
||||
labelCheckInsecure = "Allow self-signed certificates"
|
||||
labelDatabase = "Database"
|
||||
labelInsecure = "Certificate validation"
|
||||
labelOrg = "Organization"
|
||||
labelPassword = "Password"
|
||||
labelToken = "API Token"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
|
|
@ -27,7 +28,7 @@ type Influx struct {
|
|||
}
|
||||
|
||||
// NewInfluxClient creates new publisher for influx
|
||||
func NewInfluxClient(url, token, org, user, password, database string) *Influx {
|
||||
func NewInfluxClient(url, token, org, user, password, database string, insecure bool) *Influx {
|
||||
log := util.NewLogger("influx")
|
||||
|
||||
// InfluxDB v1 compatibility
|
||||
|
|
@ -35,7 +36,11 @@ func NewInfluxClient(url, token, org, user, password, database string) *Influx {
|
|||
token = fmt.Sprintf("%s:%s", user, password)
|
||||
}
|
||||
|
||||
options := influxdb2.DefaultOptions().SetPrecision(time.Second)
|
||||
options := influxdb2.DefaultOptions()
|
||||
|
||||
options.SetTLSConfig(&tls.Config{InsecureSkipVerify: insecure})
|
||||
options.SetPrecision(time.Second)
|
||||
|
||||
client := influxdb2.NewClientWithOptions(url, token, options)
|
||||
|
||||
// handle error logging in writer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue