kapacitor icon indicating copy to clipboard operation
kapacitor copied to clipboard

Failed to send alert data to Alerta: Token is invalid (where as the token is valid)

Open emirozer opened this issue 10 years ago • 7 comments

Latest master deployed with (no prepackaged use, just go build the master kapacitor)

go1.7.3 linux/amd64 64bit Ubuntu 16.04 LTS

kapacitor.conf have the following set:

[alerta]
  enabled = true
  url = "__ALERTA_URL__"
  token = "__ALERTA_TOKEN__"
  environment = "__ALERTA_ENV__"
  origin = "Kapacitor"

This is what we see in the logs:

2016-12-05T11:27:19.54+0100 [App/0] OUT [heartbeat:alert3] 2016/12/05 10:27:18 E! failed to send alert data to Alerta: Token is invalid

I have three remarks:

  • the token is valid. confirmed manually.

  • alerta does not even receive the request to return a 401. so for some reason kapacitor thinks the token is invalid by itself? (tested this by, forking alerta, changing the code slightly to warn whenever it receives a token and the auth result. so that when kapacitor says alerta token is invalid, alerta neither returns 401 nor logs anything) https://github.com/emirozer/alerta/blob/master/alerta/app/auth.py#L50

  • alerta is the latest one in pypi (as of reporting time) https://pypi.python.org/pypi/alerta/4.8.3

Thanks!

emirozer avatar Dec 05 '16 10:12 emirozer

in the logs i can see these btw:

[srv] 2016/12/05 14:40:05 D! opening service: *alerta.Service     
[srv] 2016/12/05 14:40:05 D! opened service: *alerta.Service   

emirozer avatar Dec 05 '16 14:12 emirozer

So i think i have an idea what broke.(NOT CONFIRMED YET) -- Just an educated guess

39b5a8db

At https://github.com/influxdata/kapacitor/commit/39b5a8dbd2b37dea29a671b88e8db1b14d3fc4dc#diff-669ef0be807fb0d87f7b5f88fca10430R194 this line, the auth is being done by the keyword 'Bearer' but this is for OAUTH2 token authentication NOT API_KEY.

So this broke for us because we merely just use http://alerta.readthedocs.io/en/latest/authentication.html#api-keys

So if the 'Bearer' was 'Key' in the alerta service.go, this would work. I think it makes sense because it seems you implemented to use api-key with alerta in the first place.

I am going to test this hopefully and inform you.

emirozer avatar Dec 05 '16 16:12 emirozer

@emirozer That sounds reasonable @allen13 Can you also take a look?

nathanielc avatar Dec 05 '16 17:12 nathanielc

I'll check it out.

allen13 avatar Dec 05 '16 18:12 allen13

@emirozer You are correct. The custom version of golerta I am using uses Bearer instead of Key. This was an oversight on my part. Apologies. I will get a pull request in ASAP.

allen13 avatar Dec 05 '16 18:12 allen13

Pull request in https://github.com/influxdata/kapacitor/pull/1077

allen13 avatar Dec 05 '16 18:12 allen13

thanks for the quick reaction @nathanielc @allen13

emirozer avatar Dec 05 '16 20:12 emirozer