influxdata / influxdata/kapacitor

Templating for HTTP Request Headers

Open
#2,133 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
2.4k
Forks
479
Avg merge
4d 16h
Merged PRs (30d)
4

Description

Currently, one can have templating in the request body for the alert, but we cannot have a templated value in request header.

For example, to add a templated message in alert, one can do the following:
```
var alert = data
|alert()
.id('{{ index .Tags "host"}}/mem_used_percent')
.message('{{ .ID }}:{{ index .Fields "stat" }}')
```

**Our use case is to send team-name information as part of the request.**
The team name information is stored in influx and it will be available in the tags, as you can see below.

```
var data = stream
|from()
.measurement('mem')
.where(exclusion_list)
.groupBy('host', 'team')
```

Is there a way to templatize the headers like below:

```
alert
.log('/tmp/mem_alert_log.txt')
.post('http://my-service/some-url')
.header('Team-Name', '{{ index .Tags "team" }}')
```

Contributor guide

Open the contributing guide

Research direction

Start by tracing the alert .header() and .post() entry points, then compare them with the existing templating path for request bodies. Done means a header value such as '{{ index .Tags "team" }}' is rendered from alert data and covered by tests for templated HTTP headers.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, observability
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.