Custom Rule using Scripted Field

Is it possible to create an ML job with custom rule referencing a scripted field? I'm trying to skip results during a certain period of the day. Running 6.6 Here are the relevant snippets:

In the datafeed_config section I've got this, which seems to work:
"script_fields": {
"timestamp_hour": {
"script": {
"lang": "painless",
"inline": "doc['@timestamp'].value.getHourOfDay()"

In the detectors section I've got this, which throws an error:
"custom_rules": [{
"actions": ["skip_result"],
"conditions": [
"applies_to": "timestamp_hour",
"operator": "lt",
"value": 12

Error: [rule_condition] failed to parse field [applies_to]

Why not use calendar events to ignore the timeframes that you want?

It's my understanding that calendar events are for specific date/times. I'm looking for recurring daily time-of-day rules. Am I misunderstanding the calendar event?

Yes, the calendar events allow you to ignore specific dates/times and there currently is no "recurring" option at the moment (would be a nice feature request you could add).

However, with that said, the calendar event does have an API, you can programmatically add many at once or one per day with a scheduled script/cron job

Just a thought...

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.