You can also bundle Atatus infra agent inside your docker image, this helps you to monitor process level metrics inside the container along with resource metrics, logs and traces.

Following is a sample dockerfile to install Atatus Infrastructure Agent in the docker image.

Dockerfile

copy
icon/buttons/copy
# Dockerfile
FROM ubuntu:18.04

RUN apt-get update && apt-get install curl -y

RUN cd ~ \
    && export ATATUS_RELEASE="atatus-infra-agent-3.1.0-linux" \
    && curl -sS "https://s3.amazonaws.com/atatus-artifacts/atatus-infra/downloads/${ATATUS_RELEASE}.tar.gz" | tar xvzf - \
    && cd "${ATATUS_RELEASE}" \
    && ATATUS_LICENSE_KEY="lic_infra_***************" bash install.sh install \
    && cd .. \
    && unset ATATUS_RELEASE

CMD service atatus-infra-agent start; php-fpm

Also, in above file, we used php-fpm as a service. But you can replace it with your process/service command.

In Docker, Atatus infra agent won't start automatically. So you have to add the service atatus-infra-agent start before your process/service command either in ENTRYPOINT/CMD as follows.

Using ENTRYPOINT:

# shell format
ENTRYPOINT service atatus-infra-agent start; php-fpm

# exec format
ENTRYPOINT ["sh", "-c", "service atatus-infra-agent start; php-fpm"]

Using CMD:

# shell format
CMD service atatus-infra-agent start; php-fpm

# exec format
CMD ["sh", "-c", "service atatus-infra-agent start; php-fpm"]

You need to make the following changes to make this work.

  • Change php-fpm to your start application command.
  • Update ATATUS_RELEASE environment variable to latest version of the Atatus PHP agent.
  • Change the license key lic_infra_***************.

Enable Logs

You can collect logs through infra agent by enabling logs_enabled option. In below Dockerfile, we have added the following

  • Set logs_enabled to true.
  • Copy sample files.yml to /etc/atatus-infra-agent/conf.d/files.d/ folder. This file defines from which location/path to collect logs.
# Dockerfile
FROM ubuntu:18.04
RUN apt-get update && apt-get install curl -y

RUN cd ~ \
    && export ATATUS_RELEASE="atatus-infra-agent-3.1.0-linux" \
    && curl -sS "https://s3.amazonaws.com/atatus-artifacts/atatus-infra/downloads/${ATATUS_RELEASE}.tar.gz" | tar xvzf - \
    && cd "${ATATUS_RELEASE}" \
    && ATATUS_LICENSE_KEY="lic_infra_***************" bash install.sh install \
    && sed -i -e 's/logs_enabled: .*/logs_enabled: true/' /etc/atatus-infra-agent/atatus.yml \
    && cd .. \
    && unset ATATUS_RELEASE

# copy custom log config file
COPY ./files.yml /etc/atatus-infra-agent/conf.d/files.d/

CMD service atatus-infra-agent start; php-fpm

files.yml

Following is the sample log config file to capture the app logs.
You can change the file path under paths field.

# files.yml
logs:
  - type: file
    paths:
      - /home/myapp/app/logs/error.log*
    source: source_name
    service: service_name
    severity: error # debug, info, notice, success, warning, error