tsaikd / gogstash

Logstash like, written in golang
MIT License
644 stars 106 forks source link

add filter/cond and output/cond #40

Closed tengattack closed 6 years ago

tengattack commented 6 years ago

Hi, I think this could help us to do more complex consumption for events.

Add filter/cond and output/cond implements the sequence control for event's filters and outputs.

a simple config:

input:
  - type: httplisten
    address: '0.0.0.0:8081'
    path: '/log'
filter:
  - type: add_field
    key: instance_id
    value: '123456'
  - type: cond
    condition: "([nginx.access.url] ?? '') =~ '^/api/'"
    filter:
      - type: add_field
        key: controller
        value: api
output:
  - type: cond
    condition: "info == 'ERROR'"
    output:
      - type: stdout
tsaikd commented 6 years ago

thx for the PR

tengattack commented 6 years ago

Could you help me to fix that? BYW, we can update the entry README too. :)

tengattack commented 6 years ago

oh, ... modified many times, finally find a solution:

condition: "([nginx.access.url] ?? '') =~ '^/api/'"