Graylog2 / graylog2-server

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

AddGl2MessageIdFieldAliasForEvents fails when starting with an empty Elasticsearch node #9148

Closed bernd closed 4 years ago

bernd commented 4 years ago

I just started a new Graylog test setup (empty MongoDB and ES) and got the following error in my log:

2020-10-13 15:12:48,225 ERROR: org.graylog2.periodical.ConfigurationManagementPeriodical - Error while running migration <V20200730000000_AddGl2MessageIdFieldAliasForEvents{2020-07-30T00:00:00Z}>
org.graylog.shaded.elasticsearch7.org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=index_not_found_exception, reason=no such index [gl-events*]]
    at org.graylog.shaded.elasticsearch7.org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:187) ~[elasticsearch7-7.9.1-0.jar:?]
    at org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1892) ~[elasticsearch7-7.9.1-0.jar:?]
    at org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:1869) ~[elasticsearch7-7.9.1-0.jar:?]
    at org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1626) ~[elasticsearch7-7.9.1-0.jar:?]
    at org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1598) ~[elasticsearch7-7.9.1-0.jar:?]
    at org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1565) ~[elasticsearch7-7.9.1-0.jar:?]
    at org.graylog.shaded.elasticsearch7.org.elasticsearch.client.IndicesClient.putMapping(IndicesClient.java:353) ~[elasticsearch7-7.9.1-0.jar:?]
    at org.graylog.storage.elasticsearch7.views.migrations.V20200730000000_AddGl2MessageIdFieldAliasForEventsES7.addGl2MessageIdFieldAlias(V20200730000000_AddGl2MessageIdFieldAliasForEventsES7.java:37) ~[classes/:?]
    at org.graylog.plugins.views.migrations.V20200730000000_AddGl2MessageIdFieldAliasForEvents.upgrade(V20200730000000_AddGl2MessageIdFieldAliasForEvents.java:75) ~[classes/:?]
    at org.graylog2.periodical.ConfigurationManagementPeriodical.doRun(ConfigurationManagementPeriodical.java:43) [classes/:?]
    at org.graylog2.plugin.periodical.Periodical.run(Periodical.java:77) [classes/:?]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_265]
    Suppressed: org.graylog.shaded.elasticsearch7.org.elasticsearch.client.ResponseException: method [PUT], host [http://127.0.0.1:9220], URI [/gl-events*,gl-system-events*/_mapping?master_timeout=30s&ignore_unavailable=false&expand_wildcards=open%2Cclosed&allow_no_indices=false&ignore_throttled=false&timeout=30s], status line [HTTP/1.1 404 Not Found]
{"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index [gl-events*]","resource.type":"index_or_alias","resource.id":"gl-events*","index_uuid":"_na_","index":"gl-events*"}],"type":"index_not_found_exception","reason":"no such index [gl-events*]","resource.type":"index_or_alias","resource.id":"gl-events*","index_uuid":"_na_","index":"gl-events*"},"status":404}
        at org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RestClient.convertResponse(RestClient.java:302) ~[elasticsearch7-7.9.1-0.jar:?]
        at org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RestClient.performRequest(RestClient.java:272) ~[elasticsearch7-7.9.1-0.jar:?]
        at org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RestClient.performRequest(RestClient.java:246) ~[elasticsearch7-7.9.1-0.jar:?]
        at org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1613) ~[elasticsearch7-7.9.1-0.jar:?]
        at org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1598) ~[elasticsearch7-7.9.1-0.jar:?]
        at org.graylog.shaded.elasticsearch7.org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1565) ~[elasticsearch7-7.9.1-0.jar:?]
        at org.graylog.shaded.elasticsearch7.org.elasticsearch.client.IndicesClient.putMapping(IndicesClient.java:353) ~[elasticsearch7-7.9.1-0.jar:?]
        at org.graylog.storage.elasticsearch7.views.migrations.V20200730000000_AddGl2MessageIdFieldAliasForEventsES7.addGl2MessageIdFieldAlias(V20200730000000_AddGl2MessageIdFieldAliasForEventsES7.java:37) ~[classes/:?]
        at org.graylog.plugins.views.migrations.V20200730000000_AddGl2MessageIdFieldAliasForEvents.upgrade(V20200730000000_AddGl2MessageIdFieldAliasForEvents.java:75) ~[classes/:?]
        at org.graylog2.periodical.ConfigurationManagementPeriodical.doRun(ConfigurationManagementPeriodical.java:43) [classes/:?]
        at org.graylog2.plugin.periodical.Periodical.run(Periodical.java:77) [classes/:?]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_265]

We probably need to add a check to avoid running when there are no indices.

dennisoelkers commented 4 years ago

I guess we can just skip this migration (and mark it completed) if the events index does not exist?

bernd commented 4 years ago

I guess we can just skip this migration (and mark it completed) if the events index does not exist?

@dennisoelkers As far as I understand, the migration is adding a field alias to existing indices. So yeah, if there a no indices, we don't need the migration. :+1: