Ingesting surricata logs

Hi, I am trying to ingest surricata logs into ElasticStack.
The architecture is as follows,
Suricata>>>FileBeat>>>ElasticSearch>>>Kibana

I have followed this guide to letter. How To Build A SIEM with Suricata and Elastic Stack on Ubuntu 20.04 | DigitalOcean

Now, I do not see in logs coming into ElasticSearch. I was wondering how do I troubleshoot this situation.

I have checked that suricata is generating alerts / logs.
FileBeats is running fine
ElasticSearch and Kibana are running fine.

I also tried couple of other tutorials / youtube videos but unable to determine the issue.

My 1st step would be to see what surricata logs filebeat can see?

Any help will be greatly appreciated.

Thanks

Hi @username82 Welcome to the community.

Although the referenced article appears well written, I would also recommend using / referring to our official docs.

What version of the Elastic Stack are you running?

How do you know this? Did you look at the logs?

Can you share your filebeat modules.d/suricata.yml?

Are you sure your suricata logs are in the default path?

You can test to see if filebeat is reading the logs by turning on the console output and just starting filebeat from the command line and see...

thanks for your reply,

I think surricata log file are in correct place,

root@idss:/var/log/suricata# ls /var/log/suricata/
 certs  'ervice: Start request repeated too quickly'   eve.json   fast.log   files   mwb.log   stats.log   suricata.log

do I need to stop and start filebeat service once I make changes to /etc/filebeat/filebeat.yml. Would the data would just appear on console.

surricata.yml is quite massive I am unable to attach here. Adding pastebin link,

https://pastebin.com/pSn5Nsb1

Hi @username82

Apologies... I / we are not suricata experts the suricata.yml so all that setup doesn't really help me, perhaps for others.

What I asked for and was not clear apologies, was the the filebeat modules.d/suricata.yml

Yes you need to stop and start... I do not personally use restart...

What I would like to see is the filebeat logs... more than 1 line otherwise I can not help.

I need more than

root@idss:/var/log/suricata# ls /var/log/suricata/
 certs  'ervice: Start request repeated too quickly'   eve.json   fast.log   files   mwb.log   stats.log   suricata.log

Per our docs here

Filebeat status and logs

To get the service status, use systemctl:

systemctl status filebeat

Logs are stored by default in journald. To view the Logs, use journalctl:

journalctl -u filebeat.service

Also you did not answer what version of the stack are you on... I asked that intentionally.

Hi, thanks for coming back and I am trying to get all this information especially version numbers for Elasticsearch & Kibana but running into space errors. I will get this sorted and revert back.
Thanks

Thanks for your help, I was able to recover my system from low memory for some reason filebeats was logging huge amounts of data to syslog and daemon log files. I reset them and commented the console output commands. Now, it appears to be fine. Filebeats is still logging into syslog file but not in json.

Versions of stack.

:~# filebeat version
filebeat version 7.17.5 (amd64), libbeat 7.17.5 [05f73d937c955ef81eccacc460a161cf2e6ac123 built 2022-06-23 23:24:12 +0000 UTC]


:/usr/share/elasticsearch# sudo ./bin/elasticsearch --version
Version: 7.17.4, Build: default/deb/79878662c54c886ae89206c685d9f1051a9d6411/2022-05-18T18:04:20.964345128Z, JVM: 18.0.1.1

:/usr/share/kibana/bin# sudo ./kibana --allow-root --version
7.17.4

Surricata.yml

:/etc/filebeat/modules.d# cat suricata.yml
# Module: suricata
# Docs: https://www.elastic.co/guide/en/beats/filebeat/7.17/filebeat-module-suricata.html

- module: suricata
  # All logs
  eve:
    enabled: true

    # Set custom paths for the log files. If left empty,
    # Filebeat will choose the paths depending on your OS.
    #var.paths:

Service Status of Elk Stack

root@ids1:/etc/filebeat/modules.d# sudo systemctl status filebeat.service
● filebeat.service - Filebeat sends log files to Logstash or directly to Elastic
   Loaded: loaded (/lib/systemd/system/filebeat.service; disabled; vendor preset
   Active: active (running) since Wed 2022-07-13 11:22:07 BST; 1h 51min ago
     Docs: https://www.elastic.co/beats/filebeat
 Main PID: 12010 (filebeat)
    Tasks: 14 (limit: 4915)
   Memory: 385.1M
   CGroup: /system.slice/filebeat.service
           └─12010 /usr/share/filebeat/bin/filebeat --environment systemd -c /et

Jul 13 13:12:31 ids1 filebeat[12010]: 2022-07-13T13:12:31.652+0100        INFO
Jul 13 13:12:31 ids1 filebeat[12010]: 2022-07-13T13:12:31.652+0100        ERROR
Jul 13 13:12:40 ids1 filebeat[12010]: 2022-07-13T13:12:40.765+0100        INFO
Jul 13 13:13:07 ids1 filebeat[12010]: 2022-07-13T13:13:07.160+0100        ERROR
Jul 13 13:13:07 ids1 filebeat[12010]: 2022-07-13T13:13:07.161+0100        INFO
Jul 13 13:13:07 ids1 filebeat[12010]: 2022-07-13T13:13:07.161+0100        INFO
Jul 13 13:13:07 ids1 filebeat[12010]: 2022-07-13T13:13:07.161+0100        INFO
Jul 13 13:13:07 ids1 filebeat[12010]: 2022-07-13T13:13:07.161+0100        ERROR
Jul 13 13:13:10 ids1 filebeat[12010]: 2022-07-13T13:13:10.764+0100        INFO
Jul 13 13:13:40 ids1 filebeat[12010]: 2022-07-13T13:13:40.764+0100        INFO
lines 1-20/20 (END)


 sudo systemctl status elasticsearch.service
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/lib/systemd/system/elasticsearch.service; disabled; vendor p
   Active: active (running) since Wed 2022-07-13 13:15:55 BST; 1min 56s ago
     Docs: https://www.elastic.co
 Main PID: 12550 (java)
    Tasks: 125 (limit: 4915)
   Memory: 5.0G
   CGroup: /system.slice/elasticsearch.service
           ├─12550 /usr/share/elasticsearch/jdk/bin/java -Xshare:auto -Des.netwo
           └─12750 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86

Jul 13 13:15:45 ids1 systemd[1]: Starting Elasticsearch...
Jul 13 13:15:55 ids1 systemd[1]: Started Elasticsearch.

root@ids1:/etc/filebeat/modules.d# sudo systemctl status kibana.service
● kibana.service - Kibana
   Loaded: loaded (/etc/systemd/system/kibana.service; disabled; vendor preset:
   Active: active (running) since Wed 2022-07-13 13:16:04 BST; 2min 9s ago
     Docs: https://www.elastic.co
 Main PID: 12831 (node)
    Tasks: 11 (limit: 4915)
   Memory: 401.8M
   CGroup: /system.slice/kibana.service
           └─12831 /usr/share/kibana/bin/../node/bin/node /usr/share/kibana/bin/

Jul 13 13:16:04 ids1 systemd[1]: Started Kibana.

I will get the logs from filebeat shortly and share it here.

Regards

output from journal for filebeats

 journalctl -u filebeat.service
-- Logs begin at Wed 2022-07-13 11:16:39 BST, end at Wed 2022-07-13 13:29:10 BST
Jul 13 11:16:39 ids1 filebeat[6114]:     "offset": 56990148349,
Jul 13 11:16:39 ids1 filebeat[6114]:     "file": {
Jul 13 11:16:39 ids1 filebeat[6114]:       "path": "/var/log/suricata/eve.json"
Jul 13 11:16:39 ids1 filebeat[6114]:     }
Jul 13 11:16:39 ids1 filebeat[6114]:   },
Jul 13 11:16:39 ids1 filebeat[6114]:   "suricata": {
Jul 13 11:16:39 ids1 filebeat[6114]:     "eve": {
Jul 13 11:16:39 ids1 filebeat[6114]:       "in_iface": "enp1s0f0",
Jul 13 11:16:39 ids1 filebeat[6114]:       "vlan": [
Jul 13 11:16:39 ids1 filebeat[6114]:         999
Jul 13 11:16:39 ids1 filebeat[6114]:       ],
Jul 13 11:16:39 ids1 filebeat[6114]:       "event_type": "flow",
Jul 13 11:16:39 ids1 filebeat[6114]:       "app_proto": "dns",
Jul 13 11:16:39 ids1 filebeat[6114]:       "flow": {
Jul 13 11:16:39 ids1 filebeat[6114]:         "reason": "unknown",
Jul 13 11:16:39 ids1 filebeat[6114]:         "pkts_toserver": 1,
Jul 13 11:16:39 ids1 filebeat[6114]:         "pkts_toclient": 0,
Jul 13 11:16:39 ids1 filebeat[6114]:         "bytes_toserver": 84,
Jul 13 11:16:39 ids1 filebeat[6114]:         "bytes_toclient": 0,
Jul 13 11:16:39 ids1 filebeat[6114]:         "end": "2022-06-30T07:04:51.897574+
Jul 13 11:16:39 ids1 filebeat[6114]:         "age": 0,
Jul 13 11:16:39 ids1 filebeat[6114]:         "state": "new",
Jul 13 11:16:39 ids1 filebeat[6114]:         "start": "2022-06-30T07:04:51.89757
Jul 13 11:16:39 ids1 filebeat[6114]:         "alerted": false
Jul 13 11:16:39 ids1 filebeat[6114]:       },
Jul 13 11:16:39 ids1 filebeat[6114]:       "flow_id": "1077105807045158"
Jul 13 11:16:39 ids1 filebeat[6114]:     }
Jul 13 11:16:39 ids1 filebeat[6114]:   },
Jul 13 11:16:39 ids1 filebeat[6114]:   "tags": [
Jul 13 11:16:39 ids1 filebeat[6114]:     "suricata"
Jul 13 11:16:39 ids1 filebeat[6114]:   ],
Jul 13 11:16:39 ids1 filebeat[6114]:   "agent": {
Jul 13 11:16:39 ids1 filebeat[6114]:     "version": "7.17.5",
Jul 13 11:16:39 ids1 filebeat[6114]:     "hostname": "ids1",
Jul 13 11:16:39 ids1 filebeat[6114]:     "ephemeral_id": "d6d8da43-e668-4021-b3b
Jul 13 11:16:39 ids1 filebeat[6114]:     "id": "29df4832-7199-44af-ad01-8e436c09
Jul 13 11:16:39 ids1 filebeat[6114]:     "name": "ids1",
Jul 13 11:16:39 ids1 filebeat[6114]:     "type": "filebeat"
Jul 13 11:16:39 ids1 filebeat[6114]:   },
Jul 13 11:16:39 ids1 filebeat[6114]:   "network": {
Jul 13 11:16:39 ids1 filebeat[6114]:     "transport": "UDP",
Jul 13 11:16:39 ids1 filebeat[6114]:     "community_id": "1:rZsRJ7uFp1Uhl8XP0JwC
Jul 13 11:16:39 ids1 filebeat[6114]:     "direction": "external"

So it looks like filebeat is harvesting the suricata logs which is good

It also looks like you set the output to console So we're seeing what filebeat is collecting sent to the console which ends up going to the filbeat logs.

So now set the filebeat output back to Elasticsearch and run again and check the filebeat logs.

Also, post your filebeat.yml.

Try to post more of your filebeat logs My suspicion is filebeat is not connecting with elasticsearch.

thanks for your support, please see the filebeats logs from journalctl. I have used grep 'elasticsearch' to reduce. I am happy to share full logs if need be,
Also I have changed the ip address and passwords for security purpose,

FileBeat logs greped

https://pastebin.com/4bNhR8qt

FileBeat.yml (password and ip changed)

###################### Filebeat Configuration Example #########################

# This file is an example configuration file highlighting only the most common
# options. The filebeat.reference.yml file from the same directory contains all the
# supported options with more comments. You can use it as a reference.
#
# You can find the full configuration reference here:
# https://www.elastic.co/guide/en/beats/filebeat/index.html

# For more available modules and options, please see the filebeat.reference.yml sample
# configuration file.

# ============================== Filebeat inputs ===============================

filebeat.inputs:

# Each - is an input. Most options can be set at the input level, so
# you can use different inputs for various configurations.
# Below are the input specific configurations.

# filestream is an input for collecting log messages from files.
- type: filestream

  # Unique ID among all inputs, an ID is required.
  id: my-filestream-id

  # Change to true to enable this input configuration.
  enabled: false

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
    - /var/log/*.log
    #- c:\programdata\elasticsearch\logs\*

  # Exclude lines. A list of regular expressions to match. It drops the lines that are
  # matching any regular expression from the list.
  #exclude_lines: ['^DBG']

  # Include lines. A list of regular expressions to match. It exports the lines that are
  # matching any regular expression from the list.
  #include_lines: ['^ERR', '^WARN']

  # Exclude files. A list of regular expressions to match. Filebeat drops the files that
  # are matching any regular expression from the list. By default, no files are dropped.
  #prospector.scanner.exclude_files: ['.gz$']

  # Optional additional fields. These fields can be freely picked
  # to add additional information to the crawled log files for filtering
  #fields:
  #  level: debug
  #  review: 1

# ============================== Filebeat modules ==============================

filebeat.config.modules:
  # Glob pattern for configuration loading
  path: ${path.config}/modules.d/*.yml

  # Set to true to enable config reloading
  reload.enabled: false

  # Period on which files under path should be checked for changes
  #reload.period: 10s

# ======================= Elasticsearch template setting =======================

setup.template.settings:
  index.number_of_shards: 1
  #index.codec: best_compression
  #_source.enabled: false


# ================================== General ===================================

# The name of the shipper that publishes the network data. It can be used to group
# all the transactions sent by a single shipper in the web interface.
#name:

# The tags of the shipper are included in their own field with each
# transaction published.
#tags: ["service-X", "web-tier"]

# Optional fields that you can specify to add additional information to the
# output.
#fields:
#  env: staging

# ================================= Dashboards =================================
# These settings control loading the sample dashboards to the Kibana index. Loading
# the dashboards is disabled by default and can be enabled either by setting the
# options here or by using the `setup` command.
#setup.dashboards.enabled: false

# The URL from where to download the dashboards archive. By default this URL
# has a value which is computed based on the Beat name and version. For released
# versions, this URL points to the dashboard archive on the artifacts.elastic.co
# website.
#setup.dashboards.url:

# =================================== Kibana ===================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:

  # Kibana Host
  # Scheme and port can be left out and will be set to the default (http and 5601)
  # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
  
   host: "10.10.10.10:5601"

  # Kibana Space ID
  # ID of the Kibana Space into which the dashboards should be loaded. By default,
  # the Default Space will be used.
  #space.id:

# =============================== Elastic Cloud ================================

# These settings simplify using Filebeat with the Elastic Cloud (https://cloud.elastic.co/).

# The cloud.id setting overwrites the `output.elasticsearch.hosts` and
# `setup.kibana.host` options.
# You can find the `cloud.id` in the Elastic Cloud web UI.
#cloud.id:

# The cloud.auth setting overwrites the `output.elasticsearch.username` and
# `output.elasticsearch.password` settings. The format is `<user>:<pass>`.
#cloud.auth:

# ================================== Outputs ===================================

# Configure what output to use when sending the data collected by the beat.

# ---------------------------- Elasticsearch Output ----------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["10.10.10.10:9200"]

  # Protocol - either `http` (default) or `https`.
  #protocol: "https"

  # Authentication credentials - either API key or username/password.
  #api_key: "id:api_key"
  username: "elastic"
  password: "changedpassword"

#output.console:
#  pretty: true

# ------------------------------ Logstash Output -------------------------------
#output.logstash:
  # The Logstash hosts
  #hosts: ["localhost:5044"]

  # Optional SSL. By default is off.
  # List of root certificates for HTTPS server verifications
  #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]

  # Certificate for SSL client authentication
  #ssl.certificate: "/etc/pki/client/cert.pem"

  # Client Certificate Key
  #ssl.key: "/etc/pki/client/cert.key"

# ================================= Processors =================================
processors:
  - add_host_metadata:
      when.not.contains.tags: forwarded
  - add_cloud_metadata: ~
  - add_docker_metadata: ~
  - add_kubernetes_metadata: ~

# ================================== Logging ===================================

# Sets log level. The default log level is info.
# Available log levels are: error, warning, info, debug
#logging.level: debug

# At debug level, you can selectively enable logging only for some components.
# To enable all selectors use ["*"]. Examples of other selectors are "beat",
# "publisher", "service".
#logging.selectors: ["*"]

# ============================= X-Pack Monitoring ==============================
# Filebeat can export internal metrics to a central Elasticsearch monitoring
# cluster.  This requires xpack monitoring to be enabled in Elasticsearch.  The
# reporting is disabled by default.

# Set to true to enable the monitoring reporter.
#monitoring.enabled: false

# Sets the UUID of the Elasticsearch cluster under which monitoring data for this
# Filebeat instance will appear in the Stack Monitoring UI. If output.elasticsearch
# is enabled, the UUID is derived from the Elasticsearch cluster referenced by output.elasticsearch.
#monitoring.cluster_uuid:

# Uncomment to send the metrics to Elasticsearch. Most settings from the
# Elasticsearch output are accepted here as well.
# Note that the settings should point to your Elasticsearch *monitoring* cluster.
# Any setting that is not set is automatically inherited from the Elasticsearch
# output configuration, so if you have the Elasticsearch output configured such
# that it is pointing to your Elasticsearch monitoring cluster, you can simply
# uncomment the following line.
#monitoring.elasticsearch:

# ============================== Instrumentation ===============================

# Instrumentation support for the filebeat.
#instrumentation:
    # Set to true to enable instrumentation of filebeat.
    #enabled: false

    # Environment in which filebeat is running on (eg: staging, production, etc.)
    #environment: ""

    # APM Server hosts to report instrumentation results to.
    #hosts:
    #  - http://localhost:8200

    # API Key for the APM Server(s).
    # If api_key is set then secret_token will be ignored.
    #api_key:

    # Secret token for the APM Server(s).
    #secret_token:


# ================================= Migration ==================================

# This allows to enable 6.7 migration aliases
#migration.6_to_7.enabled: true


Well there you have it 100s of times :slight_smile:

Filebeat can not connect to elasticsearch so you have a network issue or you did not bind elasticsearch to the network.. or both...

Jul 13 13:16:15 ids1 filebeat[12010]: 2022-07-13T13:16:15.475+0100        ERROR        [publisher_pipeline_output]        pipeline/output.go:154        Failed to connect to backoff(elasticsearch(http://10.10.10.10:9200)): Get "http://10.10.10.10:9200": dial tcp 10.10.10.10:9200: connect: connection refused

I looked at your article in your /etc/elasticsearch/elasticsearch.yml I see the instructions I would set.

# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
network.host: 0.0.0.0 <!---  Here 
# network.bind_host: ["127.0.0.1", "your_private_ip"] <!-- Comment Back Out
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
...
discovery.type: single-node
xpack.security.enabled: true

Next try to curl from your filebeat server to elasticsearch server you should get a happy response from this.

curl -u "username:password" http://10.10.10.10:9200

you can also try

telnet 10.10.10.10 9200
you should get a connected message.

if it does not connect you have a Connectivity / Firewall issue

thanks for response, Yes I had made the changes and thanks for pointing out.

following is the response for curl


{
  "name" : "idss",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "WSqAyTj4SVCktzdx***tGw",
  "version" : {
    "number" : "7.17.4",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "79878662c54c886ae89206c995d9f1051a9d6411",
    "build_date" : "2022-05-18T18:04:20.964345128Z",
    "build_snapshot" : false,
    "lucene_version" : "8.11.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"

So now ... IMPORTANT

You need to run filebeat setup since it probably did NOT work before

filebeat setup -e

THEN start filebeat... if you already started filebeat again will need to stop it.. clean up the index then run setup then start.

1 Like

hello, thanks.
I can see all the logs are coming in the system.
I was wondering what I was doing wrong previously.
Thank you very much for your help.
Regards

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