elasticsearch 如何为多个日志文件修改td代理文件,elasticsearch,logging,kibana,td-agent,elasticsearch,Logging,Kibana,Td Agent" /> elasticsearch 如何为多个日志文件修改td代理文件,elasticsearch,logging,kibana,td-agent,elasticsearch,Logging,Kibana,Td Agent" />

elasticsearch 如何为多个日志文件修改td代理文件

elasticsearch 如何为多个日志文件修改td代理文件,elasticsearch,logging,kibana,td-agent,elasticsearch,Logging,Kibana,Td Agent,我有一个服务器,它正在做一些与网络中其他设备相关的处理,然后相应地将每个设备的日志保存在自己的文件中。它检查每个设备及其数据的运行状况,并将其保存在json日志文件中。日志文件如下所示: rp_001_health.json -> health logs for 001 device rp_001_prod.json -> production logs for 001 device rp_002_health.json -> health logs for 002

我有一个服务器,它正在做一些与网络中其他设备相关的处理,然后相应地将每个设备的日志保存在自己的文件中。它检查每个设备及其数据的运行状况,并将其保存在json日志文件中。日志文件如下所示:

rp_001_health.json  -> health logs for 001 device
rp_001_prod.json    -> production logs for 001 device

rp_002_health.json -> health logs for 002 device
rp_002_prod.json   -> production logs for 002 device

rp_003_health.json  -> health logs for 003 device
rp_003_prod.json    -> production logs for 003 device

rp_004_health.json  -> production logs for 004 device
rp_004_prod.json    -> production logs for 004 device
<source>
  @type tail
  path /home/ripe/Documents/ripeproduct/logs/rp_001_health.json
  pos_file /home/ripe/Documents/ripeproduct/logs/rp_001_health.json.pos
  format json
  time_format %Y-%m-%d %H:%M:%S
  tag health001
</source>

<source>
  @type tail
  path /home/ripe/Documents/ripeproduct/logs/rp_002_health.json
  pos_file /home/ripe/Documents/ripeproduct/logs/rp_002_health.json.pos
  format json
  time_format %Y-%m-%d %H:%M:%S
  tag health002
</source>

<filter *health*>
  @type record_transformer
  <record>
    hostname ${hostname}
    Customer "Nycil"
    Version "V2"
  </record>
</filter>

<match *health001*>
  @type elasticsearch
  hosts https://search-rpproduction-0fzlamandaofgvfcukuoyewkrtfkkw2vre.eu-west-2.es.amazonaws.com/
  user <user>
  password <pwd>
  index_name rp_health_001
  type_name health
</match>

<match *health002*>
  @type elasticsearch
  hosts https://search-rpproduction-0fzlamandaofgvfcukuoyewkrtfkkw2vre.eu-west-2.es.amazonaws.com/
  user <user>
  password <pwd>
  index_name rp_health_002
  type_name health
</match>
设备总数为28个,因此创建的日志文件总数为56个

我正致力于将所有这些日志数据放入集中日志系统,从而使用
elasticsearch
kibana
。我已经安装了
td-agent
,正在为所有上述日志编写其
td-agent.conf
文件,如下所示:

rp_001_health.json  -> health logs for 001 device
rp_001_prod.json    -> production logs for 001 device

rp_002_health.json -> health logs for 002 device
rp_002_prod.json   -> production logs for 002 device

rp_003_health.json  -> health logs for 003 device
rp_003_prod.json    -> production logs for 003 device

rp_004_health.json  -> production logs for 004 device
rp_004_prod.json    -> production logs for 004 device
<source>
  @type tail
  path /home/ripe/Documents/ripeproduct/logs/rp_001_health.json
  pos_file /home/ripe/Documents/ripeproduct/logs/rp_001_health.json.pos
  format json
  time_format %Y-%m-%d %H:%M:%S
  tag health001
</source>

<source>
  @type tail
  path /home/ripe/Documents/ripeproduct/logs/rp_002_health.json
  pos_file /home/ripe/Documents/ripeproduct/logs/rp_002_health.json.pos
  format json
  time_format %Y-%m-%d %H:%M:%S
  tag health002
</source>

<filter *health*>
  @type record_transformer
  <record>
    hostname ${hostname}
    Customer "Nycil"
    Version "V2"
  </record>
</filter>

<match *health001*>
  @type elasticsearch
  hosts https://search-rpproduction-0fzlamandaofgvfcukuoyewkrtfkkw2vre.eu-west-2.es.amazonaws.com/
  user <user>
  password <pwd>
  index_name rp_health_001
  type_name health
</match>

<match *health002*>
  @type elasticsearch
  hosts https://search-rpproduction-0fzlamandaofgvfcukuoyewkrtfkkw2vre.eu-west-2.es.amazonaws.com/
  user <user>
  password <pwd>
  index_name rp_health_002
  type_name health
</match>

@型尾
path/home/ripe/Documents/ripeproduct/logs/rp_001_health.json
pos_文件/home/ripe/Documents/ripeproduct/logs/rp_001_health.json.pos
格式json
时间\u格式%Y-%m-%d%H:%m:%S
标签health001
@型尾
path/home/ripe/Documents/ripeproduct/logs/rp_002_health.json
pos_文件/home/ripe/Documents/ripeproduct/logs/rp_002_health.json.pos
格式json
时间\u格式%Y-%m-%d%H:%m:%S
标签health002
@型记录变压器
主机名${hostname}
客户“Nycil”
版本“V2”
@类型弹性搜索
主人https://search-rpproduction-0fzlamandaofgvfcukuoyewkrtfkkw2vre.eu-west-2.es.amazonaws.com/
使用者
密码
索引\u名称rp\u健康\u 001
键入\u名称健康状况
@类型弹性搜索
主人https://search-rpproduction-0fzlamandaofgvfcukuoyewkrtfkkw2vre.eu-west-2.es.amazonaws.com/
使用者
密码
索引\u名称rp\u健康\u 002
键入\u名称健康状况
在上面的文件中,我有两个源代码,目前我正在上传两个文件的日志。然后我有一个过滤器部分,在这里我放置了一些元数据,然后是两个匹配部分,在这里我定义了索引模式,我将在elasticsearch和kiabana中使用它

现在的问题是,如果我继续为日志文件的其余部分构建conf文件,它将变得非常冗长,无法理解,因为我总共有56个日志文件。我们有没有办法只使用一个源来保存所有运行状况日志文件和一个源来保存所有产品日志文件

类似地,我可以为所有运行状况日志定义一个匹配项,并为所有prod日志文件定义另一个匹配项。但在这里,我不确定如何输入与每个文件相关的不同索引模式。我想使用索引模式,比如

rp_health_<device_id> -> rp_health_001 or rp_health_002
rp\u health->rp\u health\u 001或rp\u health\u 002
那么,如何在一个匹配中为所有文件执行此操作呢。谁能给我一些好的建议吗。请帮忙。谢谢