Unable to get externally-created subscriptions working
According to this issue:
https://github.com/influxdata/kapacitor/issues/349
... it's possible to create subscriptions with the name:
kapacitor-(cluster-id)
...configured however one likes (UDP, HTTP, etc) and kapacitor will use whatever is configured in the subscription configuration, rather than kapacitor itself creating a subscription & listener on a 'random' port.
In my case, I run a few prepared queries against influxdb to seed the needed subscriptions before kapacitor starts.
After my prepared queries run, if I "SHOW SUBSCRIPTIONS" in influxdb, I see this:
// My custom database platform-metrics "kapacitor-platform-monitoring" "ALL" udp://instance1:46661
// _Internal database monitor "kapacitor-platform-monitoring" "ALL" udp://instance1:46662
Soon after, Kapactor is launched:
'##:::'##::::'###::::'########:::::'###:::::'######::'####:'########::'#######::'########:: ##::'##::::'## ##::: ##.... ##:::'## ##:::'##... ##:. ##::... ##..::'##.... ##: ##.... ##: ##:'##::::'##:. ##:: ##:::: ##::'##:. ##:: ##:::..::: ##::::: ##:::: ##:::: ##: ##:::: ##: #####::::'##:::. ##: ########::'##:::. ##: ##:::::::: ##::::: ##:::: ##:::: ##: ########:: ##. ##::: #########: ##.....::: #########: ##:::::::: ##::::: ##:::: ##:::: ##: ##.. ##::: ##:. ##:: ##.... ##: ##:::::::: ##.... ##: ##::: ##:: ##::::: ##:::: ##:::: ##: ##::. ##:: ##::. ##: ##:::: ##: ##:::::::: ##:::: ##:. ######::'####:::: ##::::. #######:: ##:::. ##: ..::::..::..:::::..::..:::::::::..:::::..:::......:::....:::::..::::::.......:::..:::::..::
2016/08/03 22:01:58 Using configuration at: /opt/kapacitor/conf/kapacitor.conf
[run] 2016/08/03 22:01:58 I! Kapacitor starting, version 1.0.0~beta4, branch master, commit 1e00423551591862b11f70b5fc59a47300ef596c
[run] 2016/08/03 22:01:58 I! Go version go1.6.2
[srv] 2016/08/03 22:01:58 I! Kapacitor hostname: ...instance1...
[srv] 2016/08/03 22:01:58 I! ClusterID: platform-monitoring ServerID: 30-135
[task_master:main] 2016/08/03 22:01:58 I! opened
[srv] 2016/08/03 22:01:58 D! opening service: *udf.Service
[srv] 2016/08/03 22:01:58 D! opened service: *udf.Service
[srv] 2016/08/03 22:01:58 D! opening service: *deadman.Service
[srv] 2016/08/03 22:01:58 D! opened service: *deadman.Service
[srv] 2016/08/03 22:01:58 D! opening service: *storage.Service
[srv] 2016/08/03 22:01:58 D! opened service: *storage.Service
[srv] 2016/08/03 22:01:58 D! opening service: *noauth.Service
[srv] 2016/08/03 22:01:58 D! opened service: *noauth.Service
[srv] 2016/08/03 22:01:58 D! opening service: *influxdb.Service
[influxdb] 2016/08/03 22:01:58 D! linking subscriptions
[srv] 2016/08/03 22:01:59 D! opened service: *influxdb.Service
[srv] 2016/08/03 22:01:59 D! opening service: *task_store.Service
[task_store] 2016/08/03 22:01:59 W! could not open old boltd for task_store. Not performing migration. Remove the task_store.dir configuration to disable migration.
[srv] 2016/08/03 22:01:59 D! opened service: *task_store.Service
[srv] 2016/08/03 22:01:59 D! opening service: *replay.Service
[srv] 2016/08/03 22:01:59 D! opened service: *replay.Service
[srv] 2016/08/03 22:01:59 D! opening service: *stats.Service
[stats] 2016/08/03 22:01:59 I! opened service
[srv] 2016/08/03 22:01:59 D! opened service: *stats.Service
[srv] 2016/08/03 22:01:59 D! opening service: *reporting.Service
[srv] 2016/08/03 22:01:59 D! opened service: *reporting.Service
[srv] 2016/08/03 22:01:59 D! opening service: *httpd.Service
[httpd] 2016/08/03 22:01:59 I! Starting HTTP service
[httpd] 2016/08/03 22:01:59 I! Authentication enabled: false
[httpd] 2016/08/03 22:01:59 I! Listening on HTTP: [::]:9092
[srv] 2016/08/03 22:01:59 D! opened service: *httpd.Service
[run] 2016/08/03 22:01:59 I! Listening for signals
Kapacitor overwrites the two subscriptions leaving influxdb looking like this:
// My custom database platform-metrics "kapacitor-platform-monitoring" "ANY" http://instance1:9092
// _internal retention_policy name mode destinations monitor "kapacitor-platform-monitoring" "ANY" http://instance1:9092
How is this external seeding of kapacitor subscriptions supposed to work?
TIA
Change the subscription-protocol config option to udp so that Kapacitor doesn't think the udp based subscriptions are invalid. Then it will leave them alone.
Thanks. I didn't spot the subscription-protocol configuration option but now see it.
However, instead of changing to UDP, I tried to pre-create an HTTP subscription on a different port, i.e.:
platform-metrics "kapacitor-platform-monitoring" "ALL" http://instance1:46661
... but once again, when kapacitord starts, this is what influxdb "show subscriptions" shows:
platform-metrics "kapacitor-platform-monitoring" "ANY" http://instance1:9092
The debug output shows
...[httpd] 2016/08/03 23:45:34 I! Listening on HTTP: [::]:9092...
Am I missing some other configuration options to set the port explicitly or perhaps there is something else my config is missing that affects this?
Thanks again - I am sure it's a case of stupid user so appreciate the advice :)
Hmm, perhaps:
`
[http] # HTTP API Server for Kapacitor # This server is always on, # it servers both as a write endpoint # and as the API endpoint for all other # Kapacitor calls. bind-address = ":9092" ~
Edit: Bingo, that was it. The Http bind-address port of course has to match the subscription, otherwise influxdb cannot send http messages to kapacitor. Makes sense.
@mrwilby can this bind-address be provided at the time of running kapacitord from command line?
@mdamir Yes, all config options can be set via an env variable. In this case KAPACITOR_HTTP_BIND_ADDRESS=':9092'
@nathanielc lets say my kapacitor is running as a docker container, so that it runs on 9092 but externally, it has to be connected on some other port, say 8086 of the host. My system has a limitation that i can not provide a same port mapping between host and container (i.e. 9092:9092). In this case, if I set KAPACITOR_HTTP_BIND_ADDRESS to 9092, then influxdb will start communicating with this kapacitor on 9092, and hence will fail (it has to connect to port 8086). Do you think currently, there is a solution for this?
Ideally, there should be a configuration where kapacitor should specify the influx subscription destination.
@mdamir You are correct that if the external facing port is different than the locally bound port its not possible to use subscriptions in the current state.
I have created an issue to track fixing this #886
@nathanielc Where can I get list of all env variables defined in the kapacitor.conf file. I want to be able to override these config values through ENVs. Specifically, I am interested in the influx db endpoints.
@mdamir All config options can be overridden using the env vars.
The env var name should be KAPACIOTR_{SECTION_NAME}_{OPTION_NAME}. Here are the relevant docs for InfluxDB but the same pattern/logic holds for Kapacitor https://docs.influxdata.com/influxdb/v1.0/administration/config/#environment-variables
We don't have an enumeration of all ENV vars for Kapacitor at the moment.