influxdata / influxdata/kapacitor
httppost templating, incompatible types for comparison
- Dominant language
- Go
- Stars
- 2.4k
- Forks
- 479
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 4
Description
Hi, Im having some problem with the following template:
kapacitor version
`Kapacitor 1.4.0-rc1 (git: master 211cce44e9f7fa9b18c6c7c0a185469219a3adb1)`
kapacitor.conf
```
...
[[httppost]]
endpoint = "test"
url = "http://127.0.0.1:1234"
alert-template = "{{ if eq .Level \"CRITICAL\" }}3{{ end }}"
```
logs
```
ts=2017-11-14T12:03:00.114Z lvl=debug msg="alert triggered" service=kapacitor task_master=main task=test node=alert3 level=CRITICAL id=test:host=test event_message="test" data="&{system map[host:test] [time last] [[2017-11-14 12:03:00 +0000 UTC 18074]]}"
ts=2017-11-14T12:03:00.115Z lvl=error msg="failed to execute alert template" service=httppost handler=test topic=test err="template: body:1:7: executing \"body\" at : error calling eq: incompatible types for comparison"
```
When im just printing it out, like ` alert-template = "{{ .Level }}"` it works fine
Am I doing something wrong here ?
Contributor guide
Research direction
Start with the httppost alert-template handling and reproduce the reported configuration on Kapacitor 1.4.0-rc1. Check why comparing .Level with "CRITICAL" produces an incompatible-types error while printing .Level works. Done means the comparison behaves as intended and the template emits 3 for a CRITICAL alert.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100