# Metrics for multiple log messages

**URL:** <https://discuss.elastic.co/t/metrics-for-multiple-log-messages/111860>\
**Category:** Logstash\
**Created:** [December 14, 2017, 9:06pm UTC](https://discuss.elastic.co/t/metrics-for-multiple-log-messages/111860 "2017-12-14T21:06:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaichidrewar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vaichidrewar/32/25604_2.png) [@vaichidrewar](https://discuss.elastic.co/u/vaichidrewar)\
**Post date:** [December 14, 2017, 9:06pm UTC](https://discuss.elastic.co/t/metrics-for-multiple-log-messages/111860/1 "2017-12-14T21:06:57Z")

</div>

Hi,

I want to parse log file and keep the count of various messages per minute

I got the following config working for counting one type of message -. So below config is counting log lines containing "PixelLogParseAndEnrichFunc Entry" in a line.

I have 10-15 such different messages appearing in the log and want to get the count for each message per minute.

What is the best way to templatize this counting of messages? There has to be some better way than repeating these 25 lines ten times more.

```
filter {
  grok {
    match => ["message", "(?<input_pixel_log_event>PixelLogParseAndEnrichFunc Entry)"]
    add_tag => "input_pixel_event"
  }
  if "input_pixel_event" in [tags] {
    metrics {
      meter => ["input_pixel"]
      clear_interval => 60
      flush_interval => 60
      #timer => { "input_pixel" => "%{duration}" }
      add_tag => "input_pixel_metric"
    }
  }
}

output {
  if "input_pixel_metric" in [tags] {
      file {
          codec => line {
              format => "input_pixel_metric_count: %{[input_pixel][count]}"
          }
          path => "/tmp/vaibhav_logstash_op"
      }
  }
}
```

---

<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:** [January 11, 2018, 9:07pm UTC](https://discuss.elastic.co/t/metrics-for-multiple-log-messages/111860/2 "2018-01-11T21:07:15Z")

</div>

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