pulsar-beat-output icon indicating copy to clipboard operation
pulsar-beat-output copied to clipboard

Conditional topic selection

Open cagucor opened this issue 3 years ago • 4 comments

Hi Everyone,

Is there a way to conditionally apply a topic to a certain message? For example: if an object has a field like level, then it will be published to a different topic if it is an info or warning.

cagucor avatar Jan 09 '22 21:01 cagucor

@SperChung-11 Could you please look at this issue, thank you :)

shoothzj avatar Jan 10 '22 00:01 shoothzj

hi, @cagucor. you can try filebeat.yml config as follows :

filebeat.inputs:
- type: log
  enabled: true
  paths: /var/log/message
  fields:
    log_topic: warn_topic
  include_lines: ['WARN']

- type: log
  enabled: true
  paths: /var/log/message
  fields:
    log_topic: info_topic
  include_lines: ['INFO']

#--------------------------pulsar  output ------------------------------
output.pulsar:
  enabled: true
  url: ${PULSAR_ADDRESS}
  topic: '%{[fields.log_topic]}'

SperChung-11 avatar Jan 11 '22 03:01 SperChung-11

Hi, thanks for the reply.

I tried the solution you suggested, but it does not produce the expected result. When I use that config I get a topic called '%{[fields.log_topic]}'. Is dynamic topic a feature that is enabled? I noticed issue #19 is still open and has been in backlog for a while.

producerID=1 producer_name=filebeat topic="persistent://public/default/%{[fields.log_topic]}"

cagucor avatar Jan 12 '22 02:01 cagucor

@Shoothzj can you help to confirm that if #19 was solved ? both are the same questions, thanks ^.^

SperChung-11 avatar Jan 12 '22 06:01 SperChung-11