且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

collectd 与 logstash配置

更新时间:2022-08-12 16:13:11

节点

  • node1: 配置logstash
  • node2: 配置collectd, collectd收集本地的信息, 通过配置将信息发送到node1节点

node1安装配置logstash

  • rpm -ivh logstash.rpm
  • logstash安装在/opt目录下, 在/etc/profile,d目录下添加logstash.sh脚本文件将其添加到环境变量中
  • export PATH=$PATH:/opt/logstash/bin
  • 配置文件在/etc/logstash/conf.d下, 默认该目录是空的
  • 示例配置文件

example 1:

input {
file {
path => "/var/log/messages"
type => "system"
start_position => "beginning"
}
}

output {
stdout {
codec => rubydebug
}
}

example 2:

input {
stdin {}
}

output {
stdout {
codec => rubydebug
}
}

example 3(此为collectd的配置, 等会就是这个):

input {
udp {
port => 25826
type => "collectd"
codec => collectd {}
}
}

output {
stdout {
codec => rubydebug
}
}

node2安装配置collectd

  • yum install collectd #collectd在epel源
  • 配置文件为/etc/collectd.conf
  • LoadPlugin network
  • Hostname "node2"

  • systemctl start collectd

node1使用logstash

  • logstash -f /etc/logstash/collectd.conf --configtest
  • logstash -f /etc/logstash/collectd.conf