Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
Ops agent acts as the primary agent for collecting telemetry from the user's compute engine instances. It combines logging and metrics into a single agent. It uses Fluent Bit for logs that support high-throughput logging and OpenTelemtery Collector for metrics. It can also be used for supporting the parsing of log files from third-party applications.
Ops agent features
Following are some of the features of Ops agent:
Logging features include
Standard system logs
Custom logs files
JSON files
Plain text logs
Regex-based parsing
JSON-based parsing
Efficient resource management
Monitoring features include
System metrics without setup
Things included with metrics
Cpu metrics
Disk metrics
iis metrics
Interface metrics
Memory metrics
Swap metrics
Network metrics
Internal agent metrics like api_request_count, memory_usage, point_count, uptime
Agent access requirements
Access to the below-mentioned DNS name is required for installing the agent
Google Cloud package repository, which is available at packages.cloud.google.com
The following DNS names are required for running the agent
The following command can be used to remove the ops agent and its related configuration files. The google cloud console might take up to an hour to report the changes
Agent policies have given the option to automate the installation and maintenance of the Google Cloud's operation suite agents across a fleet of VMs that matches the user's specified criteria. It allows the user to create a policy for their Google cloud project using just one command. The policy can govern existing or new VMs associated with that particular cloud project, ensuring proper installation and optional auto-upgrade of all the agents.
Creating an Agent Policy
If you wish to create an agent policy using the Google Cloud CLI, follow the below steps:
Install the Google cloud cli.
If not installed, install the beta component of the gcloud CLI:
gcloud components install beta
If you want to check the beta component for the installed, use the following command:
gcloud components list
In order to enable the APIs and to set the proper permissions use the following command: set-permissions.sh
An additional setup is required to ensure the OS config agent that the policy on which it relies is installed on the VMs for a policy to take effect on VMs that predate OS config. If you wish to install the OS config agent on a fleet on VMs, follow the below steps:
The user must ensure that the set-permissions.sh script has been run in the Creating an agent policy section.
Choose all the VMs on which you want to install the OS config agent and list them in a CSV file. In order to get a list of all the other non Google-managed instances into a csv, run the following command:
VMs that have an already installed and enabled OS config agent is filtered using the grep section. The goog- filters out compute engine VMs which are managed by GKE, App Engine, etc.
To filter the instances further based on zones or labels, change the –filter to:
"-labels.list(show="keys"):goog- AND zone:(ZONE_1,ZONE_2) AND labels.KEY_1:VALUE_1 AND labels.KEY_2=VALUE_2"
Troubleshooting
The ops-agent policy commands fail
In case the ops-agent policy commands fail, a corresponding validation error will appear. The errors can be corrected by fixing the command arguments and flags as suggested by the error message.
The following error can also appear:
Insufficient IAM permission
The user should ensure that the set-permissions.sh script has been run in the Creating an Agent Policy section for setting up the osconfig.guestPolicy specific IAM role.
Osconfig API is not enabled
The user must ensure that the set-permissions.sh script has been run in the Creating an Agent Policy section to grant/allow all the necessary permissions.
To check if OS config API is enabled or not for the project, use the below command
gcloud services list --project project-id \
| grep osconfig.googleapis.com
The output should be like this:
osconfig.googleapis.com Cloud OS Config API
The policy is created but has no effect.
To manage the packages for the Logging and Monitoring agents, OS Config agents are deployed to each Compute Engine instance. If the underlying OS Config agent is not installed, then the policy may seem to have no effect.
To check that the OS Config agent is installed, use the below command
The OS Config agent is installed, but Ops agents aren't
The OS Config agent's log can be used to check if there is any error when the OS Config agent applies the policies. This can be done both ways, either via Logs explorer or SSH into individual compute engine instances.
Use the below filter to view the OS Config agent logs in Logs Explorer
resource.type="gce_instance"
logName="projects/project-id/logs/OSConfigAgent"
To view the OS Config agent logs via SSH for Ubuntu
gcloud compute ssh instance-id \
--project project-id \
-- sudo cat /var/log/syslog \
| grep "OSConfigAgent\|google-fluentd\|stackdriver-agent"
To view the OS Config agent logs via RDP for individual Compute engine windows instances, follow the below steps:
Login to windows after connecting to your instance using the RDP or any other similar tool
Search for logs with Source equal to OSConfigAgent after opening the Event Viewer app under the Windows logs -> Application
To verify if the OS Config metadata is enabled or not, use the below command
gcloud compute project-info describe \
--project project-id \
| grep "enable-osconfig\|enable-guest-attributes" -A 1
The output will look like this:
- key: enable-guest-attributes
value: 'TRUE'
- key: enable-osconfig
value: 'TRUE'
Several ways are provided by the Google Cloud's operations suite to manage the Ops agent across your fleet of Compute engine Linux Vms:
Ansible
It can be used to install and configure the agent across your fleet of Linux VMs.
Chef
The chefbook can be used to install and configure the agent across your fleet of Linux VMs. It must be noted that for Windows VMs only the Ops agent is supported.
Puppet
The puppet module can be used to install and configure the agent across your fleet of Linux VMs. It must be noted that for Windows VMs only the Ops agent is supported.
Terraform
The Terraform module can be used to install and configure the agent on VMs with supported operating systems.
Agent Policy using gcloud CLI
The Google Cloud CLI can be used to create an agent policy that can govern new as well as existing VMs with supported operating systems, ensuring proper installation and optional auto-upgrade of all agents.
Frequently Asked Questions
Name two Linux operating systems that the agents support.
Rocky Linus 8 and CentOS7 are two of the many Linux operating systems supported by the agents.
Does the RHEL 6 operating system support monitoring agents?
No, monitoring agents aren't supported by the RHEL 6 operating system.
Mention any one use of the OS Config agent's log.
The OS Config agent's logs can be used to check if there are any errors when the OS Config agent applies policies.
Conclusion
In this article, we have extensively discussed the Overview of the Ops Agent.
After reading about Overview of the Ops Agent, are you not feeling excited to read/explore more articles on Google Cloud? Don't worry; Coding Ninjas has you covered. To learn about GCP certification: Google Cloud Platform, the difference between AWS, Azure & Google Cloud, and which platform is best: AWS vs. Google Cloud.
If you wish to enhance your skills in Data Structures and Algorithms, Competitive Programming, JavaScript, etc., you should check out our Guided path column at Coding Ninjas Studio. We at Coding Ninjas Studio organize many contests in which you can participate. You can also prepare for the contests and test your coding skills by giving the mock test series available. In case you have just started the learning process, and your dream is to crack major tech giants like Amazon, Microsoft, etc., then you should check out the most frequently asked problems and the interview experiences of your seniors that will surely help you in landing a job in your dream company.