GitHub user nickwallen opened a pull request:
https://github.com/apache/metron/pull/721
METRON-1138 Improve Error Message with Bad Profile Expression
I have found that it can be very natural for a new Profiler user to attempt
to reference a field defined in a telemetry message, in a Profile's `groupBy`
expression. Unfortunately, this does not work as the 'groupBy' expression runs
during a flush and has no single telemetry message available in scope.
For example, this seems like a Profile that should work.
```
{
"profile": "calender-effects",
"onlyif": "exists(ip_src_addr) and exists(timestamp)",
"foreach": "ip_src_addr",
"init": { "count": 0 },
"update": { "count": "count + 1" },
"result": "count",
"groupBy": ["DAY_OF_WEEK(timestamp)"]
}
```
Currently, when this expression fails the error message looks-like this,
which is not exactly enlightening.
```
org.apache.metron.stellar.dsl.ParseException: Bad 'groupBy' expression:
Unexpected type:
expected=Object,
actual=null,
expression=DAY_OF_WEEK(timestamp),
profile=calender-effects,
entity=10.0.0.1
```
With this change, additional information is provided.
* The variables that are in-scope is logged in the error message.
* The exact expression that failed is logged. Previously, for the 'init'
and 'update' expressions it wasn't clear which expression failed, if the user
defined multiple.
This should make it much easier to debug for a user. The same error
looks-like the following with the code change.
```
ERROR DefaultProfileBuilder:189 - ...
org.apache.metron.stellar.dsl.ParseException: Bad 'groupBy' expression:
error='Unexpected type: expected=Object, actual=null,
expression=DAY_OF_WEEK(timestamp)', expr='DAY_OF_WEEK(timestamp)',
profile='calendar-effects',
entity='10.0.0.1',
variables-available='[duration, result, profile, start, x, end, entity]'
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/nickwallen/metron METRON-1138
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/metron/pull/721.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #721
----
commit b54db11a28737ca51d5a479ab8b4118a15d3abf2
Author: Nick Allen <[email protected]>
Date: 2017-08-29T14:38:23Z
METRON-1138 Improve Error Message with Bad Profile Expression
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---