Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libbeat 7.12.1 default logging logs excessive amount of data when failing to create index template #25540

Closed
gpapakyriakopoulos opened this issue May 5, 2021 · 5 comments · Fixed by #25743

Comments

@gpapakyriakopoulos
Copy link

As the title mentions, auditbeat on the default logging level (INFO based on official documentation) logs an excessive amount of data on syslog when failing to create an index template (ex. Due to insufficient access privileges).

After logging the initial exception error, it proceeds to also log the full index template as part of the exception error log, which usually amounts to several thousand lines of JSON. The log output is repeated continuously while the error is present, resulting in quickly filling up massive amounts of disk space.

An example (truncated) error log that fits the above description is as follows :

Connection marked as failed because the onConnect callback failed: error loading template: could not load template. Elasticsearch returned: couldn't load template: 403 Forbidden: {"error":{"roo
t_cause":[{"type":"security_exception","reason":"action [indices:admin/template/put] is unauthorized for user [beats_writer], this action is granted by the cluster privileges [manage_index_templates,manag
e,all]"}],"type":"security_exception","reason":"action [indices:admin/template/put] is unauthorized for user [beats_writer], this action is granted by the cluster privileges [manage_index_templates,manage
,all]"},"status":403}. Response body: {"error":{"root_cause":[{"type":"security_exception","reason":"action [indices:admin/template/put] is unauthorized for user [beats_writer], this action is granted by
the cluster privileges [manage_index_templates,manage,all]"}],"type":"security_exception","reason":"action [indices:admin/template/put] is unauthorized for user [beats_writer], this action is granted by t
he cluster privileges [manage_index_templates,manage,all]"},"status":403}. Template is: {
Apr 30 00:00:04 siem packetbeat[18558]:   "index_patterns": [
Apr 30 00:00:04 siem packetbeat[18558]:     "packetbeat-7.12.1-*"
Apr 30 00:00:04 siem packetbeat[18558]:   ],
Apr 30 00:00:04 siem packetbeat[18558]:   "mappings": {
Apr 30 00:00:04 siem packetbeat[18558]:     "_meta": {
Apr 30 00:00:04 siem packetbeat[18558]:       "beat": "packetbeat",
Apr 30 00:00:04 siem packetbeat[18558]:       "version": "7.12.1"
Apr 30 00:00:04 siem packetbeat[18558]:     },
Apr 30 00:00:04 siem packetbeat[18558]:     "date_detection": false,
Apr 30 00:00:04 siem packetbeat[18558]:     "dynamic_templates": [
Apr 30 00:00:04 siem packetbeat[18558]:       {
Apr 30 00:00:04 siem packetbeat[18558]:         "labels": {
Apr 30 00:00:04 siem packetbeat[18558]:           "mapping": {
Apr 30 00:00:04 siem packetbeat[18558]:             "type": "keyword"
Apr 30 00:00:04 siem packetbeat[18558]:           },
Apr 30 00:00:04 siem packetbeat[18558]:           "match_mapping_type": "string",
Apr 30 00:00:04 siem packetbeat[18558]:           "path_match": "labels.*"
Apr 30 00:00:04 siem packetbeat[18558]:         }
Apr 30 00:00:04 siem packetbeat[18558]:       },
Apr 30 00:00:04 siem packetbeat[18558]:       {
Apr 30 00:00:04 siem packetbeat[18558]:         "container.labels": {
Apr 30 00:00:04 siem packetbeat[18558]:           "mapping": {
Apr 30 00:00:04 siem packetbeat[18558]:             "type": "keyword"
Apr 30 00:00:04 siem packetbeat[18558]:           },
Apr 30 00:00:04 siem packetbeat[18558]:           "match_mapping_type": "string",
Apr 30 00:00:04 siem packetbeat[18558]:           "path_match": "container.labels.*"
Apr 30 00:00:04 siem packetbeat[18558]:         }
Apr 30 00:00:04 siem packetbeat[18558]:       },
Apr 30 00:00:04 siem packetbeat[18558]:       {
Apr 30 00:00:04 siem packetbeat[18558]:         "fields": {
Apr 30 00:00:04 siem packetbeat[18558]:           "mapping": {
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label May 5, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label May 5, 2021
@ChrsMark
Copy link
Member

ChrsMark commented May 5, 2021

Thanks for reporting this @gpapakyriakopoulos! Could you please add more information regarding version you are using and how you run auditbeat (configuration, cli flags, binary/service etc)?

cc: @andrewkroh @adriansr

@tsigouris007
Copy link

Our ES cluster runs on version 7.12.1.
Our beats + elastic-agent run on version 7.12.1.
Our auditbeat configuration is the following:

# =========================== Modules configuration ============================
auditbeat.config.modules:
  # Set to true to enable config reloading
  reload.enabled: true
  reload.period: 10s
  # Glob pattern for configuration reloading
  path: [ '${path.config}/audit.rules.d/*.conf' ]

auditbeat.modules:

- module: auditd
  # Load audit rules from separate files. Same format as audit.rules(7).
  audit_rule_files: [ '${path.config}/audit.rules.d/*.conf' ]
  audit_rules: |

- module: file_integrity
  paths:
    - /bin
    - /usr/bin
    - /sbin
    - /usr/sbin
    - /etc/sudoers
    - /etc/sudoers.d
    - /etc/shadow
    - /etc/shadow-
    - /etc/passwd
    - /etc/passwd-
    - /etc/gshadow
    - /etc/gshadow-
    - /etc/group
    - /etc/group-
    - /etc/pam.d
    - /etc/pam.conf
    - /etc/ntp.conf
    - /etc/ferm
    - /etc/cron.d
    - /etc/cron.daily
    - /etc/cron.hourly
    - /etc/cron.monthly
    - /etc/cron.weekly
    - /etc/crontab
    - /etc/ca-certificates
    - /etc/ca-certificates/conf
    - /etc/subgid
    - /etc/subgid-
    - /etc/subuid
    - /etc/subuid-
    - /etc/ssh
    - /etc/hosts
    - /etc/hosts.allow
    - /etc/hosts.deny
    - /etc/hostname
    - /etc/resolv.conf
    - /etc/selinux
    - /etc/security
    - /etc/ssl
    - /etc/fstab
    - /etc/services
    - /root
    - /boot/grub/grub.conf
  exclude_files:
    - /root/.bash_history
    - /root/.bashrc
  recursive: true

- module: system
  datasets:
    - package # Installed, updated, and removed packages
  period: 5m

- module: system
  datasets:
    - login # User logins, logouts, and system boots.
  period: 1m

- module: system
  datasets:
    - user # User information
  period: 10m

- module: system
  datasets:
    - host # General host information, e.g. uptime, IPs
  period: 10m

- module: system
  datasets:
    - socket # Opened and closed sockets
  period: 1m

  # How often datasets send state updates with the
  # current state of the system (e.g. all currently
  # running processes, all open sockets).
  state.period: 12h

  # Enabled by default. Auditbeat will read password fields in
  # /etc/passwd and /etc/shadow and store a hash locally to
  # detect any changes.
  user.detect_password_changes: true

  # File patterns of the login record files.
  login.wtmp_file_pattern: /var/log/wtmp*
  login.btmp_file_pattern: /var/log/btmp*

# =================================== Elastic ===================================
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: 
      - "https://...:9200"
  
  protocol: "https"
   
  ssl.certificate_authorities: [...]
  ssl.certificate: ...
  ssl.key: ...
  ssl.verification_mode: certificate
  
  username: ...
  password: ...
  
# ======================= Elasticsearch template setting =======================
setup.template.settings:
  index.number_of_shards: 3

Our environment is:

Environment="GODEBUG='madvdontneed=1'"
Environment="BEAT_LOG_OPTS="
Environment="BEAT_CONFIG_OPTS=-c /etc/auditbeat/auditbeat.yml"
Environment="BEAT_PATH_OPTS=--path.home /usr/share/auditbeat --path.config /etc/auditbeat --path.data /var/lib/auditbeat --path.logs /var/log/auditbeat"
ExecStart=/usr/share/auditbeat/bin/auditbeat --environment systemd $BEAT_LOG_OPTS $BEAT_CONFIG_OPTS $BEAT_PATH_OPTS

The service is running as systemd default service with no other customization.

@andrewkroh
Copy link
Member

This is a problem affecting all Beats since this logging is part of libbeat. I'd probably stop the template logging entirely. The template itself can be dumped using beatname export template --es.version=7.11.0 if needed for debugging purposes.

@andrewkroh andrewkroh added libbeat Team:Elastic-Agent Label for the Agent team labels May 10, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/agent (Team:Agent)

@andrewkroh andrewkroh changed the title Auditbeat 7.12.1 default logging logs excessive amount of data when failing to create index template libbeat 7.12.1 default logging logs excessive amount of data when failing to create index template May 10, 2021
andrewkroh added a commit to andrewkroh/beats that referenced this issue Jun 14, 2021
Index templates in some beats can be very large (~1MB) and including the data in errors can use a lot of memory and also makes for very large log lines. If the error is recurring then this makes the effects worse. So this change removes the index template body from the error. Users that need to see the index template for debugging can use `<beatname> export template --es.version=1.2.3`.

Fixes elastic#25540
andrewkroh added a commit that referenced this issue Jun 15, 2021
* Don't include full ES index template in errors

Index templates in some beats can be very large (~1MB) and including the data in errors can use a lot of memory and also makes for very large log lines. If the error is recurring then this makes the effects worse. So this change removes the index template body from the error. Users that need to see the index template for debugging can use `<beatname> export template --es.version=1.2.3`.

Fixes #25540

* Update expected log messages in tests
mergify bot pushed a commit that referenced this issue Jun 15, 2021
* Don't include full ES index template in errors

Index templates in some beats can be very large (~1MB) and including the data in errors can use a lot of memory and also makes for very large log lines. If the error is recurring then this makes the effects worse. So this change removes the index template body from the error. Users that need to see the index template for debugging can use `<beatname> export template --es.version=1.2.3`.

Fixes #25540

* Update expected log messages in tests

(cherry picked from commit 766e303)

# Conflicts:
#	libbeat/template/load.go
michalpristas pushed a commit to michalpristas/beats that referenced this issue Jun 17, 2021
* Don't include full ES index template in errors

Index templates in some beats can be very large (~1MB) and including the data in errors can use a lot of memory and also makes for very large log lines. If the error is recurring then this makes the effects worse. So this change removes the index template body from the error. Users that need to see the index template for debugging can use `<beatname> export template --es.version=1.2.3`.

Fixes elastic#25540

* Update expected log messages in tests
andrewkroh added a commit that referenced this issue Jun 30, 2021
…#26318)

* Don't include full ES index template in errors (#25743)

Index templates in some beats can be very large (~1MB) and including the data in errors can use a lot of memory and also makes for very large log lines. If the error is recurring then this makes the effects worse. So this change removes the index template body from the error. Users that need to see the index template for debugging can use `<beatname> export template --es.version=1.2.3`.

Fixes #25540

* Update expected log messages in tests

(cherry picked from commit 766e303)

Co-authored-by: Andrew Kroh <andrew.kroh@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants