MetricPoints help

Set up server log access

Connect Nginx or Apache access/error logs, grant metricpoints-agent read permission, preserve access after log rotation, and troubleshoot empty logs.

Skip to guide

Integrations / Set up server log access

Set up server log access

Connect a site's access and error logs to its Linux server agent to review recent activity and collection problems. Start with one site, verify a result, then add other files. The agent reads bounded samples locally and sends counts and file diagnostics; raw requests, headers and error messages stay on the server.

You need a connected server linked to the site, agent 0.7.1 or newer for current-file diagnostics, Python 3, and a hosting administrator who can grant file access. Agent 0.7.0 supports mappings but cannot explain all empty-log causes. These checks are on demand; they do not enable continuous traffic monitoring or automatic IP blocking.

1. Identify the site's files

Ask the hosting administrator to confirm the active virtual host's access and error destinations and log format. For Nginx, review access_log, error_log and log_format; for Apache/httpd, review CustomLog, ErrorLog and LogFormat. A filename alone does not prove a file belongs to one site.

  • Use separate, site-specific regular files directly under /var/log/nginx, /var/log/apache2 or /var/log/httpd. Symlinks, nested directories, shared cross-site logs, syslog and journald are not supported.
  • Common/combined access logs, Nginx error logs and standard Apache error logs have parsers. JSON/custom formats can be saved for assisted setup but are not collected.
  • Map access and error files separately. Add up to five exact older files per source, such as example_access.log.1 and example_access.log.2.gz, only when readable. Plain text and gzip are supported; wildcards are not.

The examples below use example_access.log and example_error.log. Replace them with your reviewed paths. Run commands on the monitored server as its administrator, not on the MetricPoints application host. Do not copy configuration dumps or raw logs into support requests.

2. Check existing agent access

Access for your SSH login does not establish access for the service. Check the actual account and file metadata:

id metricpoints-agent
systemctl show metricpoints-agent.service -p User -p Group -p SupplementaryGroups
namei -l /var/log/nginx/example_access.log
stat -c '%A %U:%G %n' /var/log/nginx/example_access.log /var/log/nginx/example_error.log

Then test an actual open as the agent, without printing log contents. This also works for an empty file:

sudo -u metricpoints-agent python3 - <<'PY'
import os
import stat

for path in (
    "/var/log/nginx/example_access.log",
    "/var/log/nginx/example_error.log",
):
    try:
        parent, name = os.path.split(path)
        directory = os.open(parent, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW)
        try:
            fd = os.open(name, os.O_RDONLY | os.O_NONBLOCK | os.O_NOFOLLOW, dir_fd=directory)
        finally:
            os.close(directory)
        try:
            if not stat.S_ISREG(os.fstat(fd).st_mode):
                raise OSError("not a regular file")
            os.read(fd, 1)
        finally:
            os.close(fd)
        print("READABLE", path)
    except OSError as error:
        print("UNAVAILABLE", path, error.strerror or str(error))
PY

Add any mapped rotations to the path list. If every selected file is readable, skip permission changes. This checks operating-system access; the final MetricPoints check also verifies service restrictions and parsing. If sudo requires a password, enter it locally or ask the host administrator to run the check. Never send it to support.

3. Grant read access

Option A: selected files with ACLs — recommended for shared hosts

If needed, install ACL tools with sudo apt-get install acl on Ubuntu or sudo dnf install acl on AlmaLinux. Inspect and save the current permissions before changing them:

umask 077
log_acl_backup=$(mktemp /tmp/metricpoints-log-acls.XXXXXX)
sudo getfacl -p /var/log/nginx /var/log/nginx/example_access.log /var/log/nginx/example_error.log > "$log_acl_backup"
printf 'ACL backup: %s\n' "$log_acl_backup"
sudo getfacl -p /var/log/nginx/example_access.log /var/log/nginx/example_error.log
sudo setfacl --test -m u:metricpoints-agent:r /var/log/nginx/example_access.log /var/log/nginx/example_error.log

Review the preview, especially existing entries whose permissions are limited by an ACL mask: recalculating that mask can also change their effective access. Move the backup to your secure operational records. Once reviewed, apply read access:

sudo setfacl -m u:metricpoints-agent:r /var/log/nginx/example_access.log /var/log/nginx/example_error.log

If the containing directory is inaccessible, the collector needs read and search permission on it. Grant this only where required; ancestors also need search permission. Directory access alone does not grant read access to the other files:

sudo setfacl -m u:metricpoints-agent:rx /var/log/nginx

Repeat for exact mapped rotations, then rerun the open check. Avoid recursive grants, world-readable logs, changing the writer's ownership, or running the agent as root. See the ACL command reference and ACL access rules.

Option B: an existing log-reader group — broader access

Use this only when the host owner approves access to all files readable by that group. On some Ubuntu servers, logs are owned by www-data:adm with mode 0640. After confirming those permissions and the group's scope:

sudo usermod -aG adm metricpoints-agent
id metricpoints-agent

Keep -aG so existing memberships are preserved. The adm group is an example, not a requirement; do not assume it exists or has the same scope on Apache or AlmaLinux. It can expose unrelated system or customer logs. A host administrator can instead arrange a dedicated reader group and matching rotation ownership.

