influxdata / influxdata/kapacitor
The 'hostname' in config not working when using docker
- Dominant language
- Go
- Stars
- 2.4k
- Forks
- 479
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 4
Description
I have a influxdb container on '192.168.0.1:8086'.
Then I start a kapacitor container with `kapacitor:latest`:
```
docker run -p 9092:9092 \
-v $PWD/kapacitor.conf:/etc/kapacitor/kapacitor.conf:ro \
kapacitor
```
Here is my config
```
httppost = []
hostname = "192.168.0.1"
data_dir = "/var/lib/kapacitor"
skip-config-overrides = false
default-retention-policy = ""
[http]
bind-address = ":9092"
auth-enabled = false
log-enabled = true
write-tracing = false
pprof-enabled = false
https-enabled = false
https-certificate = "/etc/ssl/kapacitor.pem"
shutdown-timeout = "10s"
shared-secret = ""
[replay]
dir = "/var/lib/kapacitor/replay"
[storage]
boltdb = "/var/lib/kapacitor/kapacitor.db"
[task]
dir = "/root/.kapacitor/tasks"
snapshot-interval = "1m0s"
[[influxdb]]
enabled = true
name = "default"
default = true
urls = ["http://192.168.0.1:8086"]
username = "admin"
password = "admin"
ssl-ca = ""
ssl-cert = ""
ssl-key = ""
insecure-skip-verify = false
timeout = "0s"
disable-subscriptions = false
subscription-protocol = "http"
kapacitor-hostname = ""
http-port = 0
udp-bind = ""
udp-buffer = 1000
udp-read-buffer = 0
startup-timeout = "5m0s"
subscriptions-sync-interval = "1m0s"
[influxdb.excluded-subscriptions]
_kapacitor = ["autogen"]
```
but in influxdb , I got this:
```
name: _internal
retention_policy name mode destinations
---------------- ---- ---- ------------
monitor kapacitor-f5d7399f-5876-417f-ad24-9a227042f67c ANY [http://ef412dbdc801:9092]
```
I try to change the host value to 'kapacitor', but got another:
```
name: _internal
retention_policy name mode destinations
---------------- ---- ---- ------------
monitor kapacitor-ad4dc3b6-1f8c-46d6-b506-62241a1702bd ANY [http://aa121f1b601d:9092]
```
Finally I try this, and it works:
```
docker run -p 9092:9092 \
-v $PWD/kapacitor.conf:/etc/kapacitor/kapacitor.conf:ro \
-e KAPACITOR_HOSTNAME=192.168.0.1 kapacitor
```
The result:
```
name: _internal
retention_policy name mode destinations
---------------- ---- ---- ------------
monitor kapacitor-e0d48f68-1159-4f07-a2e3-b3c021d8bee0 ANY [http://192.168.0.1:9092]
```
:smile::smile:
Contributor guide
Research direction
Start by comparing the hostname setting in kapacitor.conf with the KAPACITOR_HOSTNAME environment override used in the Docker command. Reproduce the container setup and inspect the resulting InfluxDB subscription destination. Done means the hostname from kapacitor.conf is honored without requiring the environment variable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100