Mapper [type] cannot be changed from type [text] to [keyword]

Hello,
I used a opensearch 2.4.1 in my server. If I can try add a alerts(monitor) I use a type “Per document monitor” I receive error: mapper [type] cannot be changed from type [text] to [keyword]

[ERROR][o.o.b.OpenSearchUncaughtExceptionHandler] [node-1] uncaught exception in thread [DefaultDispatcher-worker-1]
java.lang.IllegalArgumentException: mapper [type] cannot be changed from type [text] to [keyword]
at org.opensearch.index.mapper.ParametrizedFieldMapper.merge(ParametrizedFieldMapper.java:112) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.index.mapper.ParametrizedFieldMapper.merge(ParametrizedFieldMapper.java:76) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.index.mapper.ObjectMapper.doMerge(ObjectMapper.java:616) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.index.mapper.RootObjectMapper.doMerge(RootObjectMapper.java:350) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.index.mapper.ObjectMapper.merge(ObjectMapper.java:575) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.index.mapper.RootObjectMapper.merge(RootObjectMapper.java:345) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.index.mapper.Mapping.merge(Mapping.java:129) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.index.mapper.DocumentMapper.merge(DocumentMapper.java:307) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.cluster.metadata.MetadataMappingService$PutMappingExecutor.applyRequest(MetadataMappingService.java:271) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.cluster.metadata.MetadataMappingService$PutMappingExecutor.execute(MetadataMappingService.java:237) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.cluster.service.MasterService.executeTasks(MasterService.java:843) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.cluster.service.MasterService.calculateTaskOutputs(MasterService.java:414) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.cluster.service.MasterService.runTasks(MasterService.java:285) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.cluster.service.MasterService$Batcher.run(MasterService.java:196) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.cluster.service.TaskBatcher.runIfNotProcessed(TaskBatcher.java:176) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.cluster.service.TaskBatcher$BatchedTask.run(TaskBatcher.java:214) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:747) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.common.util.concurrent.PrioritizedOpenSearchThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedOpenSearchThreadPoolExecutor.java:282) ~[opensearch-2.4.1.jar:2.4.1]
at org.opensearch.common.util.concurrent.PrioritizedOpenSearchThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedOpenSearchThreadPoolExecutor.java:245) ~[opensearch-2.4.1.jar:2.4.1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
at java.lang.Thread.run(Thread.java:833) ~[?:?]

can you try help me?
Thank you.

This url from ff
api/alerting/monitors/_execute

I try change index but result only one:
[ERROR][o.o.b.OpenSearchUncaughtExceptionHandler] [node-1] uncaught exception in thread [DefaultDispatcher-worker-1]
java.lang.IllegalArgumentException: mapper [type] cannot be changed from type [text] to [keyword]

Hello!
Any ideas how to fix this bug?

Thanks for your time.

Hi!
Maybe in this issue i need a change a some fields in some index… I do not know how index I need a change for fix this error.
Please help me for this issue.

Thank you! :grinning:

Maybe somehow you can recreate the index that is responsible for monitoring and alerts.
If anyone knows how to do this - please write. Thank you.

Can you please provide payload which is sent from network tab?

Can you also post mappings of index you’re trying to monitor? (my_index/_mapping API)

Hello, yes.
If you can help me, please it. Thanks.

{
  "msg-logs-2023.09" : {
    "mappings" : {
      "properties" : {
        "@timestamp" : {
          "type" : "date"
        },
        "@version" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "alert10" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "alert9" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "alert8" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "alert7" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "alert6" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "alert5" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "alert4" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "aler3" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "aler2" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "alert1" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "application" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "datetime" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "environment" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "event" : {
          "properties" : {
            "original" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            }
          }
        },
        "log_level" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "log_type" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "message" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "platform" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "server" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "service" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "system" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "system_message" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "type" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        }
      }
    }
  }
}

Can you please update to 2.5 version. If error persists after update you can try deleting .opendistro-alerting-config index.

1 Like

Thanks for you answer. I try update my cluster.

I have a similar problem with a 2.6.0 cluster.
Creating monitors fail with:

Alerting error: RemoteTransportException[[coordinator-1][1.1.1.1:9300][indices:admin/mapping/put]]; nested: IllegalArgumentException[mapper [metadata.monitor_id] cannot be changed from type [text] to [keyword]];

Delete index fails with admin keys:
# curl -k --cert ./admin.pem --key ./admin-key.pem -XDELETE "https://localhost:9200/.opendistro-alerting-config"

{"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index [.opendistro-alerting-config]","index":".opendistro-alerting-config","resource.id":".opendistro-alerting-config","resource.type":"index_or_alias","index_uuid":"_na_"}],"type":"index_not_found_exception","reason":"no such index [.opendistro-alerting-config]","index":".opendistro-alerting-config","resource.id":".opendistro-alerting-config","resource.type":"index_or_alias","index_uuid":"_na_"},"status":404}

Full stack trace:

org.opensearch.alerting.util.AlertingException: [coordinator01][1.1.1.1:9300][indices:admin/mapping/put], at org.opensearch.alerting.util.AlertingException$Companion.wrap(AlertingException.kt:70) ~[opensearch-alerting-2.6.0.0.jar:2.6.0.0], at org.opensearch.alerting.transport.TransportIndexMonitorAction$IndexMonitorHandler$start$2.onFailure(TransportIndexMonitorAction.kt:338) [opensearch-alerting-2.6.0.0.jar:2.6.0.0], at org.opensearch.action.support.TransportAction$1.onFailure(TransportAction.java:122) [opensearch-2.6.0.jar:2.6.0], at org.opensearch.action.support.RetryableAction$RetryingListener.onFinalFailure(RetryableAction.java:218) [opensearch-2.6.0.jar:2.6.0], at org.opensearch.action.support.RetryableAction$RetryingListener.onFailure(RetryableAction.java:210) [opensearch-2.6.0.jar:2.6.0], at org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction$AsyncSingleAction$1.handleException(TransportClusterManagerNodeAction.java:298) [opensearch-2.6.0.jar:2.6.0], at org.opensearch.transport.TransportService$6.handleException(TransportService.java:794) [opensearch-2.6.0.jar:2.6.0], at org.opensearch.security.transport.SecurityInterceptor$RestoringTransportResponseHandler.handleException(SecurityInterceptor.java:312) [opensearch-security-2.6.0.0.jar:2.6.0.0], at org.opensearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1414) [opensearch-2.6.0.jar:2.6.0], at org.opensearch.transport.InboundHandler.lambda$handleException$3(InboundHandler.java:420) [opensearch-2.6.0.jar:2.6.0], at org.opensearch.common.util.concurrent.OpenSearchExecutors$DirectExecutorService.execute(OpenSearchExecutors.java:343) [opensearch-2.6.0.jar:2.6.0], at org.opensearch.transport.InboundHandler.handleException(InboundHandler.java:418) [opensearch-2.6.0.jar:2.6.0], at org.opensearch.transport.InboundHandler.handlerResponseError(InboundHandler.java:410) [opensearch-2.6.0.jar:2.6.0], at org.opensearch.transport.InboundHandler.messageReceived(InboundHandler.java:158) [opensearch-2.6.0.jar:2.6.0], at org.opensearch.transport.InboundHandler.inboundMessage(InboundHandler.java:114) [opensearch-2.6.0.jar:2.6.0], at org.opensearch.transport.TcpTransport.inboundMessage(TcpTransport.java:769) [opensearch-2.6.0.jar:2.6.0], at org.opensearch.transport.InboundPipeline.forwardFragments(InboundPipeline.java:175) [opensearch-2.6.0.jar:2.6.0], at org.opensearch.transport.InboundPipeline.doHandleBytes(InboundPipeline.java:150) [opensearch-2.6.0.jar:2.6.0], at org.opensearch.transport.InboundPipeline.handleBytes(InboundPipeline.java:115) [opensearch-2.6.0.jar:2.6.0], at org.opensearch.transport.netty4.Netty4MessageChannelHandler.channelRead(Netty4MessageChannelHandler.java:94) [transport-netty4-client-2.6.0.jar:2.6.0], at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:280) [netty-handler-4.1.87.Final.jar:4.1.87.Final], at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1373) [netty-handler-4.1.87.Final.jar:4.1.87.Final], at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1236) [netty-handler-4.1.87.Final.jar:4.1.87.Final], at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1285) [netty-handler-4.1.87.Final.jar:4.1.87.Final], at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:529) [netty-codec-4.1.87.Final.jar:4.1.87.Final], at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468) [netty-codec-4.1.87.Final.jar:4.1.87.Final], at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290) [netty-codec-4.1.87.Final.jar:4.1.87.Final], at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:689) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:652) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) [netty-transport-4.1.87.Final.jar:4.1.87.Final], at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) [netty-common-4.1.87.Final.jar:4.1.87.Final], at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.87.Final.jar:4.1.87.Final], at java.lang.Thread.run(Thread.java:833) [?:?], Caused by: java.lang.Exception: org.opensearch.transport.RemoteTransportException: [coordinator-1][1.1.1.1:9300][indices:admin/mapping/put], … 48 more

Finally was able to delete the index, monitors are created just fine now.

1 Like