【问题标题】:Metricbeat WARN Cannot index eventMetricbeat WARN 无法索引事件
【发布时间】:2020-05-25 20:56:27
【问题描述】:

我看过一些这样的帖子,但都没有解决我的问题,所以:

我按照本教程创建了一个弹性集群:https://www.elastic.co/guide/en/elasticsearch/reference/current/configuring-tls-docker.html

我已经设置了内置密码,可以访问elasticsearch

$ curl -k --user elastic:$ELASTIC_PWD https://localhost:9200/
{
  "name" : "es01",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "hqrGkTUGR0W2Clsaxp75pQ",
  "version" : {
    "number" : "7.6.2",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
    "build_date" : "2020-03-26T06:34:37.794943Z",
    "build_snapshot" : false,
    "lucene_version" : "8.4.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

我将证书颁发机构复制到主机(我将在其中运行 metricbeat),如下所示:

sudo -s
mkdir -p /etc/pki/root
docker exec kibana cat /usr/share/elasticsearch/config/certificates/ca/ca.crt > /etc/pki/root/ca.pem

我可以检查证书是否存在:

$ cat /etc/pki/root/ca.pem
-----BEGIN CERTIFICATE-----
<certificate>
-----END CERTIFICATE-----

到目前为止一切顺利,然后,我按照本教程安装了 metricbeat: https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-installation.html

并在/etc/metricbeat/metricbeat.yml 设置以下配置:

setup.kibana:
  host: "https://localhost:5601"
  ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]

output.elasticsearch:
  hosts: ["https://localhost:9200"]
  username: "metricbeat"
  password: "<password>"
  ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]

我在 Kibana 中创建的 metricbeat 用户如下: https://www.elastic.co/guide/en/beats/metricbeat/current/feature-roles.html

基本上,我创建了一个名为metricbeat_setup 的角色,具有monitormanage_ilm 的集群权限和metricbeat-* 上的索引权限manage,然后,我创建了具有角色metricbeatmetricbeat 用户,@ 987654338@、ingest_adminbeats_adminbeats_system

我认为我的问题可能在这里,我不太了解必要的权限,所以我只是矫枉过正,无论如何,继续......

我运行了sudo metricbeat setup -e 的设置,一切正常,设置中没有错误,然后我用sudo service metricbeat start 启动它,但没有任何东西进入elasticsearch,当我查看sudo service metricbeat status 时,我得到多行@ 987654345@

我试图查看/var/log/metricbeat/ 中的日志,但没有发现任何有用的信息,在 docker 的 elasticsearch 日志中也是如此,也没有有用的信息。

创建metricbeat-*索引并分配分片:

$ curl -k --user elastic:$ELASTIC_PWD https://localhost:9200/_cat/indices/metricbeat-*?pretty
green open metricbeat-7.7.0-2020.05.25-000001 p_0nuiX1S8SARk9QZK01EA 1 1 0 0 566b 283b
$ curl -k --user elastic:$ELASTIC_PWD https://localhost:9200/_cluster/allocation/explain?pretty
{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "unable to find any unassigned shards to explain [ClusterAllocationExplainRequest[useAnyUnassignedShard=true,includeYesDecisions?=false]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "unable to find any unassigned shards to explain [ClusterAllocationExplainRequest[useAnyUnassignedShard=true,includeYesDecisions?=false]"
  },
  "status" : 400
}

那么,请问,我在这里缺少什么?我在日志或帖子中找不到任何相关信息,我在这里看到帖子说这与磁盘空间不足有关,我有 14G 可用空间,所以我想这不是问题。另外,我知道metricbeat可以同时连接到elasticsearch和kibana,因为它能够创建索引和仪表板,我可以在kibana中打开仪表板但是没有数据。

我做错了什么?

谢谢

【问题讨论】:

  • elasticserch 日志中是否有任何内容?
  • 不,elasticsearch 中没有记录任何内容
  • 仔细检查您的用户是否有priveleges needed 可以发布到索引中,您的用户似乎在metricbeat-* 索引中缺少create_doc 权限。
  • 就是这样,非常感谢,请发表您的答案,以便我可以接受它应得的

标签: elasticsearch elastic-stack metricbeat elastic-beats


【解决方案1】:

为了能够写入索引,用户需要在所需索引中拥有create_doc 权限。

在这种情况下,对于每个名为metricbeat-* 的索引,用户需要拥有create_docindex 权限。

来源:grant privileges and roles needed for publishing

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-08
    • 2018-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多