# Extract integer from syslog

**URL:** <https://discuss.elastic.co/t/extract-integer-from-syslog/28850>\
**Category:** Logstash\
**Created:** [September 8, 2015, 4:01pm UTC](https://discuss.elastic.co/t/extract-integer-from-syslog/28850 "2015-09-08T16:01:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lwhitworth](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lwhitworth/32/6940_2.png) [@lwhitworth](https://discuss.elastic.co/u/lwhitworth)\
**Post date:** [September 8, 2015, 4:01pm UTC](https://discuss.elastic.co/t/extract-integer-from-syslog/28850/1 "2015-09-08T16:01:09Z")

</div>

Hi there,

I have a basic syslog input/filter/output that's working fine to ship stuff to elasticsearch and onto kibana. Occasionally though there'll be a line in the syslog for a specific system like:

```
Sep 8 16:35:01 captiveportalhost captiveportal[24715]: [notice] There are currently 0 people logged into captivegateway

```

I'd like logstash to take the number of people in that line and store it as its own field so I can later us that to build a graph in kibana. Can anyone give me some pointers how to achieve it?

At present my config looks like:

```
filter {
  if [type] == "syslog" {
    grok {
      match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
      add_field => ["received_at", "%{@timestamp}"]
      add_field => ["received_from", "%{host}"]
    }
    syslog_pri { }
    date {
      match => ["syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss"]
    }
  }
}

filter {
  if [type] == "syslog" {
    grok {
      match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
      add_field => ["received_at", "%{@timestamp}"]
      add_field => ["received_from", "%{host}"]
    }
    syslog_pri { }
    date {
      match => ["syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss"]
    }
  }
}

output {
  elasticsearch { host => localhost }
  stdout { codec => rubydebug }
}

```

Any help gratefully recieved! I'm very new to this and finding it a bit hard getting going!

Luke

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 8, 2015, 4:09pm UTC](https://discuss.elastic.co/t/extract-integer-from-syslog/28850/2 "2015-09-08T16:09:25Z")

</div>

Was that a copy/paste mistake or do you actually have the same configuration block twice?

This is an easy job for a grok filter.

```
filter {
  grok {
    match => [
      "syslog_message",
      "There are currently %{INT:logged_in_count:int} people logged into captivegateway"
    ]
  }
}
```

---

<div class="post-metadata">

**Author:** ![lwhitworth](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lwhitworth/32/6940_2.png) [@lwhitworth](https://discuss.elastic.co/u/lwhitworth)\
**Post date:** [September 9, 2015, 7:32am UTC](https://discuss.elastic.co/t/extract-integer-from-syslog/28850/3 "2015-09-09T07:32:14Z")

</div>

Cheers for the answer I'll give it a go......and yes it was a copy/paste mistake....apologies!

---

<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:** [July 6, 2017, 5:29am UTC](https://discuss.elastic.co/t/extract-integer-from-syslog/28850/4 "2017-07-06T05:29:40Z")

</div>

Closed on July 6, 2017, 5:29am UTC


