Connecting influxdb 2.0 with Kapacitor OSS version 1.5.9

Hello all,

I am trying to connect Kapacitor OSS version 1.5.9 with InfluxDB 2.0.4

I am following Use Kapacitor with InfluxDB OSS [1] along with the additional comments in How to configure kapacitor v.1.5 to influxdb 2.0 with token [2]

As described in [2] I have created a dbrp and auth using influx

$ influx v1 dbrp create --org myorg --db telegraf --rp 30days --bucket-id d3d999f5ba713ad3
ID                      Database        Bucket ID               Retention Policy        Default Organization ID
07738569db7fa000        telegraf        d3d999f5ba713ad3        30days                  false   1fbb239dff290f87

$ influx v1 auth create --org myorg --username kapacitorv1 --password myorg123 --write-bucket d3d999f5ba713ad3 --read-bucket d3d999f5ba713ad3
ID                      Description     Name / Token    User Name       User ID                 Permissions
077385be08bfa000                        kapacitorv1     admin          07629ab16d4f6000        [read:orgs/1fbb239dff290f87/buckets/d3d999f5ba713ad3 write:orgs/1fbb239dff290f87/buckets/d3d999f5ba713ad3]

in kapacitor.conf [[influxdb]] section, I have changed username and password with the newly created username and password. Edited disable-subscriptions to true

[[influxdb]]
  enabled = true
  name = "localhost"
  default = true
  urls = ["http://localhost:8086"]
  username = "kapacitorv1"
  password = "myorg123"
  ssl-ca = ""
  ssl-cert = ""
  ssl-key = ""
  insecure-skip-verify = false
  timeout = "0s"
  disable-subscriptions = true
  subscription-protocol = "http"
  subscription-mode = "cluster"
  kapacitor-hostname = ""
  http-port = 0
  udp-bind = ""
  udp-buffer = 1000
  udp-read-buffer = 0
  startup-timeout = "5m0s"
  subscriptions-sync-interval = "1m0s"
  subscription-path = ""
  compression = "none"
  [influxdb.subscriptions]
  [influxdb.excluded-subscriptions]
    _kapacitor = ["autogen"]

After running Kapacitor, when I create a TICK script, I get the following error:

$ kapacitor define cpu-alert -tick cpu-alert.tick
unable to parse authentication credentials

Logs show the following:

ts=2021-04-30T06:46:10.922+05:30 lvl=info msg="http request" service=http host=::1 username=- start=2021-04-30T06:46:10.92228 method=GET uri=/kapacitor/v1/tasks/cpu-alert?dot-view=attributes&replay-id=&script-format=formatted protocol=HTTP/1.1 status er=- user-agent=KapacitorClient request-id=a61be3a2-a951-11eb-8001-000000000000 duration=640.966µs
ts=2021-04-30T06:46:10.925+05:30 lvl=info msg="http request" service=http host=::1 username=- start=2021-04-30T06:46:10.92450 method=POST uri=/kapacitor/v1/tasks protocol=HTTP/1.1 status=401 referer=- user-agent=KapacitorClient request-id=a61c3ab5-a902-000000000000 duration=894.142µs

Kind of stuck here, as I believe I have correctly followed all steps. Any help in moving forward would be much appreciated!

Thanks!

X.

After digging some more, I think I have found what is wrong:

The error comes from parseCredentials function and it expects credentials in the following format:

// parseCredentials parses a request and returns the authentication credentials.
// The credentials may be present as URL query params, or as a Basic
// Authentication header.
// As params: http://127.0.0.1/query?u=username&p=token
// As basic auth: http://username:token@127.0.0.1
// As Token in Authorization header: Token <username:token>

while kapacitor sends the following URL to kapacitord

GET /kapacitor/v1/tasks/cpu-alert?dot-view=attributes&replay-id=&script-format=formatted HTTP/1.1

and kapacitord returns with

"error":"unable to parse authentication credentials"

Now the problem reduces to how to authenticate kapacitor with kapacitord

auth-enabled = false did the trick for now.

1 Like

@xuoguoto,
Thank you for sharing your solution!!