Browse Source

feat(influxdb): use database auth if provided

closes #6310
bergquist 9 years ago
parent
commit
9429434cb5

+ 0 - 75
docker/blocks/influxdb/config.toml

@@ -1,75 +0,0 @@
-bind-address = "0.0.0.0"
-
-[logging]
-level  = "debug"
-file   = "/opt/influxdb/shared/data/influxdb.log"         # stdout to log to standard out
-
-[admin]
-port   = 8083              # binding is disabled if the port isn't set
-assets = "/opt/influxdb/current/admin"
-
-[api]
-port     = 8086    # binding is disabled if the port isn't set
-
-read-timeout = "5s"
-
-[input_plugins]
-
-  [input_plugins.graphite]
-  enabled = true
-  port = 2004
-  database = "graphite"  # store graphite data in this database
-
-
-[raft]
-port = 8090
-dir  = "/opt/influxdb/shared/data/raft"
-
-[storage]
-dir = "/opt/influxdb/shared/data/db"
-# How many requests to potentially buffer in memory. If the buffer gets filled then writes
-# will still be logged and once the local storage has caught up (or compacted) the writes
-# will be replayed from the WAL
-write-buffer-size = 10000
-default-engine = "rocksdb"
-max-open-shards = 0
-point-batch-size = 100
-write-batch-size = 5000000
-retention-sweep-period = "10m"
-
-[storage.engines.rocksdb]
-max-open-files = 1000
-lru-cache-size = "200m"
-
-[storage.engines.leveldb]
-max-open-files = 1000
-lru-cache-size = "200m"
-
-[cluster]
-protobuf_port = 8099
-protobuf_timeout = "2s" # the write timeout on the protobuf conn any duration parseable by time.ParseDuration
-protobuf_heartbeat = "200ms" # the heartbeat interval between the servers. must be parseable by time.ParseDuration
-protobuf_min_backoff = "1s" # the minimum backoff after a failed heartbeat attempt
-protobuf_max_backoff = "10s" # the maxmimum backoff after a failed heartbeat attempt
-write-buffer-size = 10000
-ax-response-buffer-size = 100000
-oncurrent-shard-query-limit = 10
-
-[sharding]
-  replication-factor = 1
-
-  [sharding.short-term]
-  duration = "7d"
-  split = 1
-
-  [sharding.long-term]
-  duration = "30d"
-  split = 1
-  # split-random = "/^Hf.*/"
-
-[wal]
-dir   = "/opt/influxdb/shared/data/wal"
-flush-after = 1000 # the number of writes after which wal will be flushed, 0 for flushing on every write
-bookmark-after = 1000 # the number of writes after which a bookmark will be created
-index-after = 1000
-requests-per-logfile = 10000

+ 2 - 1
docker/blocks/influxdb/fig

@@ -1,11 +1,12 @@
 influxdb:
-  #image: influxdb/influxdb:1.0-alpine
   image: influxdb:latest
   container_name: influxdb
   ports:
     - "2004:2004"
     - "8083:8083"
     - "8086:8086"
+  volumes:
+    - ./blocks/influxdb/influxdb.conf:/etc/influxdb/influxdb.conf
 
 fake-influxdb-data:
   image: grafana/fake-data-gen

+ 92 - 0
docker/blocks/influxdb/influxdb.conf

@@ -0,0 +1,92 @@
+reporting-disabled = false
+
+[meta]
+  # Where the metadata/raft database is stored
+  dir = "/var/lib/influxdb/meta"
+
+  retention-autocreate = true
+
+  # If log messages are printed for the meta service
+  logging-enabled = true
+  pprof-enabled = false
+
+  # The default duration for leases.
+  lease-duration = "1m0s"
+
+[data]
+  # Controls if this node holds time series data shards in the cluster
+  enabled = true
+
+  dir = "/var/lib/influxdb/data"
+
+  # These are the WAL settings for the storage engine >= 0.9.3
+  wal-dir = "/var/lib/influxdb/wal"
+  wal-logging-enabled = true
+
+
+[coordinator]
+  write-timeout = "10s"
+  max-concurrent-queries = 0
+  query-timeout = "0"
+  log-queries-after = "0"
+  max-select-point = 0
+  max-select-series = 0
+  max-select-buckets = 0
+
+[retention]
+  enabled = true
+  check-interval = "30m"
+
+[shard-precreation]
+  enabled = true
+  check-interval = "10m"
+  advance-period = "30m"
+
+[monitor]
+  store-enabled = true # Whether to record statistics internally.
+  store-database = "_internal" # The destination database for recorded statistics
+  store-interval = "10s" # The interval at which to record statistics
+
+[admin]
+  enabled = true
+  bind-address = ":8083"
+  https-enabled = false
+  https-certificate = "/etc/ssl/influxdb.pem"
+
+[http]
+  enabled = true
+  bind-address = ":8086"
+  auth-enabled = true
+  log-enabled = true
+  write-tracing = false
+  pprof-enabled = false
+  https-enabled = false
+  https-certificate = "/etc/ssl/influxdb.pem"
+  ### Use a separate private key location.
+  # https-private-key = ""
+  max-row-limit = 10000
+  realm = "InfluxDB"
+
+  unix-socket-enabled = false # enable http service over unix domain socket
+  # bind-socket = "/var/run/influxdb.sock"
+
+[subscriber]
+  enabled = true
+
+[[graphite]]
+  enabled = false
+
+[[collectd]]
+  enabled = false
+
+[[opentsdb]]
+  enabled = false
+
+[[udp]]
+  enabled = false
+
+[continuous_queries]
+  log-enabled = true
+  enabled = true
+  # run-interval = "1s" # interval for how often continuous queries will be checked if they need to run
+

+ 5 - 0
pkg/tsdb/influxdb/influxdb.go

@@ -124,10 +124,15 @@ func (e *InfluxDBExecutor) createRequest(query string) (*http.Request, error) {
 	req.URL.RawQuery = params.Encode()
 
 	req.Header.Set("User-Agent", "Grafana")
+
 	if e.BasicAuth {
 		req.SetBasicAuth(e.BasicAuthUser, e.BasicAuthPassword)
 	}
 
+	if e.User != "" {
+		req.SetBasicAuth(e.User, e.Password)
+	}
+
 	glog.Debug("Influxdb request", "url", req.URL.String())
 	return req, nil
 }