My data coming into Telegraf:
{
"fields": {
"description": "desc goes here"
},
"name": "measurement name",
"tags": {
"host": "hostname",
"name": "interface-name",
"path": "",
"source": "source-name"
},
"timestamp": 1628116374
}
I want to filter out metrics that have timestamps that are older than 24hrs. My starlark stanza looks like this:
[[processors.starlark]]
namepass = ["interfaces"]
source = '''
load('time.star', 'time')
def apply(metric):
curDate = time.now().unix
metric_date = time.from_timestamp(int(metric.time / 1e9))
if metric_date >= curDate - time.parse_duration("24h") :
return metric
However, this is giving me the following errors:
2021-08-13T19:06:46Z E! [processors.starlark] Error: unknown binary op: int - time.duration
2021-08-13T19:06:46Z E! [processors.starlark] Error in plugin: unknown binary op: int - time.duration
I think time.from_timestamp() returns an int64, and I believe the curDate var might be an int type. Since those are two separate types Go isn’t allowing the math to happen?