如何change/rename kibana UI 上的kibana 索引字段的值?

How to change/rename value of kibana index field on kibana UI?

我在一台服务器上设置了 ELK 堆栈,在另外两台服务器上设置了 filebeat,以将数据直接发送到 logstash。

设置工作正常,我根据需要获得了日志结果,但是当我在 Kibana UI(左侧)上看到字段部分时,我看到“host.hostname”字段,其中有两个服务器 fqdns(即“ip-113-331-116-35.us-east-1.compute.internal", “ip-122-231-123-35.us-东-1.compute.internal” )

我想设置别名或将这些值分别重命名为 Production-1Production-2 以在 kibana 上显示 UI

如何在不破坏任何东西的情况下更改这些值

如果您需要任何代码片段,请告诉我

由于字段 host.hostname 是一个 ECS 字段,因此我不建议重命名该特定字段。

在我看来你有两个选择:

1.) 在 Logstash 中创建管道

您可以在 Logstash 中设置一个简单的管道,在其中使用 mutate 过滤器插件并执行 add_field 操作。这将在您的活动中创建一个值为 host.hostname 的新字段。这是一个简单的例子:

filter{
  if [host][hostname]{
    mutate{
      add_field => { "your_cool_field_name" => "%{[host][hostname]}" }
    }
  }
}

2.) 设置自定义 mapping/index 模板

您可以在自定义映射中定义字段别名。我推荐阅读 this article about field aliases

您可以在 logstash 管道的过滤器块中使用 translate 过滤器来重命名值。

filter {
    translate {
        field => "[host][hostname]"
        destination => "[host][hostname]"
        dictionary => {
            "ip-113-331-116-35.us-east-1.compute.internal" => "Production-1"
            "ip-122-231-123-35.us-east-1.compute.internal" => "Production-2"
        }
    }
}