New service processes pick up account group membership even when SupplementaryGroups is empty. MetricPoints uses a timer and a short-lived reporting service, so the next invocation uses the updated groups. Check the timer and request a fresh log check; a service shown as inactive between runs is normal. See systemd's account and group behavior.

systemctl status metricpoints-agent.timer --no-pager
systemctl show metricpoints-agent.service -p Type -p Result -p ExecMainStatus

4. Keep access after rotation

A one-time ACL may disappear when a new file replaces the current log or when an archive is compressed. A group-based setup depends on replacement files retaining the approved readable group and mode. For example, create 0640 www-data adm preserves that group access for newly created logs; confirm your own writer and group before using it.

Have the administrator review the existing Nginx/Apache stanza in /etc/logrotate.d/ and retain its reopen commands. For ACLs, merge a narrowly scoped lastaction block into that same stanza (or merge into its existing block). This example reapplies access after rotation/compression, only to the explicitly listed files that exist. Adjust the list to the files you approved and mapped:

lastaction
    for log_file in \
        /var/log/nginx/example_access.log \
        /var/log/nginx/example_error.log \
        /var/log/nginx/example_access.log.1 \
        /var/log/nginx/example_access.log.2.gz
    do
        if [ -f "$log_file" ] && [ ! -L "$log_file" ]; then
            /usr/bin/setfacl -m u:metricpoints-agent:r "$log_file" || exit 1
        fi
    done
endscript

This is a configuration fragment, not a shell command or a complete rotation policy. Confirm command -v setfacl matches the path, keep the configuration and log directory administrator-controlled, and retain existing scripts. Do not create a duplicate rotation stanza for the same logs or set a default ACL on a shared directory. Date-named archives need their exact mappings and permission list maintained.

Preview the full policy without rotating files, then repeat the open check and a MetricPoints check after the next normal rotation. A preview does not execute the ACL hook or prove future access. See the logrotate reference.

sudo logrotate --debug /etc/logrotate.conf

5. Map and verify collection

  1. Open the site in MetricPoints, then Settings → Site log sources. Choose its linked server.
  2. Save one access source: web-server type, actual parser, exact path, plain/gzip format, optional rotations, and IP field. For common/combined logs the IP field is normally 1. Confirm the file contains only this site's records.
  3. Keep IP attribution Unknown — needs review until trusted-proxy behavior is verified. Cloudflare peer addresses are always protected and excluded from visitor candidates; counts alone do not establish abuse.
  4. Select a 5, 15 or 60 minute window and choose Check access log. Refresh after the next agent report, usually about a minute. Verify the timestamp, source revision, current-file details and coverage.
  5. Add a separate error source with its own path and parser, then choose Check error log. Nginx/Apache error timestamps use the server's local timezone; access timestamps include their recorded offset.

Success means a fresh result verifies readable, recognizable contents for the saved mapping. A saved mapping or a successful agent heartbeat alone is not proof of log collection. Scans are limited to 8 MiB and 15 seconds across the configured files; a large file may leave rotations unscanned. Results older than five minutes are historical, and checks are retained for 24 hours.

6. Troubleshoot or undo access

  • Log file missing: confirm the active web-server destination and rotation name. Update the mapping if the path changed; readable older archives do not verify the current file.
  • Log file unreadable: rerun the open check, inspect directory access and ACL masks, and verify compression. If Unix permissions pass but the service still fails, ask the administrator to review service restrictions and SELinux/AppArmor denials without disabling those protections.
  • Access log is empty / no recent access records: consider low traffic, a new rotation, CDN-cached requests that never reach this host, disabled logging or a changed destination. An empty error log can be normal. Neither result automatically creates a site incident.
  • No recognizable log records: review the selected parser, access IP field and server timezone. JSON/custom formats need assisted setup.
  • Collection unavailable or request expired: verify Python 3, a fresh agent report, the timer, the source revision and server linkage. A missing prerequisite is not zero traffic.
  • Works until rotation: inspect the replacement file's owner/group, mode and ACL, including gzip archives. Correct the existing rotation policy and check again.

To stop checks, disable the source in MetricPoints. To revoke host access, first remove only the permission-maintenance lines you added to rotation. Remove the agent's ACL entry from every file and directory you granted, including remaining rotations; or remove only the group membership added for this setup:

# ACL example: repeat for the exact directories and rotations you changed.
sudo setfacl -x u:metricpoints-agent /var/log/nginx/example_access.log /var/log/nginx/example_error.log

# Group option only, if this setup added membership in adm:
sudo gpasswd -d metricpoints-agent adm

Revocation affects new service processes; let any running check finish and verify the next invocation. For an immediate ACL rollback on unchanged files, an administrator can restore the saved backup with sudo setfacl --restore=/secure/path/log-acls.before. Review it before restoring after rotation or other permission changes. Do not erase other users' ACL entries.

Use Help me set this up in the site's log-source panel to retain the site context and follow the request's owner/status. Provide the source kind, format, observation time and collection status. Keep passwords, agent tokens, raw log lines and private configuration out of the request.

Still need help? Contact MetricPoints. Include the site and what you were trying to do; leave out passwords and tokens.