1

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.

karthiks
  • 7,049
  • 7
  • 47
  • 62
  • 1
    Did you go through the [troubleshooting docs](https://cloud.google.com/monitoring/agent/ops-agent/troubleshooting)? A simple restart of agent might do the trick.... – dany L Jul 16 '21 at 18:29
  • 1
    1) What do you have set for the VM's **Access scopes**? 2) SSH into the VM and review error messages here: /var/log/google-cloud-ops-agent/subagents/*.log – John Hanley Jul 16 '21 at 18:33
  • 1
    Also check the service account attached to your VM, if you are using default SA then editor should be fine. If you are using your own SA then make sure to choose something like editor or monitoring admin. – dany L Jul 16 '21 at 18:43

1 Answers1

2

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.

karthiks
  • 7,049
  • 7
  • 47
  • 62