# Help with creating a Logstash configuration file for Postfix log analysis

**URL:** <https://discuss.elastic.co/t/help-with-creating-a-logstash-configuration-file-for-postfix-log-analysis/335078>\
**Category:** Logstash\
**Created:** [June 2, 2023, 12:38pm UTC](https://discuss.elastic.co/t/help-with-creating-a-logstash-configuration-file-for-postfix-log-analysis/335078 "2023-06-02T12:38:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aleksandr\_Terekhov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aleksandr_terekhov/32/118288_2.png) [@Aleksandr\_Terekhov](https://discuss.elastic.co/u/Aleksandr_Terekhov)\
**Post date:** [June 2, 2023, 12:38pm UTC](https://discuss.elastic.co/t/help-with-creating-a-logstash-configuration-file-for-postfix-log-analysis/335078/1 "2023-06-02T12:38:59Z")

</div>

Hello everybody

Can someone help to correctly create a configuration file that will display the fields from the postfix log

that  
from  
status  
Message-id

in Kiban in one line and not as in the screenshot

I will be grateful for your help

thank you!

 ![222](https://us1.discourse-cdn.com/elastic/original/3X/e/0/e0eab4933e988362a54382010619f097fec7e251.png)

```auto
filter {
  if [fields][server] == "postfix" {
    grok {
      match => { "message" => "%{SYSLOGBASE:log_timestamp} %{DATA:log_source}: %{GREEDYDATA:log_message}" }
    }

    if [log_message] =~ /to=</ {
      grok {
        match => { "log_message" => "to=<(?<send_email_to>[^>]+)>" }
      }
      mutate {
        add_field => { "Send Email To" => "%{send_email_to}" }
      }
    }

    if [log_message] =~ /from=</ {
      grok {
        match => { "log_message" => "from=<(?<send_email_from>[^>]+)>" }
      }
      mutate {
        add_field => { "Send Email From" => "%{send_email_from}" }
      }
    }

    if [log_message] =~ /status/ {
      grok {
        match => { "log_message" => "status=%{DATA:status_send}\s" }
      }
      mutate {
        add_field => { "Status Send" => "%{status_send}" }
      }
    }

    if [log_message] =~ /message-id=<[^>]+>/ {
      grok {
        match => { "log_message" => "message-id=<%{DATA:message_id}>" }
      }
      mutate {
        add_field => { "Message ID" => "%{message_id}" }
      }
    }

    mutate {
      remove_field => ["log_message", "log_timestamp", "log_source", "send_email_to", "send_email_from", "status_send", "message_id"]
    }
  } else {
    drop {}
  }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 30, 2023, 12:39pm UTC](https://discuss.elastic.co/t/help-with-creating-a-logstash-configuration-file-for-postfix-log-analysis/335078/2 "2023-06-30T12:39:57Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
