You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Azure环境下跨VM访问ELK Stack失败的排查与配置解决方案咨询

Azure环境下跨VM访问ELK Stack失败的排查与配置解决方案咨询

Hey Krishna, let's work through this ELK access issue step by step—since you've already tried updating the YAML files with your Ubuntu VM's IP, let's dig into the other common culprits that might be blocking access from your Windows VM.

第一步:先确认Azure网络层面的连通性

Before diving into ELK configs, let's rule out basic network issues:

  • 确认两台VM处于同一个Azure虚拟网络(VNet)和子网中,如果不在,需要配置VNet对等连接或路由规则允许跨VNet通信
  • 在你的Windows VM上,用PowerShell测试基础连通性:
    Test-NetConnection -ComputerName <Ubuntu-VM-Private-IP> -Port 5601
    
    如果这个返回TcpTestSucceeded: False,重点排查防火墙和Azure安全组
  • 也可以先试试ping <Ubuntu-VM-Private-IP>,如果ping不通,先解决VM间的网络可达性问题

第二步:检查ELK各组件的核心配置

Let's double-check that each ELK component is set up to accept external connections:

Elasticsearch 配置(elasticsearch.yml

  • 确保network.host设置为Ubuntu VM的私有IP(或者0.0.0.0临时测试,生产环境不建议开放所有地址)
  • 如果是单节点部署,添加discovery.type: single-node避免集群发现报错
  • 重启Elasticsearch服务生效:
    sudo systemctl restart elasticsearch
    
  • 在Ubuntu本地验证:curl http://<Ubuntu-VM-Private-IP>:9200,应该返回包含集群信息的JSON响应

Kibana 配置(kibana.yml

  • 关键设置:
    server.host: "0.0.0.0"  # 允许监听所有网卡,或者直接填Ubuntu私有IP
    elasticsearch.hosts: ["http://<Ubuntu-VM-Private-IP>:9200"]  # 指向正确的Elasticsearch地址
    
  • 重启Kibana并检查状态:
    sudo systemctl restart kibana
    sudo systemctl status kibana
    
    确保服务显示active (running)

Logstash 配置(可选,若需从Windows发日志)

  • 如果要让Windows端的Filebeat/Logstash客户端连接,在logstash.yml里设置:
    http.host: "0.0.0.0"
    
  • 对应的输入插件配置(比如Beats输入)也要监听正确地址,在conf.d/*.conf中:
    input {
      beats {
        port => 5044
        host => "<Ubuntu-VM-Private-IP>"
      }
    }
    

第三步:检查Ubuntu本地防火墙(UFW)

Ubuntu默认启用UFW,需要开放ELK相关端口的入站权限:

  • 执行以下命令开放端口:
    sudo ufw allow 5601/tcp  # Kibana
    sudo ufw allow 9200/tcp  # Elasticsearch
    sudo ufw allow 5044/tcp  # Filebeat(如果需要)
    sudo ufw reload
    
  • 验证规则是否生效:sudo ufw status,确认这些端口在允许列表中

第四步:检查Azure网络安全组(NSG)

Azure NSG是VM网络访问的关键关卡,必须添加入站规则允许Windows VM访问ELK端口:

  1. 进入Azure门户,找到Ubuntu VM关联的NSG
  2. 添加一条入站安全规则
    • 优先级:设置为比默认拒绝规则更高的数值(比如100)
    • 源:可以选择Windows VM的私有IP,或者整个VNet的地址范围(如10.0.0.0/24
    • 目标端口范围:5601,9200,5044(按需调整)
    • 协议:TCP
    • 动作:允许
  3. 保存规则后等待1-2分钟生效,再测试访问

最后测试与排障

  1. 在Windows VM的浏览器中输入http://<Ubuntu-VM-Private-IP>:5601不要用localhost,localhost指向Windows VM自身
  2. 如果还是失败,查看Ubuntu端的日志找错误:
    • Kibana日志:sudo journalctl -u kibana -f(实时查看)
    • Elasticsearch日志:sudo journalctl -u elasticsearch -f
      日志里通常会显示监听失败、连接拒绝等具体原因

备注:内容来源于stack exchange,提问作者Krishna Nagendra Vuda

火山引擎 最新活动