Search code examples
google-cloud-platformapache2google-cloud-stackdrivergoogle-cloud-logginggoogle-cloud-ops-agent

Monitoring Apache2 in Google Cloud with Ops Agent


I have Apache2 installed in one of VMs in Google Cloud Platform. I installed Ops Agent and configured it like below per the docs:

logging:
  receivers:
    mywebserver:
      type: files
      include_paths:
      - /var/log/apache*/access_log
      - /var/log/apache*/error_log
  service:
    pipelines:
      default_pipeline:
        receivers:
        - mywebserver

But then the Logs in GCP isn't showing the logs of this web-server. I don't see the service mywebserver as filter option in the logs dropdown even for this VM instance.

OS: Ubuntu 18.x LTS

Ops Agent Version : Latest as of today

What am I missing? Your help is much appreciated.


Solution

  • When I tried to debug using the command cat /var/log/google-cloud-ops-agent/subagents/*.log | grep apache it returned nothing. It should show something similar to below:

    [ info] [input:tail:tail.0] inotify_fs_add(): inode=268631 watch_fd=1 name=/var/log/apache2/access.log
    [input:tail:tail.0] inotify_fs_add(): inode=268633 watch_fd=2 name=/var/log/apache2/error.log
    

    This prompted me to get back to logs and realized that the google docs had a typo and I ended up copy-pasting the lines in good faith. Basically if you note my configuration instead of access.log the line contains access_log.

    As trivial as it sounds, this killed a good deal of hours of mine. :Facepalm:

    Lesson: Even Google Docs can have errors something as trivial as this that can kill your hours in debugging.