influxdata / influxdata/kapacitor

Variable Field Names

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

Description

I can accomplish this task by having seperate tick scripts, but since the scripts are doing the same thing but on different fields of a measurement, I figured I would combine them into one TICK script.

The issue I am having is two fold.

1 )AWS CW metrics sometimes will push out metrics that do not have the all fields populated. i.e. one point may have a tag for "domain_name" but the field names vary all over the place, so I needed to filter out only the points that have a "domain_name" and "cluster_status.yellow_maximum" or "cluster_status.red_maximum" So I am doing a eval/keep to filter that out. This works fine as long as I don't use a variable for the field, i.e.
```
|eval(lambda: "domain_name", lambda: "cluster_status.yellow_maximum")
.as('_domain_name', '_cluster_status')
.keep()
.quiet()
```
So problem #1 solved.

2) Now the variable issue if I want to have a single TICK script the above would be:
```
|eval(lambda: "domain_name", lambda: measurement_field)
.as('_domain_name', '_cluster_status')
.keep()
.quiet()
```
where measurement_field is a variable, a string to be exact.
```
var measurement_field = "cluster_status.yellow_maximum"
```
Now this means that the metrics push into the next node would the proper domain name, but simply the string value of "measurement_field"
```
[elasticsearch_status-yellow:log5] 2017/01/23 20:33:48 I! {"Name":"cloudwatch_aws_es","Database":"local","RetentionPolicy":"default","Group":"","Dimensions":{"ByName":false,"TagNames":null},"Tags":{"deployment":"local","domain_name":"test"},"Fields":{"_cluster_status":"cluster_status.yellow_maximum","_domain_name":"test","cluster_status.yellow_maximum":1},"Time":"2017-01-23T20:33:48.51813888Z"}
```

So my question is in a lambda expression, how do I go about expanding the variable variable? Kinda
like a double eval??

I am running kapacitor 1.1.1

Any help would be greatly appreciated.

Contributor guide

Open the contributing guide

Research direction

No repository file, test, or entry point is named. Start by reproducing the TICK 1.1.1 eval/keep example with a literal field and with measurement_field; done means the variable selects the intended measurement field rather than emitting the variable name as a value.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.