Senior Software Engineer
Share
As applications become more complex both in functionality and deployment footprint, observability becomes increasingly crucial. App Platform supports metrics via our Insights features and logging via the Log Forwarding feature. In this post, we will build on the microservices architecture example by demonstrating how to enhance it with log forwarding to Managed OpenSearch.
Distributed applications often lead to distributed problems that are difficult to debug. Microservices architecture, while powerful, introduces a layer of complexity that can be daunting. Services need to communicate effectively, manage state, and scale independently. All these factors contribute to an intricate web of interdependencies that can make troubleshooting a nightmare.
App Platform simplifies the deployment and management of distributed apps. It allows developers to focus on coding and application logic, while App Platform handles the infrastructure. With features like Log Forwarding, Insights, and Alerts, it offers a streamlined approach to handling complex architectures.
In a previous post, Deploying your Microservices Architecture App in App Platform, we discussed how to deploy a microservices app with a managed Kafka cluster and two components:
Web Service API: Receives requests, publishes messages to Kafka, and responds to the user.
Backend Processing Service: Consumes messages from Kafka and processes them.
This architecture allows for independent scaling of the web service API and backend processing service, providing flexibility and efficiency.
Now, let’s enhance this architecture with improved observability using App Platform’s Log Forwarding feature. Logs are vital for understanding what is happening within your application. By forwarding logs to OpenSearch, you can gain deeper insights and make debugging easier.
App Platform supports OpenSearch in two different ways:
Bring-Your-Own: In this mode, you can use any OpenSearch or ElasticSearch endpoint as long as it supports TLS and authentication via a username and password.
DigitalOcean Managed OpenSearch: You can create a cluster in a few minutes via the Cloud Console’s Databases page.
In this example, we’ll use a managed OpenSearch cluster for simplicity.
Enable Log Forwarding: In the App Platform dashboard, navigate to your app and enable log forwarding from the settings tab.
Configure OpenSearch: Set up an OpenSearch instance where your logs will be sent. Ensure your OpenSearch endpoint is accessible and properly secured.
Alternatively, you can modify the App Spec located in the Kafka post repository.
Here’s what the changes to the app spec would look like
yaml
name: sample-golang-kafka-2
# env and databases sections removed for brevity
services:
- name: producer
source_dir: producer
github:
repo: digitalocean/sample-golang-kafka
branch: main
log_destinations:
- name: logs-producer
open_search:
cluster_name: my-opensearch-cluster
workers:
- name: consumer
source_dir: consumer
github:
repo: digitalocean/sample-golang-kafka
branch: main
log_destinations:
- name: logs-consumer
open_search:
cluster_name: my-opensearch-cluster
Login via the link provided in the OpenSearch database dashboard using the credentials provided
Create an Index Pattern by navigating to Management → Dashboards Management → Index Patterns
Use the Default datasource
Specify a pattern name of ‘logs*’
Specify @timestamp
as the Time field and click the Create index pattern button
Navigate to OpenSearch Dashboards → Discover
App Platform is designed to simplify the complexities of deploying and managing distributed, cloud-native apps. By leveraging features like Log Forwarding and Managed OpenSearch, you can enhance observability and streamline your operational experience. Try out these features and let us know how they help you manage your distributed applications more effectively.
Share