Graylog2 / graylog2-server

Free and open log management
https://www.graylog.org
Other
7.41k stars 1.07k forks source link

Absolute Dashboard Widgets Cause 500 Error #884

Closed traviscosgrave closed 9 years ago

traviscosgrave commented 9 years ago

Adding a widget built from an absolute search seems to be causing a 500 error when visiting the Dashboards page and when attempting to edit a user(?!).

The offending component seem to be in the widget's config.timerange, regardless of the dates chosen. Below is an offending document. If I change the time range to be relative everything is happy again.

{
    "_id" : ObjectId("54b59a63e4b09224d4442f37"),
    "created_at" : ISODate("2015-01-13T22:21:23.202Z"),
    "creator_user_id" : "viewlogs",
    "description" : "A Test Dashboard",
    "title" : "Test Dashboard",
    "widgets" : [ 
        {
            "id" : "5bc3f514-6a0a-4df5-8f78-ea18b039f221",
            "description" : "Count",
            "config" : {
                "query" : "message:\"ERROR\"",
                "timerange" : {
                    "to" : ISODate("2015-01-01T00:00:00.000Z"),
                    "from" : ISODate("2015-01-01T22:05:59.807Z"),
                    "type" : "absolute"
                }
            },
            "cache_time" : 10,
            "creator_user_id" : "admin",
            "type" : "search_result_count"
        }
    ]
}

The error thrown in graylog2-server is really gross. After checking my user for permissions hundreds of times in the same second... for example

2015-01-15 16:18:36,279 DEBUG: org.graylog2.security.realm.MongoDbAuthorizationRealm - User travis.cosgrave has permissions: [ "*"]
2015-01-15 16:18:36,279 DEBUG: org.graylog2.security.realm.MongoDbAuthorizationRealm - Retrieving authorization information for travis.cosgrave
2015-01-15 16:18:36,279 DEBUG: org.graylog2.users.UserServiceImpl - Loading user travis.cosgrave
2015-01-15 16:18:36,280 DEBUG: org.graylog2.users.UserServiceImpl - Loaded user travis.cosgrave/5419ab5221534dedf02d9e56 from MongoDB
2015-01-15 16:18:36,280 DEBUG: org.graylog2.security.realm.MongoDbAuthorizationRealm - User travis.cosgrave has permissions: [ "*"]
2015-01-15 16:18:36,280 DEBUG: org.graylog2.security.realm.MongoDbAuthorizationRealm - Retrieving authorization information for travis.cosgrave
2015-01-15 16:18:36,280 DEBUG: org.graylog2.users.UserServiceImpl - Loading user travis.cosgrave

I get the following:

2015-01-15 16:18:36,285 ERROR: org.graylog2.jersey.container.netty.NettyContainer - Uncaught exception in transport layer. This is likely a bug, closing channel.
java.lang.StackOverflowError
        at com.fasterxml.jackson.databind.ObjectMapper._serializerProvider(ObjectMapper.java:2831)
        at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:1887)
        at com.fasterxml.jackson.core.base.GeneratorBase.writeObject(GeneratorBase.java:239)
        at org.mongojack.internal.DateSerializer.serialize(DateSerializer.java:37)
        at org.mongojack.internal.DateSerializer.serialize(DateSerializer.java:33)
        at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:114)
        at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:1887)
        at com.fasterxml.jackson.core.base.GeneratorBase.writeObject(GeneratorBase.java:239)
        at org.mongojack.internal.DateSerializer.serialize(DateSerializer.java:37)
       at org.mongojack.internal.DateSerializer.serialize(DateSerializer.java:33)
edmundoa commented 9 years ago

Hello, Thank you for reporting this issue. Could you please specify the Graylog version you are using?

traviscosgrave commented 9 years ago

0.92.3 On Jan 15, 2015 5:41 PM, "Edmundo Alvarez" notifications@github.com wrote:

Hello, Thank you for reporting this issue. Could you please specify the Graylog version you are using?

— Reply to this email directly or view it on GitHub https://github.com/Graylog2/graylog2-server/issues/884#issuecomment-70176538 .

edmundoa commented 9 years ago

The first odd thing I saw is that the from and to fields in the widget seem to be swapped (from is after to in your example). Anyway, I was trying to break the dashboard creating a widget like that and I couldn't.

Could you please include more information about the users involved? In the data you attached, I see that the dashboard was created by viewlogs, the widget itself by admin, and you are accessing them using your user travis.cosgrave. My concrete questions are if all these users still exist and which permissions they have.

Thank you again.

traviscosgrave commented 9 years ago

I am currently running 0.92.3, but plan to update to 0.92.4 today.

I took a look at the users and made sure that I was only working with two, admin (the local one as defined in /etc/graylog2.conf) and viewlogs. Both exist and both have admin powers.

I've also gone back to the initial dashboard that was causing the problems (instead of the one I mangled while debugging...).

{
    "_id" : ObjectId("54b59a63e4b09224d4442f37"),
    "created_at" : ISODate("2015-01-13T22:21:23.202Z"),
    "creator_user_id" : "viewlogs",
    "description" : "A dashboard for testing",
    "title" : "Test Dashboard",
    "widgets" : [ 
        {
            "id" : "59befc6e-f26e-4369-84bb-1db650f6f6a9",
            "description" : "Absolute Widget",
            "config" : {
                "interval" : "month",
                "query" : "*",
                "timerange" : {
                    "to" : ISODate("2015-05-01T04:00:00.000Z"),
                    "from" : ISODate("2014-10-26T17:18:33.000Z"),
                    "type" : "absolute"
                }
            },
            "cache_time" : 10,
            "creator_user_id" : "viewlogs",
            "type" : "search_result_chart"
        }
    ]
}

I do have two independant graylog2 packs. So I tried creating everything again with the same results.

If I remove the widget from the dashboard I do not receive the error.

The error is thrown when visiting /system (although the system page works), and it is thrown when editing a user (which renders the page unuseable).

The created Dashboard looks like this:

{
    "_id" : ObjectId("54b926b3e4b02ca7784fab4c"),
    "created_at" : ISODate("2015-01-16T14:56:51.279Z"),
    "creator_user_id" : "admin",
    "description" : "A Test Dashboard for an Absolute Widget",
    "title" : "Test for Absolute Widget",
    "widgets" : [ 
        {
            "id" : "569d20aa-5c15-4618-bc64-bf894f3f1efe",
            "description" : "Absolute Message Count",
            "config" : {
                "query" : "*",
                "timerange" : {
                    "to" : ISODate("2015-01-16T14:56:56.634Z"),
                    "from" : ISODate("2015-01-16T14:56:51.783Z"),
                    "type" : "absolute"
                }
            },
            "cache_time" : 10,
            "creator_user_id" : "admin",
            "type" : "search_result_count"
        }
    ]
}
edmundoa commented 9 years ago

I could reproduce the issue using 0.92.4, although it is already fixed on the 1.0 branch. As there are not more planned 0.92 releases, I think you have to wait until 1.0 is released.

Please give Graylog 1.0 beta a try: https://www.graylog2.org/news/post/0014-graylog-v1-0-0-beta1