New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE computing statistical widget #4026

Closed
edmundoa opened this Issue Jul 21, 2017 · 0 comments

Comments

Projects
None yet
3 participants
@edmundoa
Member

edmundoa commented Jul 21, 2017

After the Graylog server has been stopped for a while, I'm getting a NPE when computing a statistical widget:

java.lang.NullPointerException: null
	at org.graylog2.indexer.results.FieldStatsResult.<init>(FieldStatsResult.java:50) ~[classes/:?]
	at org.graylog2.indexer.searches.Searches.fieldStats(Searches.java:508) ~[classes/:?]
	at org.graylog2.dashboards.widgets.strategies.StatisticalCountWidgetStrategy.compute(StatisticalCountWidgetStrategy.java:150) ~[classes/:?]
	at org.graylog2.dashboards.widgets.WidgetResultCache$ComputationResultSupplier.get(WidgetResultCache.java:89) ~[classes/:?]
	at org.graylog2.dashboards.widgets.WidgetResultCache$ComputationResultSupplier.get(WidgetResultCache.java:73) ~[classes/:?]
	at com.google.common.base.Suppliers$ExpiringMemoizingSupplier.get(Suppliers.java:227) ~[guava-21.0.jar:?]
	at org.graylog2.dashboards.widgets.WidgetResultCache.getComputationResultForDashboardWidget(WidgetResultCache.java:65) ~[classes/:?]

Looking into the value of the ExtendedStatsAggregation object that raises the exception, this is what I see:
screen shot 2017-07-21 at 12 00 16

This is the widget that the code tries to compute, as seen in MongoDB:

{
  "creator_user_id": "hans", 
  "cache_time": 10,
  "description": "Statistical value",
  "id": "773a22ce-3c17-467e-86cf-ac0f409702e7",
  "type": "STATS_COUNT",
  "config": {
    "timerange": {
      "type": "relative",
      "range": 300
    },
    "field": "took_ms",
    "trend": true,
    "query": "",
    "stats_function": "std_deviation",
    "lower_is_better": true
  }
}

Expected Behavior

Computing statistical widgets should work, even if there are no results because there's no data.

Current Behavior

Computing statistical widgets does not work when there's no data available. At least that's what I read from the results I see.

Steps to Reproduce (for bugs)

  1. Stop the server for double the time the widget is querying (ensuring there's no results for the statistical value)
  2. Start the server and try to get a computation of the widget value
  3. See NPE

Your Environment

  • Graylog Version: 2.4.0-SNAPSHOT, but probably also present in 2.3.0-rc.2-SNAPSHOT
  • Elasticsearch Version: 2.4.4
  • Operating System: macOS Sierra

@edmundoa edmundoa added the bug label Jul 21, 2017

@jalogisch jalogisch added the triaged label Jul 24, 2017

dennisoelkers added a commit that referenced this issue Jul 27, 2017

Return NaN for non-present fields of FieldStatsResult.
Before this change, an ExtendedStatsAggregation could include an
arbitrary number of fields that are null. Assigning them a non-boxed
field type leads to an NPE and a 500 is being returned to the caller
when the result of a extended field stats widget is requested.

This change properly assigns a valid value for those fields, so a result
(albeit possibly containing NaN for one or more fields) is being
returned to the caller.

Fixes #4026.

@wafflebot wafflebot bot added the in progress label Jul 27, 2017

@joschi joschi closed this in #4038 Jul 28, 2017

joschi added a commit that referenced this issue Jul 28, 2017

Return NaN for non-present fields of FieldStatsResult (#4038)
Before this change, an ExtendedStatsAggregation could include an
arbitrary number of fields that are null. Assigning them a non-boxed
field type leads to an NPE and a 500 is being returned to the caller
when the result of a extended field stats widget is requested.

This change properly assigns a valid value for those fields, so a result
(albeit possibly containing NaN for one or more fields) is being
returned to the caller.

Fixes #4026

@wafflebot wafflebot bot removed the in progress label Jul 28, 2017

dennisoelkers added a commit that referenced this issue Aug 2, 2017

Return NaN for non-present fields of FieldStatsResult
Before this change, an ExtendedStatsAggregation could include an
arbitrary number of fields that are null. Assigning them a non-boxed
field type leads to an NPE and a 500 is being returned to the caller
when the result of a extended field stats widget is requested.

This change properly assigns a valid value for those fields, so a result
(albeit possibly containing NaN for one or more fields) is being
returned to the caller.

Fixes #4026

(cherry picked from commit 882727e)

joschi added a commit that referenced this issue Aug 2, 2017

Return NaN for non-present fields of FieldStatsResult (#4046)
Before this change, an `ExtendedStatsAggregation` could include an
arbitrary number of fields that are null. Assigning them a non-boxed
field type leads to an NPE and a 500 is being returned to the caller
when the result of a extended field stats widget is requested.

This change properly assigns a valid value for those fields, so a result
(albeit possibly containing NaN for one or more fields) is being
returned to the caller.

Fixes #4026
Fixes #4045

(cherry picked from commit 882727e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment