Debian 12 bookworm
Sponsored Link

Elastic Stack 8 : Install Packetbeat2023/08/04

 

Install Packetbeat that collects and analyze Network packets.

[1] Install Packetbeat. Configure Elasticsearch repository before it.
root@dlp:~#
apt -y install packetbeat
[2] Configure basic settings and start Packetbeat.
root@dlp:~#
vi /etc/packetbeat/packetbeat.yml
# line 58 : set items to collect data
# if disable ICMPv4/ICMPv6, turn to false
# line 44 and later : many items are targeted as monitoring by default,
# but if not need, comment out the line [ports: ***]

packetbeat.protocols:
- type: icmp
  # Enable ICMPv4 and ICMPv6 monitoring. Default: false
  enabled: true

- type: amqp
  # Configure the ports where to listen for AMQP traffic. You can disable
  # the AMQP protocol by commenting out the list of ports.
  ports: [5672]

.....
.....

# line 181 : if use Kibana, uncomment and specify output host
# if SSL is enabled on Kibana, hostname should be the same with the hostname in certs
# [username] and [password] is the admin user's one
# if using self-signed certificate, specify [ssl.verification_mode: none]

setup.kibana:
.....
  host: "https://dlp.srv.world:5601"
  protocol: "https"
  username: "elastic"
  password: "password"
  ssl.enabled: true
  ssl.verification_mode: none

# line 217 : specify output of Elasticsearch
# [username] and [password] is the admin user's one
# [ssl.certificate_authorities] is the cacert generated by Elasticsearch installation

output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["https://dlp.srv.world:9200"]

  protocol: "https"
  username: "elastic"
  password: "password"
  ssl.certificate_authorities: "/etc/elasticsearch/certs/http_ca.crt"

.....
.....

root@dlp:~#
vi /etc/packetbeat/packetbeat.reference.yml
# line 1816 : if use Kibana, uncomment and specify output host
# if SSL is enabled on Kibana, uncomment ssl related lines
# [username] and [password] is the admin user's one
# if using self-signed certificate, specify [ssl.verification_mode: none]

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: "https://dlp.srv.world:5601"

  # Optional protocol and basic auth credentials.
  protocol: "https"
  username: "elastic"
  password: "password"

  # Optional HTTP Path
  #path: ""

  # Use SSL settings for HTTPS. Default is true.
  ssl.enabled: true

.....
.....

  # after very careful consideration. It is primarily intended as a temporary
  # diagnostic mechanism when attempting to resolve TLS errors; its use in
  # production environments is strongly discouraged.
  # The default value is full.
  ssl.verification_mode: none

root@dlp:~#
systemctl enable --now packetbeat
[3] Verify status the data has been collected normally.
# index list

root@dlp:~#
curl -u elastic --cacert /etc/elasticsearch/certs/http_ca.crt https://127.0.0.1:9200/_cat/indices?v

Enter host password for user 'elastic'
health status index                                                        uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   .internal.alerts-observability.metrics.alerts-default-000001 JG7OkJGSQoOU1unZWIpPhg   1   0          0            0       247b           247b
yellow open   .ds-metricbeat-8.9.0-2023.08.04-000001                       _P5TRkvkRQajH-_vCoSxPg   1   1       1778            0      2.4mb          2.4mb
green  open   .internal.alerts-observability.logs.alerts-default-000001    7-mTfD30Qsm_BMQrjWf4wA   1   0          0            0       247b           247b
green  open   .internal.alerts-observability.uptime.alerts-default-000001  5T9PMMMiRkCgUy9SIzj1Mg   1   0          0            0       247b           247b
green  open   .fleet-file-data-agent-000001                                g9lX3CKhRVOHtUIQBOYrUw   1   0          0            0       247b           247b
green  open   .fleet-files-agent-000001                                    9jPGD7QJRXKygS-7h_KsRw   1   0          0            0       247b           247b
green  open   .internal.alerts-security.alerts-default-000001              mx-yDAa7QBmOH0Hqg-ewpg   1   0          0            0       247b           247b
green  open   .internal.alerts-observability.slo.alerts-default-000001     oD35AVTPStG-77Ot13aXJQ   1   0          0            0       247b           247b
green  open   .internal.alerts-observability.apm.alerts-default-000001     ItO4YBEvTYqIV4EM871jDg   1   0          0            0       247b           247b
yellow open   test_index                                                   yW_f_CXpSU6uAqRNpHXyTw   1   1          1            0      6.4kb          6.4kb
yellow open   .ds-packetbeat-8.9.0-2023.08.04-000001                       2naLXq6rTHapYqnMwBQmpQ   1   1         28            0     76.2kb         76.2kb

# document list on the index

root@dlp:~#
curl -u elastic --cacert /etc/elasticsearch/certs/http_ca.crt https://127.0.0.1:9200/.ds-packetbeat-8.9.0-2023.08.04-000001/_search?pretty

Enter host password for user 'elastic':
{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 164,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : ".ds-packetbeat-8.9.0-2023.08.04-000001",
        "_id" : "PP0NvokB_raRHX1gUEq9",
        "_score" : 1.0,
        "_source" : {
          "@timestamp" : "2023-08-04T00:58:10.004Z",
          "destination" : {
            "bytes" : 93119,
            "ip" : "10.0.0.30",
            "port" : 9200,
            "packets" : 217
          },
          "event" : {
            "action" : "network_flow",
            "type" : [
              "connection"
            ],
            "start" : "2023-08-04T00:56:16.424Z",
            "end" : "2023-08-04T00:58:09.064Z",
            "duration" : 112640025345,
            "dataset" : "flow",
            "kind" : "event",
            "category" : [
              "network"
            ]
          },
          "network" : {
            "transport" : "tcp",
            "community_id" : "1:nzJn2PsyHQgb/pT9ZcAMwquMXDY=",
            "bytes" : 641135,
            "packets" : 556,
            "type" : "ipv4"
          },
.....
.....
[4] If Kibana is running, it's possible to import data to sample Dashboards.
root@dlp:~#
packetbeat setup --dashboards

Loading dashboards (Kibana must be running and reachable)
Loaded dashboards

Matched Content