elastic / elastic/beats

Metricbeat does not respect on output.file.permissions

Open
#17,745 4 comments 0 reactions 0 assignees View on GitHub
Team:Elastic-Agent-Data-Plane
Dominant language
Go
Stars
12.7k
Forks
5k
Avg merge
2d 1h
Merged PRs (30d)
370

Description

Please post all questions and issues on https://discuss.elastic.co/c/beats
before opening a Github Issue. Your questions will reach a wider audience there,
and if we confirm that there is a bug, then you can open a new issue.

For security vulnerabilities please only send reports to security@elastic.co.
See https://www.elastic.co/community/security for more information.

Please include configurations and logs if available.

For confirmed bugs, please report:
- Version: 7.5.2
- Operating System: Centos 7.6
- Discuss Forum URL: https://discuss.elastic.co/t/metricbeat-does-not-respect-on-output-file-permissions/227325
- Steps to Reproduce:

My metricbeat config for file output is this:
```
output.file:
# Boolean flag to enable or disable the output module.
enabled: True

# Configure JSON encoding
#codec.json:
# Pretty-print JSON event
#pretty: false

# Configure escaping HTML symbols in strings.
#escape_html: false

# Path to the directory where to save the generated files. The option is
# mandatory.
path: "/var/log/metricbeat/probes"

# Name of the generated files. The default is `metricbeat` and it generates
# files: `metricbeat`, `metricbeat.1`, `metricbeat.2`, etc.
filename: metricbeat_probes.log

# Maximum size in kilobytes of each file. When this size is reached, and on
# every Metricbeat restart, the files are rotated. The default value is 10240
# kB.
rotate_every_kb: 10240

# Maximum number of files under path. When this number of files is reached,
# the oldest file is deleted and the rest are shifted from last to first. The
# default is 7 files.
number_of_files: 3

# Permissions to use for file creation. The default is 0600.
permissions: 0644
```

But the created files have 0640 permissions:
```
[root@elastic01 probes]# pwd
/var/log/metricbeat/probes
[root@elastic01 probes]# ls -l
total 68
-rw-r-----. 1 metricbeat metricbeat 68454 Apr 9 15:15 metricbeat_probes.log
```

Elastic already reproduced : Logfile:
```
2020-04-10T13:59:56.887-0600 INFO [file] fileout/file.go:100 Initialized file output. path=/Users/kaiyansheng/metricbeat-logs/metricbeat_probes.log max_size_bytes=10485760 max_backups=3 permissions=-rw-r--r--
```
Filesystem:
```
-rw-r----- 1 kaiyansheng staff 17K Apr 10 13:56 metricbeat_probes.log
```

Contributor guide

Open the contributing guide

Research direction

Start in fileout/file.go around the initialization logged at line 100, using the provided output.file configuration and filesystem listing as the reproduction. Verify how permissions are applied when metricbeat_probes.log is created; done means the generated file uses the configured 0644 mode rather than 0640.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, linux
Domain
observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.