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

mongodb_exporter service fails to start on Amazon linux #912

Open
Eric-Tyrrell22 opened this issue Sep 17, 2024 · 3 comments
Open

mongodb_exporter service fails to start on Amazon linux #912

Eric-Tyrrell22 opened this issue Sep 17, 2024 · 3 comments

Comments

@Eric-Tyrrell22
Copy link

Eric-Tyrrell22 commented Sep 17, 2024

Describe the bug
mongodb_exporter systemd service failing to start on
al2023-ami-2023.5.20240916.0-kernel-6.1-x86_64

To Reproduce

  • wget 'https://github.com/percona/mongodb_exporter/releases/download/v0.41.0/mongodb_exporter-0.41.0.linux-64-bit.rpm'
  • sudo yum install ./mongodb_exporter-0.41.0.linux-64-bit.rpm
  • systemctl start mongodb_exporter
  • journalctl -u mongodb_exporter

Expected behavior
mongodb_exporter service starts

Logs

Sep 17 16:15:57 ip-172-31-31-213.ec2.internal systemd[1]: mongodb_exporter.service: Main process exited, code=exited, status=216/GROUP
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ An ExecStart= process belonging to unit mongodb_exporter.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 216.
Sep 17 16:15:57 ip-172-31-31-213.ec2.internal systemd[1]: mongodb_exporter.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ The unit mongodb_exporter.service has entered the 'failed' state with result 'exit-code'.
Sep 17 16:15:57 ip-172-31-31-213.ec2.internal systemd[1]: mongodb_exporter.service: Scheduled restart job, restart counter is at 5.

Environment

cat /etc/os-release

NAME="Amazon Linux"
VERSION="2023"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2023"
PLATFORM_ID="platform:al2023"
PRETTY_NAME="Amazon Linux 2023.5.20240916"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
HOME_URL="https://aws.amazon.com/linux/amazon-linux-2023/"
DOCUMENTATION_URL="https://docs.aws.amazon.com/linux/"
SUPPORT_URL="https://aws.amazon.com/premiumsupport/"
BUG_REPORT_URL="https://github.com/amazonlinux/amazon-linux-2023"
VENDOR_NAME="AWS"
VENDOR_URL="https://aws.amazon.com/"
SUPPORT_END="2028-03-15"

Additional context
Issue has been ran into before:
#815

I fixed this by changing the group in the service file to mongodb_exporter.

I'm not 100% sure if changing the group to mongodb_exporter would have security implications, but I have the feeling that it would be negligble at worst.

taking a look at the mongod service file, they specify the same user and group, for example.
https://github.com/mongodb/mongo/blob/master/debian/mongod.service#L8-L9

This change can be made here:
https://github.com/percona/mongodb_exporter/blob/main/.scripts/systemd/mongodb_exporter.service#L10

@BupycHuk
Copy link
Member

Hello @Eric-Tyrrell22, have you passed options to service? could you replace $OPTIONS with flags you need.

@Eric-Tyrrell22
Copy link
Author

Eric-Tyrrell22 commented Sep 17, 2024

@BupycHuk I actually did replace the $OPTIONS with the flags I needed, but this issue was still present. It seems like not all operating systems have the group nogroup which is what's causing this issue. Amazon linux has nobody instead of nogroup

# Debian OS
$ cat /etc/group | grep no
nogroup:x:65534:

# Amazon linux
$ cat /etc/group | grep no
nobody:x:65534:

For reference this is the service file I'm using now.

[Unit]
Description=Prometheus MongoDB Exporter
Documentation=https://github.com/percona/mongodb_exporter
After=network.target

[Service]
Type=simple

User=mongodb_exporter
Group=mongodb_exporter

ExecStart=/usr/bin/mongodb_exporter --mongodb.uri="mongodb://localhost:27017/" --discovering-mode --collector.dbstats --collector.dbstatsfreestorage --collector.collstats

Restart=always

[Install]
WantedBy=multi-user.target

@ogronome
Copy link

That's definitely a bug in packaging, RHEL also doesn't have this group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants