1

我们从这里使用 mongodb-elasticsearch river 插件

在某些情况下,我们发现河流已经陈旧。
原因包括

  • 重启MongoDB
  • 字段中的数据类型不匹配

每次我们都必须手动重新启动河流并重新索引集合。

有什么方法(工具、最佳实践、功能)来检测一条陈旧的河流并重新启动它?

4

2 回答 2

1

If you check out this line, it looks like the river inserts a timestamp of its latest update. You can compare the most recent timestamp to the current time. If it looks like it's getting old compared to the latest entry in the most active collection in your db, you know there's an issue and you should restart it.

于 2015-03-13T23:37:04.363 回答
1

我们在 Ruby 应用程序中使用类似的东西来监控河流延迟并将其发送到 statsd。然后,我们的监控框架会检测到它何时超过某个值并打开操作警报

j = JSON.parse Manticore.get("http://es_server:9200/_river/mongodb/list").body
j.each do |river|
  es_lag = Time.now - Time.at(river["lastTimestamp"] / 1000)
  stat_gauge "elasticsearch.river_latency.#{river['name']}", es_lag
end

您可以通过发出如下 HTTP 请求来自动执行此操作:

POST http://es_server:9200/_river/mongodb/{river_name}/{start|stop}

自动停止/启动河流。

于 2015-03-14T00:18:18.553 回答