influxdata / influxdata/docs-v2
Kapacitor sideload node with URL not explained properly and examples are wrong
- Dominant language
- JavaScript
- Stars
- 82
- Forks
- 326
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 82
Description
The sideload docs at https://docs.influxdata.com/kapacitor/v1.6/nodes/sideload_node/ need some TLC
First, here is a working example of how the sideload node works:
Config to be served:
```
> curl localhost:8080/cool.json
{
"host1-cool-cluster1": {
"cpu_threshold": 99.9,
"disable": "false"
},
"host2-cool-cluster1": {
"cpu_threshold": 85,
"disable": "true"
},
"host2-cool-cluster2": {
"cpu_threshold": 56,
"disable": "false"
},
"env1": {
"cpu_threshold": 50,
"disable": "false"
}
}
```
Tick task:
```
dbrp "test"."autogen"
stream
// Select the CPU measurement from the `telegraf` database.
|from()
.measurement('m0')
|sideload()
.source('http://localhost:8080/cool.json')
.order('{{.host}}-cool-{{.cluster}}', '{{.env}}')
.field('cpu_threshold', 0.0)
|log()
```
Run these commands:
```
> curl -XPOST 'localhost:9092/write?db=test&rp=autogen' --data-binary "m0,host=host1,cluster=cluster1,env=env1 f1=0"
> curl -XPOST 'localhost:9092/write?db=test&rp=autogen' --data-binary "m0,host=host2,cluster=cluster1,env=env1 f1=0"
> curl -XPOST 'localhost:9092/write?db=test&rp=autogen' --data-binary "m0,host=host3,cluster=cluster1,env=env1 f1=0"
> curl -XPOST 'localhost:9092/write?db=test&rp=autogen' --data-binary "m0,host=host3,cluster=cluster1,env=env2 f1=0"
```
From the kapa logs:
```
# The first point matches host1,cluster1 so gives 99.9:
ts=2021-09-01T13:50:15.485-04:00 lvl=info msg=point service=kapacitor task_master=main task=sideload1 node=log3 prefix= name=m0 db=test rp=autogen group= tag_cluster=cluster1 tag_env=env1 tag_host=host1 field_f1=0 field_cpu_threshold=99.9 time=2021-09-01T17:50:15.485173Z
# The second point matches host2,cluster1 so gives 85
ts=2021-09-01T13:50:33.525-04:00 lvl=info msg=point service=kapacitor task_master=main task=sideload1 node=log3 prefix= name=m0 db=test rp=autogen group= tag_cluster=cluster1 tag_env=env1 tag_host=host2 field_f1=0 field_cpu_threshold=85 time=2021-09-01T17:50:33.524905Z
# The third point doesn't match any {{host}}-cool-{{cluster}} pattern, but env is env1 so we get 50
ts=2021-09-01T13:50:45.033-04:00 lvl=info msg=point service=kapacitor task_master=main task=sideload1 node=log3 prefix= name=m0 db=test rp=autogen group= tag_cluster=cluster1 tag_env=env1 tag_host=host3 field_f1=0 field_cpu_threshold=50 time=2021-09-01T17:50:45.033446Z
# The fourth point doesn't match anything so we get the default from the tick script.
ts=2021-09-01T13:50:54.072-04:00 lvl=info msg=point service=kapacitor task_master=main task=sideload1 node=log3 prefix= name=m0 db=test rp=autogen group= tag_cluster=cluster1 tag_env=env2 tag_host=host3 field_f1=0 field_cpu_threshold=0 time=2021-09-01T17:50:54.072385Z
```
## What needs to change
This current example of URL configuration seems to imply that there are different `*.yml` files involved - in fact we expect one json file to be returned, and the templates in `.order()` define how to construct keys in that json file.
```
|sideload()
.source('http://localhost:5000/threshold/')
.order('host/{{.host}}.yml', 'hostgroup/{{.hostgroup}}.yml')
.field('cpu_threshold', 0.0)
.tag('foo', 'unknown')
```
Also, it is valid to have more than one template key. The docs suggest:
```
An HTTP source endpoint should return a JSON object where each property is a key name specified in the order statement and its value is an object with a set of key-value pairs.
```
But to make this work the order would have to be something like `.order("{{.mykey}}")` and also this doesn't explain how to support multi-key matches like in the example above.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.