streamnative / pulsar-beat-output

Elastic Beats Output to Apache Pulsar
Apache License 2.0
56 stars 24 forks source link

Conditional topic selection #64

Open cagucor opened 2 years ago

cagucor commented 2 years ago

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.

shoothzj commented 2 years ago

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

SperChung-11 commented 2 years ago

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]}'
cagucor commented 2 years ago

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]}"
SperChung-11 commented 2 years ago

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