<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title><![CDATA[Jonathan Simon - Elastic Observability Labs]]></title>
    <description><![CDATA[Trusted security news & research from the team at Elastic.]]></description>
    <copyright><![CDATA[© 2026. Elasticsearch B.V. All Rights Reserved]]></copyright>
    <image>
      <title><![CDATA[Jonathan Simon - Elastic Observability Labs]]></title>
      <url>https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltad972c1c27dbefc6/6a88d9782904ea5e8511d473/observability-labs-thumbnail.png</url>
      <link>https://www.elastic.co/observability-labs/author/jonathan-simon</link>
    </image>
    <link>https://www.elastic.co/observability-labs/author/jonathan-simon</link>
    <atom:link href="https://www.elastic.co/observability-labs/rss/author/jonathan-simon.xml" rel="self" type="application/rss+xml"/>
    <language><![CDATA[en]]></language>
    <lastBuildDate>Sun, 13 Sep 2026 20:37:55 GMT</lastBuildDate>
  <item>
    <title><![CDATA[Elastic Observability monitors metrics for Microsoft Azure in just minutes]]></title>
    <description><![CDATA[Follow this step-by-step process to enable Elastic Observability for Microsoft Azure metrics.]]></description>
    <content:encoded><![CDATA[<p>Developers and SREs choose Microsoft Azure to run their applications because it is a trustworthy world-class cloud platform. It has also proven itself over the years as an extremely powerful and reliable infrastructure for hosting business-critical applications.</p>
<p>Elastic Observability offers over 25 out-of-the-box integrations for Microsoft Azure services with more on the way. A full list of Azure integrations can be found in <a href="https://docs.elastic.co/integrations/azure">our online documentation</a>.</p>
<p>Elastic Observability aggregates not only logs but also metrics for Azure services and the applications running on Azure compute services (Virtual Machines, Functions, Kubernetes Service, etc.). All this data can be analyzed visually and more intuitively using Elastic®’s advanced machine learning (ML) capabilities, which help detect performance issues and surface root causes before end users are affected.</p>
<p>For more details on how Elastic Observability provides application performance monitoring (APM) capabilities such as service maps, tracing, dependencies, and ML-based metrics correlations, read <a href="https://www.elastic.co/blog/apm-correlations-elastic-observability-root-cause-transactions">APM correlations in Elastic Observability: Automatically identifying probable causes of slow or failed transactions</a>.</p>
<p>That’s right, Elastic offers capabilities to collect, aggregate, and analyze metrics for Microsoft Azure services and applications running on Azure. Elastic Observability is for more than just capturing logs — it offers a unified observability solution for Microsoft Azure workloads.</p>
<p>In this blog, we’ll review how Elastic Observability can monitor metrics for a three-tier web application running on Microsoft Azure and leveraging:</p>
<ul>
<li>Microsoft Azure Virtual Machines</li>
<li>Microsoft Azure SQL database</li>
<li>Microsoft Azure Virtual Network</li>
</ul>
<p>As you will see, once the integration is installed, metrics will arrive instantly and you can immediately start deriving insights from metrics.</p>
<h2 id="prerequisitesandconfig">Prerequisites and config</h2>
<p>Here are some of the components and details we used to set up this demonstration:</p>
<ul>
<li>Ensure you have a Microsoft Azure account and an Azure service principal with permission to read monitoring data from Microsoft Azure (<a href="https://docs.elastic.co/integrations/azure_metrics/monitor#integration-specific-configuration-notes">see details in our documentation</a>).</li>
<li>This post does <em>not</em> cover application monitoring; instead, we will focus on how Microsoft Azure services can be easily monitored. If you want to get started with examples of application monitoring, see our <a href="https://github.com/elastic/observability-examples/tree/main/azure/container-apps">Hello World observability code samples</a>.</li>
<li>In order to see metrics, you will need to load the application. We’ve also created a Playwright script to drive traffic to the application.</li>
</ul>
<h2 id="threetierapplicationoverview">Three-tier application overview</h2>
<p>Before we dive into the Elastic deployment setup and configuration, let's review what we are monitoring. If you follow the <a href="https://learn.microsoft.com/en-us/training/modules/n-tier-architecture/">Microsoft Learn N-tier example app</a> instructions for deploying the "What's for Lunch?" app, you will have the following deployed.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt78865baac7b2a393/6a85c9fb331d7a5460c3177f/blog-elastic-three-tier-application-overview.png" alt="three tier application overview" /></p>
<p>What’s deployed:</p>
<ul>
<li>Microsoft Azure VM presentation tier that renders an HTML client in the user's browser and enables user requests to be sent to the “What’s for Lunch?” app</li>
<li>Microsoft Azure VM application tier that communicates with the presentation and the database tier</li>
<li>Microsoft Azure SQL instance in the database tier, handling requests from the application tier to store and serve data</li>
</ul>
<p>At the end of the blog, we will also provide a Playwright script that can be run to send requests to this app in order to load it with example data and exercise its functionality. This will help drive metrics to “light up” the dashboards.</p>
<h2 id="settingitallup">Setting it all up</h2>
<p>Let’s walk through the details of how to deploy the example three-tier application, Azure integration on Elastic and visualize what gets ingested in Elastic’s Kibana® dashboards.</p>
<h3 id="step0getanaccountonelasticcloud">Step 0: Get an account on Elastic Cloud</h3>
<p>Follow the instructions to <a href="https://cloud.elastic.co/registration">get started on Elastic Cloud</a>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb1b5998e0b8cc454/6a85c9fd5c27905315f59b07/blog-elastic-free-trial.png" alt="elastic cloud free trial sign up" /></p>
<h3 id="step1deploythemicrosoftazurethreetierapplication">Step 1: Deploy the Microsoft Azure three-tier application</h3>
<p>From the <a href="https://portal.azure.com/">Azure portal</a>, click the Cloud Shell icon at the top of the portal to open Cloud Shell…</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt5fc8d120fc905c77/6a85ca00bc5bb3d25af81ad9/blog-elastic-open-cloud-shell.png" alt="open cloud shell" /></p>
<p>… and when the Cloud Shell first opens, select <strong>Bash</strong> as the shell type to use.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltaaf43e6f0672dc9b/6a85ca03ba7acc9689992130/blog-elastic-cloud-shell-bash.png" alt="cloud shell bash" /></p>
<p>If you’re prompted that “You have no storage mounted,” then click the <strong>Create storage</strong> button to create a file store to be used for saving and editing files from Cloud Shell.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt24691c80db0ce204/6a85ca06331d7aa36bc31783/blog-elastic-create-storage.png" alt="cloud shell create storage" /></p>
<p>You should now see the open Cloud Shell terminal.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4dc12c5d67ebb249/6a85ca0998292672295838ca/blog-elastic-cloud-shell-terminal.png" alt="cloud shell terminal" /></p>
<p>Run the following command in Cloud Shell to define the environment variables that we’ll be using in the Cloud Shell commands required to deploy and view the sample application.</p>
<p>Be sure to specify a valid RESOURCE_GROUP from your available <a href="https://portal.azure.com/#view/HubsExtension/BrowseResourceGroups">Resource Groups listed in the Azure portal</a>. Also specify a new password to replace the SpecifyNewPasswordHere placeholder text before running the command. See the Microsoft <a href="https://learn.microsoft.com/en-us/sql/relational-databases/security/password-policy?view=sql-server-ver16#password-complexity">password policy documentation</a> for password requirements.</p>
<pre><code>RESOURCE_GROUP="test"
APP_PASSWORD="SpecifyNewPasswordHere"
</code></pre>
<p>Run the following az deployment group create command, which will deploy the example three-tier web app in around five minutes.</p>
<pre><code>az deployment group create --resource-group $RESOURCE_GROUP --template-uri https://raw.githubusercontent.com/MicrosoftDocs/mslearn-n-tier-architecture/master/Deployment/azuredeploy.json --parameters password=$APP_PASSWORD
</code></pre>
<p>After the deployment has completed, run the following command, which returns the URL for the app.</p>
<pre><code>az deployment group show --output table --resource-group $RESOURCE_GROUP --name azuredeploy --query properties.outputs.webSiteUrl
</code></pre>
<p>Copy the web app URL and paste it into a browser to view the example “What’s for Lunch?” web app.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte72de03d59114cc0/6a85ca0beaf2457371a49f49/blog-elastic-whats-for-lunch.png" alt="whats for lunch app" /></p>
<h3 id="step2createanazureserviceprincipalandgrantaccesspermission">Step 2: Create an Azure service principal and grant access permission</h3>
<p>Go to the <a href="https://portal.azure.com/">Microsoft Azure Portal</a>. Search for active directory and select <strong>Microsoft Entra ID</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt8b89c41ce941474c/6a85ca0ef61d6e00729c2afb/blog-elastic-active-directory.png" alt="search active directory" /></p>
<p>Copy the <strong>Tenant ID</strong> for use in a later step in this blog post. This ID is required to configure Elastic Agent to connect to your Azure account.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc67ef8fd47a07daf/6a85ca1168266642671eabe7/blog-elastic-your-organization-overview.png" alt="your organization overview" /></p>
<p>In the navigation pane, select <strong>App registrations</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt63caee3d530d8fb6/6a85ca1480984c3ea4668fba/blog-elastic-your-organization-overview-app-registrations.png" alt="your organization overview app registrations" /></p>
<p>Then click <strong>New registration</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt28d2ae4600d587ab/6a85ca171aa1e1c669ff8d47/blog-elastic-your-organization-new-registration.png" alt="your organization new registrations" /></p>
<p>Type the name of your application (this tutorial uses three-tier-app-azure) and click <strong>Register</strong> (accept the default values for other settings).</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7b60e56405060b44/6a85ca1a11893cefaaa7ab7c/blog-elastic-register_an_application.png" alt="register an application" /></p>
<p>Copy the <strong>Application (client) ID</strong> and save it for later. This ID is required to configure Elastic Agent to connect to your Azure account.</p>
<p>In the navigation pane, select <strong>Certificates &amp; secrets</strong> , and then click <strong>New client secret</strong> to create a new security key.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt0a42c8cd0b462f5d/6a85ca1df5f1a033fb2ec8df/blog-elastic-three-tier-app-new-client-secret.png" alt="three tier app new client secret" /></p>
<p>Type a description of the secret and select an expiration. Click <strong>Add</strong> to create the client secret. Under <strong>Value</strong> , copy the secret value and save it (along with your client ID) for later.</p>
<p>After creating the Azure service principal, you need to grant it the correct permissions. In the Azure Portal, search for and select <strong>Subscriptions</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt27de6595abfe44ac/6a85ca1fabdc2927991224d6/blog-elastic-three-tier-subscriptions.png" alt="three tier subscriptions" /></p>
<p>In the Subscriptions page, click the name of your subscription. On the subscription details page, copy your <strong>Subscription ID</strong> and save it for a later step.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc969b5a5eecfbb8e/6a85ca2293ffb98248b9142b/blog-elastic-subscription-essentials-copy.png" alt="subscription essentials copy" /></p>
<p>In the navigation pane, select <strong>Access control (IAM)</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltcc0d6f8281122752/6a85ca259a32f15cbfa7dfd0/blog-elastic-subscription-access-control.png" alt="subscription access control" /></p>
<p>Click <strong>Add</strong> and select <strong>Add role assignment</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7b3b8d7bdf3f141e/6a85ca2807829039d0321752/blog-elastic-subscription-access-control-add-role-assignment.png" alt="subscription access control add role assignment" /></p>
<p>On the <strong>Role</strong> tab, select the <strong>Monitoring Reader</strong> role and then click <strong>Next</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt99f68cb7713f8205/6a85ca2b27c5cd03ec5f73d8/blog-elastic-add-role-assignment-monitoring-readers.png" alt="add role assignment monitoring reader" /></p>
<p>On the <strong>Members</strong> tab, select the option to assign access to <strong>User, group, or service principal</strong>. Click <strong>Select members</strong> , and then search for and select the principal you created earlier. For the description, enter the name of your service principal. Click <strong>Next</strong> to review the role assignment.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt6ac85a836aeaa428/6a85ca2ef9373d43ad96f584/blog-elastic-add-role-assignment-description.png" alt="add role assignment description" /></p>
<p>Click <strong>Review + assign</strong> to grant the service principal access to your subscription.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt2d1eb5fc55533145/6a85ca30abdc2963671224da/blog-elastic-add-role-assignment-review-assign.png" alt="add role assignment review assign" /></p>
<h3 id="step3createanazurevminstance">Step 3: Create an Azure VM instance</h3>
<p>In the Azure Portal, search for and select <strong>Virtual machines</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt6df66ab8fe5350d7/6a85ca3311893cc69ba7ab80/blog-elastic-search-virtual-machines.png" alt="search virtual machines" /></p>
<p>On the <strong>Virtual machines</strong> page, click <strong>+ Create</strong> and select <strong>Azure virtual machine</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt6ee0dafa647fa8fe/6a85ca36bc5bb3bd24f81ae1/blog-elastic-azure-virtual-machine.png" alt="azure virtual machine" /></p>
<p>On the Virtual machine creation page, enter a name like “metrics-vm” for the virtual machine name and select VM Size to be “Standard_D2s_v3 - 2 vcpus, 8 GiB memory.” Click the <strong>Next : Disks</strong> button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt087222cdca1f2bf1/6a85ca3943c0b7ea592f05fc/blog-elastic-create-virtual-macine-next-disks.png" alt="create a virtual machine next disks" /></p>
<p>On the <strong>Disks</strong> page, keep the default settings and click the <strong>Next : Networking</strong> button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt6c10808899e56ad5/6a85ca3c4710c6e42ad3cb33/blog-elastic-create-virtual-machine-next-networking.png" alt="create a virtual machine next networking" /></p>
<p>On the <strong>Networking</strong> page, demo-vnet should be selected for <strong>Virtual network</strong> and demo-biz-subnet should be selected for <strong>Subnet</strong>. These resources are created as part of the three-tier example app’s deployment that was done in Step 1.</p>
<p>Click the <strong>Review + create</strong> button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltaa7213850eedec1e/6a85ca405c2790854bf59b0b/blog-elastic-create-virtual-machine-review-create.png" alt="create virtual machine review create" /></p>
<p>On the <strong>Review</strong> page, click the <strong>Create</strong> button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt49cea7999c6d0609/6a85ca4327c5cd23e75f73de/blog-elastic-create-virtual-machine-validation-passed.png" alt="create virtual machine validation passed" /></p>
<h3 id="step4installtheazureresourcemetricsintegration">Step 4: Install the Azure Resource Metrics integration</h3>
<p>In your <a href="https://cloud.elastic.co/home">Elastic Cloud</a> deployment, navigate to the Elastic Azure integrations by selecting <strong>Integrations</strong> from the top-level menu. Search for azure resource and click the <strong>Azure Resource Metrics</strong> tile.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd2a117bba617a23a/6a85ca46ba7acce765992136/blog-elastic-integrations-azure-resource-metrics.png" alt="integrations azure resource metrics" /></p>
<p>Click <strong>Add Azure Resource Metrics.</strong></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt88cb6bba93e24136/6a85ca4c342d69099a21b0d7/blog-elastic-azure-resource-metrics.png" alt="azure resource metrics" /></p>
<p>Click <strong>Add integration only (skip agent installation)</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt92fcc0204f8e2c6f/6a85ca4f80984c32d3668fc8/blog-elastic-add-integration-only.png" alt="add integration only" /></p>
<p>Enter the values that you saved previously for Client ID, Client Secret, Tenant ID, and Subscription ID.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4a0db24f97f4278c/6a85ca53eaf24562dea49f51/blog-elastic-add-azure-resource-metrics-integration.png" alt="add azure resource metrics integration" /></p>
<p>As you can see, the Azure Resource Metrics integration will collect a significant amount of data from eight Azure services. Click <strong>Save and continue</strong>.</p>
<p>You’ll be presented with a confirmation dialog window. Click <strong>Add Elastic Agent to your hosts</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4e7144de0af25985/6a85ca57bc5bb3a239f81ae5/blog-elastic-azure-resource-metrics-integration-added.png" alt="azure resource metrics integration added" /></p>
<p>This will display the instructions required to install the Elastic agent. Copy the command under the <strong>Linux Tar</strong> tab.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt20087af321e53897/6a85ca5c11893cf7cba7ab86/blog-elastic-add-agent.png" alt="add agent linux tar" /></p>
<p>Next you will need to use SSH to log in to the Azure VM instance and run the commands copied from <strong>Linux Tar</strong> tab. Go to <a href="https://portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.Compute/VirtualMachines">Azure Virtual Machines</a> in the Azure portal. Then click the name of the VM instance that you created in Step 3.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt30bf828236f78a33/6a85ca60d7b2e7f92dfe84c8/blog-elastic-metrics-vm.png" alt="metrics vm" /></p>
<p>Click the <strong>Select</strong> button in the <strong>SSH Using Azure CLI</strong> section.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt5cba533db9a395fc/6a85ca6433f244843549f4fa/blog-elastic-metrics-vm-connect.png" alt="metrics vm connect" /></p>
<p>Select the “I understand …” checkbox and then click the <strong>Configure + connect</strong> button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt5b7633d6cff018a8/6a85ca6943c0b707022f0604/blog-elastic-ssh-using-azure-cli.png" alt="ssh using azure cli" /></p>
<p>Once you are SSH’d inside the VM instance terminal window, run the commands copied previously from <strong>Linux Tar tab</strong> in the <strong>Install Elastic Agent on your host</strong> instructions. When the installation completes, you’ll see a confirmation message in the Install Elastic Agent on your host form.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt0af6bd380836ec18/6a85ca6c27c5cdc79b5f73e8/blog-elastic-add-agent-confirmed.png" alt="add agent confirmed" /></p>
<p>Super! The Elastic agent is sending data to Elastic Cloud. Now let’s observe some metrics.</p>
<h3 id="step5runtrafficagainsttheapplication">Step 5: Run traffic against the application</h3>
<p>While getting the application running is fairly easy, there is nothing to monitor or observe with Elastic unless you add a load on the application.</p>
<p>Here is a simple script you can also run using <a href="https://playwright.dev/">Playwright</a> to add traffic and exercise the functionality of the Azure three-tier application:</p>
<pre><code>import { test, expect } from "@playwright/test";

test("homepage for Microsoft Azure three tier app", async ({ page }) =&gt; {
  // Load web app
  await page.goto("http://20.172.198.231/");
  // Add lunch suggestions
  await page.fill("id=txtAdd", "tacos");
  await page.keyboard.press("Enter");
  await page.waitForTimeout(1000);
  await page.fill("id=txtAdd", "sushi");
  await page.keyboard.press("Enter");
  await page.waitForTimeout(1000);
  await page.fill("id=txtAdd", "pizza");
  await page.keyboard.press("Enter");
  await page.waitForTimeout(1000);
  await page.fill("id=txtAdd", "burgers");
  await page.keyboard.press("Enter");
  await page.waitForTimeout(1000);
  await page.fill("id=txtAdd", "salad");
  await page.keyboard.press("Enter");
  await page.waitForTimeout(1000);
  await page.fill("id=txtAdd", "sandwiches");
  await page.keyboard.press("Enter");
  await page.waitForTimeout(1000);
  // Click vote buttons
  await page.getByRole("button").nth(1).click();
  await page.getByRole("button").nth(3).click();
  await page.getByRole("button").nth(5).click();
  await page.getByRole("button").nth(7).click();
  await page.getByRole("button").nth(9).click();
  await page.getByRole("button").nth(11).click();
  // Click remove buttons
  await page.getByRole("button").nth(12).click();
  await page.getByRole("button").nth(10).click();
  await page.getByRole("button").nth(8).click();
  await page.getByRole("button").nth(6).click();
  await page.getByRole("button").nth(4).click();
  await page.getByRole("button").nth(2).click();
});
</code></pre>
<h3 id="step6viewazuredashboardsinelastic">Step 6: View Azure dashboards in Elastic</h3>
<p>With Elastic Agent running, you can go to Elastic Dashboards to view what’s being ingested. Simply search for “dashboard” in Elastic and choose <strong>Dashboard</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt33b70441f8217fae/6a85ca6f1aa1e10ef4ff8d4d/blog-elastic-dashboard.png" alt="dashboard" /></p>
<p>This will open the Elastic Dashboards page. In the Dashboards search box, search for azure vm and click the <strong>[Azure Metrics] Compute VMs Overview</strong> dashboard, one of the many out-of-the-box dashboards available.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blta63ce646f43a10c7/6a85ca73f5f1a021832ec8eb/blog-elastic-dashboards-create.png" alt="dashboards create" /></p>
<p>You will see a Dashboard populated with your deployed application’s VM metrics.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltdacd5a541976c209/6a85ca779d2b71018ff9396f/blog-elastic-azure-compute-vm.png" alt="azure compute vm" /></p>
<p>On the Azure Compute VM dashboard, we can see the following sampling of some of the many available metrics:</p>
<ul>
<li>CPU utilization</li>
<li>Available memory</li>
<li>Network sent and received bytes</li>
<li>Disk writes and reads metrics</li>
</ul>
<p>For metrics not covered by out-of-the-box dashboards, custom dashboards can be easily created to visualize metrics that are important to you.</p>
<p><strong>Congratulations, you have now started monitoring metrics from Microsoft Azure services for your application!</strong></p>
<h2 id="analyzeyourdatawithelasticaiassistant">Analyze your data with Elastic AI Assistant</h2>
<p>Once metrics and logs (or either one) are in Elastic, start analyzing your data with <a href="https://www.elastic.co/blog/context-aware-insights-elastic-ai-assistant-observability">context-aware insights using the Elastic AI Assistant for Observability</a>.</p>
<h2 id="conclusionmonitoringmicrosoftazureservicemetricswithelasticobservabilityiseasy">Conclusion: Monitoring Microsoft Azure service metrics with Elastic Observability is easy!</h2>
<p>We hope you’ve gotten an appreciation for how Elastic Observability can help you monitor Azure service metrics. Here’s a quick recap of what you learned:</p>
<ul>
<li>Elastic Observability supports ingest and analysis of Azure service metrics.</li>
<li>It’s easy to set up ingest from Azure services via the Elastic Agent.</li>
<li>Elastic Observability has multiple out-of-the-box Azure service dashboards you can use to preliminarily review information and then modify for your needs.</li>
</ul>
<p>Try it out for yourself by signing up via <a href="https://portal.azure.com/#view/Microsoft_Azure_Marketplace/GalleryItemDetailsBladeNopdl/id/elastic.ec-azure-pp">Microsoft Azure Marketplace</a> and quickly spin up a deployment in minutes on any of the <a href="https://www.elastic.co/guide/en/cloud/current/ec-reference-regions.html#ec_azure_regions">Elastic Cloud regions on Microsoft Azure</a> around the world. Your Azure Marketplace purchase of Elastic will be included in your monthly consolidated billing statement and will draw against your committed spend with Microsoft Azure.</p>
<p><em>The release and timing of any features or functionality described in this post remain at Elastic's sole discretion. Any features or functionality not currently available may not be delivered on time or at all.</em></p>]]></content:encoded>
    <link>https://www.elastic.co/observability-labs/blog/observability-monitors-metrics-microsoft-azure</link>
    <guid isPermaLink="false">observability-monitors-metrics-microsoft-azure</guid>
    <category><![CDATA[Infrastructure Monitoring]]></category>
    <category><![CDATA[Metrics]]></category>
    <dc:creator><![CDATA[Jonathan Simon,Hemant Malik]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt87fce3f72364a189/6a85ca7bf61d6eabbc9c2b01/Azure_Dark_(1).png" length="0" type="image/png"/>
    <pubDate>Mon, 29 Jan 2024 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Elastic Observability monitors metrics for Google Cloud in just minutes]]></title>
    <description><![CDATA[Follow this step-by-step process to enable Elastic Observability for Google Cloud Platform metrics.]]></description>
    <content:encoded><![CDATA[<p>Developers and SREs choose to host their applications on Google Cloud Platform (GCP) for its reliability, speed, and ease of use. On Google Cloud, development teams are finding additional value in migrating to Kubernetes on GKE, leveraging the latest serverless options like Cloud Run, and improving traditional, tiered applications with managed services.</p>
<p>Elastic Observability offers 16 out-of-the-box integrations for Google Cloud services with more on the way. A full list of Google Cloud integrations can be found in <a href="https://docs.elastic.co/en/integrations/gcp">our online documentation</a>.</p>
<p>In addition to our native Google Cloud integrations, Elastic Observability aggregates not only logs but also metrics for Google Cloud services and the applications running on Google Cloud compute services (Compute Engine, Cloud Run, Cloud Functions, Kubernetes Engine). All this data can be analyzed visually and more intuitively using Elastic®’s advanced machine learning (ML) capabilities, which help detect performance issues and surface root causes before end users are affected.</p>
<p>For more details on how Elastic Observability provides application performance monitoring (APM) capabilities such as service maps, tracing, dependencies, and ML based metrics correlations, read: <a href="https://www.elastic.co/blog/apm-correlations-elastic-observability-root-cause-transactions">APM correlations in Elastic Observability: Automatically identifying probable causes of slow or failed transactions</a>.</p>
<p>That’s right, Elastic offers metrics ingest, aggregation, and analysis for Google Cloud services and applications on Google Cloud compute services. Elastic is more than logs — it offers a unified observability solution for Google Cloud environments.</p>
<p>In this blog, I’ll review how Elastic Observability can monitor metrics for a three-tier web application running on Google Cloud services, which include:</p>
<ul>
<li>Google Cloud Run</li>
<li>Google Cloud SQL for PostgreSQL</li>
<li>Google Cloud Memorystore for Redis</li>
<li>Google Cloud VPC Network</li>
</ul>
<p>As you will see, once the integration is installed, metrics will arrive instantly and you can immediately start reviewing metrics.</p>
<h2 id="prerequisitesandconfig">Prerequisites and config</h2>
<p>Here are some of the components and details we used to set up this demonstration:</p>
<ul>
<li>Ensure you have an account on <a href="http://cloud.elastic.co">Elastic Cloud</a> and a deployed stack (<a href="https://www.elastic.co/guide/en/elastic-stack/current/installing-elastic-stack.html">see instructions here</a>).</li>
<li>Ensure you have a Google Cloud project and a Service Account with permissions to pull the necessary data from Google Cloud (<a href="https://docs.elastic.co/en/integrations/gcp#authentication">see details in our documentation</a>).</li>
<li>We used <a href="https://cloud.google.com/architecture/application-development/three-tier-web-app">Google Cloud’s three-tier app</a> and deployed it using the Google Cloud console.</li>
<li>We’ll walk through installing the general <a href="https://docs.elastic.co/en/integrations/gcp">Elastic Google Cloud Platform Integration</a>, which covers the services we want to collect metrics for.</li>
<li>We will <em>not</em> cover application monitoring; instead, we will focus on how Google Cloud services can be easily monitored.</li>
<li>In order to see metrics, you will need to load the application. We’ve also created a playwright script to drive traffic to the application.</li>
</ul>
<h2 id="threetierapplicationoverview">Three-tier application overview</h2>
<p>Before we dive into the Elastic configuration, let's review what we are monitoring. If you follow the <a href="https://cloud.google.com/architecture/application-development/three-tier-web-app">Jump Start Solution: Three-tier web app</a> instructions for<a href="https://github.com/aws-samples/aws-three-tier-web-architecture-workshop"></a>deploying the task-tracking app, you will have the following deployed.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltfdfc1ac184579a1b/6a85c99ff5f1a04ffa2ec8cd/1.png" alt="1" /></p>
<p>What’s deployed:</p>
<ul>
<li>Cloud Run frontend tier that renders an HTML client in the user's browser and enables user requests to be sent to the task-tracking app</li>
<li>Cloud Run middle tier API layer that communicates with the frontend and the database tier</li>
<li>Memorystore for Redis instance in the database tier, caching and serving data that is read frequently</li>
<li>Cloud SQL for PostgreSQL instance in the database tier, handling requests that can't be served from the in-memory Redis cache</li>
</ul>
<p>At the end of the blog, we will also provide a Playwright script that can be run to send requests to this app in order to load it with example data and exercise its functionality. This will help drive metrics to “light up” the dashboards.</p>
<h2 id="settingitallup">Setting it all up</h2>
<p>Let’s walk through the details of how to get the application, Google Cloud integration on Elastic, and what gets ingested.</p>
<h3 id="step0getanaccountonelasticcloud">Step 0: Get an account on Elastic Cloud</h3>
<p>Follow the instructions to <a href="https://cloud.elastic.co/registration?fromURI=/home">get started on Elastic Cloud</a>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt95cfd5da2363e653/6a85c9a227c5cd311b5f73ca/2.png" alt="2 - start free trial" /></p>
<h3 id="step1deploythegooglecloudthreetierapplication">Step 1: Deploy the Google Cloud three-tier application</h3>
<p>Follow the instructions listed out in <a href="https://cloud.google.com/architecture/application-development/three-tier-web-app">Jump Start Solution: Three-tier web app</a> choosing the <strong>Deploy through the console</strong> option for deployment.</p>
<h3 id="step2createagooglecloudserviceaccountanddownloadcredentialsfile">Step 2: Create a Google Cloud Service Account and download credentials file</h3>
<p>Once you’ve installed the app, the next step is to create a <em>Service Account</em> with a <em>Role</em> and a <em>Service Account Key</em> that will be used by Elastic’s integration to access data in your Google Cloud project.</p>
<p>Go to Google Cloud <a href="https://console.cloud.google.com/iam-admin/roles">IAM Roles</a> to create a Role with the necessary permissions. Click the <strong>CREATE ROLE</strong> button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb6968bc5b63bf668/6a85c9a5d6cf29ed61bb08d2/3.png" alt="3" /></p>
<p>Give the Role a <strong>Title</strong> and an <strong>ID</strong>. Then add the 10 assigned permissions listed here.</p>
<ul>
<li>cloudsql.instances.list</li>
<li>compute.instances.list</li>
<li>monitoring.metricDescriptors.list</li>
<li>monitoring.timeSeries.list</li>
<li>pubsub.subscriptions.consume</li>
<li>pubsub.subscriptions.create</li>
<li>pubsub.subscriptions.get</li>
<li>pubsub.topics.attachSubscription</li>
<li>redis.instances.list</li>
<li>run.services.list</li>
</ul>
<p>These permissions are a minimal set of what’s required for this blog post. You should add permissions for all the services for which you would like to collect metrics. If you need to add or remove permissions in the future, the Role’s permissions can be updated as many times as necessary.</p>
<p>Click the <strong>CREATE</strong> button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc83cc805a73a02f0/6a85c9a893ffb91bfbb9140f/4.png" alt="4" /></p>
<p>Go to Google Cloud <a href="https://console.cloud.google.com/iam-admin/serviceaccounts">IAM Service Accounts</a> to create a Service Account that will be used by the Elastic integration for access to Google Cloud. Click the <strong>CREATE SERVICE ACCOUNT</strong> button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt8b281c0557b900a9/6a85c9abd6cf2975bcbb08d6/5.png" alt="5" /></p>
<p>Enter a <strong>Service account name</strong> and a <strong>Service account ID.</strong> Click the <strong>CREATE AND CONTINUE</strong> button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt334653fa031b1d0f/6a85c9ad8c29444f1cb89029/6.png" alt="6" /></p>
<p>Then select the <strong>Role</strong> that you created previously and click the <strong>CONTINUE</strong> button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt45e5869885446f4c/6a85c9b02d64d537e2081d0c/7.png" alt="7" /></p>
<p>Click the <strong>DONE</strong> button to complete the Service Account creation process.</p>
<p>Next select the Service Account you just created to see its details page. Under the <strong>KEYS</strong> tab, click the <strong>ADD KEY</strong> dropdown and select <strong>Create new key</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7520bd47c8578699/6a85c9b393ffb92bd3b91413/8.png" alt="8" /></p>
<p>In the Create private key dialog window, with the <strong>Key type</strong> set as JSON, click the <strong>CREATE</strong> button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte01e021c5d511dd8/6a85c9b59a32f188bca7dfba/9.png" alt="9" /></p>
<p>The JSON credentials file key will be automatically downloaded to your local computer’s <strong>Downloads</strong> folder. The credentials file will be named something like:</p>
<pre><code>your-project-id-12a1234b1234.json
</code></pre>
<p>You can rename the file to be something else. For the purpose of this blog, we’ll rename it to:</p>
<pre><code>credentials.json
</code></pre>
<h3 id="step3createagooglecloudvminstance">Step 3: Create a Google Cloud VM instance</h3>
<p>To create the Compute Engine VM instance in Google Cloud, go to <a href="https://console.cloud.google.com/compute/instances">Compute Engine</a>. Then select <strong>CREATE INSTANCE.</strong></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9cd96f99791f8b61/6a85c9b8eaf2452324a49f3b/10.png" alt="10" /></p>
<p>Enter the following values for the VM instance details:</p>
<ul>
<li>Enter a <strong>Name</strong> of your choice for the VM instance.</li>
<li>Expand the <strong>Advanced Options</strong> section and the <strong>Networking</strong> sub-section.</li>
<li>Enter allow-ssh as the Networking tag.</li>
<li>Select the <strong>Network Interface</strong> to use the <strong>tiered-web-app-private-network</strong> , which is the network on which the Google Cloud three-tier web app is deployed.</li>
</ul>
<p>Click the <strong>CREATE</strong> button to create the VM instance.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt45a74a3aa5beeea1/6a85c9bb5c2790459cf59afb/11.png" alt="11" /></p>
<h3 id="step4sshintothegooglecloudvminstanceanduploadthecredentialsfile">Step 4: SSH in to the Google Cloud VM instance and upload the credentials file</h3>
<p>In order to SSH into the Google Cloud VM instance you just created in the previous step, you’ll need to create a Firewall rule in <strong>tiered-web-app-private-network</strong> , which is the network where the VM instance resides.</p>
<p>Go to the Google Cloud <a href="https://console.cloud.google.com/net-security/firewall-manager/firewall-policies/list"><strong>Firewall policies</strong></a> page. Click the <strong>CREATE FIREWALL RULE</strong> button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt599fa2da6ded5f6e/6a85c9be078290cb06321748/12.png" alt="12" /></p>
<p>Enter the following values for the Firewall Rule.</p>
<ul>
<li>Enter a firewall rule <strong>Name</strong>.</li>
<li>Select <strong>tiered-web-app-private-network</strong> for the <strong>Network</strong>.</li>
<li>Enter allow-ssh for <strong>Target Tags</strong>.</li>
<li>Enter 0.0.0.0/0 for the <strong>Source IPv4 ranges</strong>.Click <strong>TCP</strong> and set the <strong>Ports</strong> to <strong>22</strong>.</li>
</ul>
<p>Click <strong>CREATE</strong> to create the firewall rule.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltdb1991c77845dec7/6a85c9c12d64d5d73c081d12/13.png" alt="13" /></p>
<p>After the new Firewall rule is created, you can now SSH into your VM instance. Go to the <a href="https://console.cloud.google.com/compute/instances">Google Cloud VM instances</a> and select the VM instance you created in the previous step to see its details page. Click the <strong>SSH</strong> button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9d2871bb6db22507/6a85c9c39a32f11ecba7dfbe/14.png" alt="14" /></p>
<p>Once you are SSH’d inside the VM instance terminal window, click the <strong>UPLOAD FILE</strong> button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb3c81be45dd3f9ba/6a85c9c6f9373db18696f572/15.png" alt="15" /></p>
<p>Select the credentials.json file located on your local computer and click the <strong>Upload Files</strong> button to upload the file.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt79c12de30cb5718a/6a85c9c95c27903ef5f59b01/16.png" alt="16" /></p>
<p>In the VM instance’s SSH terminal, run the following command to get the full path to your Google Cloud Service Account credentials file.</p>
<pre><code>realpath credentials.json
</code></pre>
<p>This should return the full path to your Google Cloud Service Account credentials file.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blta577fd983ea101ae/6a85c9cc331d7a4888c31773/17.png" alt="17" /></p>
<p>Copy the credentials file’s full path and save it in a handy location to be used in a later step.</p>
<h3 id="step5addtheelasticgooglecloudintegration">Step 5: Add the Elastic Google Cloud integration</h3>
<p>Navigate to the Google Cloud Platform integration in Elastic by selecting <strong>Integrations</strong> from the top-level menu. Search for google and click the <strong>Google Cloud Platform</strong> tile.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt523984e613b2fd5a/6a85c9cf18249c75d018f7a5/18.png" alt="18" /></p>
<p>Click <strong>Add Google Cloud Platform</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt38e92105e192750a/6a85c9d2f9373d568896f57a/19.png" alt="19" /></p>
<p>Click <strong>Add integration only (skip agent installation)</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltde5bcf660bcff089/6a85c9d580984c7e2f668fb6/20.png" alt="20" /></p>
<p>Update the <strong>Project Id</strong> input text box to be your Google Cloud Project ID. Next, paste in the credentials file’s full path into the <strong>Credentials File</strong> input text box.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt71794a67ac930227/6a85c9d911893cad59a7ab72/21.png" alt="21" /></p>
<p>As you can see, the general Elastic Google Cloud Platform Integration will collect a significant amount of data from 16 Google Cloud services. If you don’t want to install this general Elastic Google Cloud Platform Integration, you can select individual integrations to install. Click <strong>Save and continue</strong>.</p>
<p>You’ll be presented with a confirmation dialog window. Click <strong>Add Elastic Agent to your hosts</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt80bdaa482f6dec89/6a85c9dc4710c67a09d3cb2b/22.png" alt="22" /></p>
<p>This will display the instructions required to install the Elastic agent. Copy the command under the <strong>Linux Tar</strong> tab.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt12d8a54bba642985/6a85c9df9bf99423670a055d/23.png" alt="23" /></p>
<p>Next you will need to use SSH to log in to the Google Cloud VM instance and run the commands copied from <strong>Linux Tar</strong> tab. Go to <a href="https://console.cloud.google.com/compute/instances">Compute Engine</a>. Then click the name of the VM instance that you created in Step 2. Log in to the VM by clicking the <strong>SSH</strong> button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9d2871bb6db22507/6a85c9c39a32f11ecba7dfbe/14.png" alt="24 - instance" /></p>
<p>Once you are SSH’d inside the VM instance terminal window, run the commands copied previously from <strong>Linux Tar tab</strong> in the <strong>Install Elastic Agent on your host</strong> instructions.</p>
<p>When the installation completes, you’ll see a confirmation message in the Install Elastic Agent on your host form. Click the <strong>Add the integration</strong> button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt901cf4f0fb9eb9ae/6a85c9e293ffb94a3cb91425/25.png" alt="25 - add agent" /></p>
<p>Excellent! The Elastic agent is sending data to Elastic Cloud. Now let’s observe some metrics.</p>
<h3 id="step6runtrafficagainsttheapplication">Step 6: Run traffic against the application</h3>
<p>While getting the application running is fairly easy, there is nothing to monitor or observe with Elastic unless you add a load on the application.</p>
<p>Here is a simple script you can also run using <a href="https://playwright.dev/">Playwright</a> to add traffic and exercise the functionality of the Google Cloud three-tier application:</p>
<pre><code>import { test, expect } from "@playwright/test";

test("homepage for Google Cloud Threetierapp", async ({ page }) =&gt; {
  await page.goto("https://tiered-web-app-fe-zg62dali3a-uc.a.run.app");
  // Insert 2 todo items
  await page.fill("id=todo-new", (Math.random() * 100).toString());
  await page.keyboard.press("Enter");
  await page.waitForTimeout(1000);
  await page.fill("id=todo-new", (Math.random() * 100).toString());
  await page.keyboard.press("Enter");
  await page.waitForTimeout(1000);
  // Click one todo item
  await page.getByRole("checkbox").nth(0).check();
  await page.waitForTimeout(1000);
  // Delete one todo item
  const deleteButton = page.getByText("delete").nth(0);
  await deleteButton.dispatchEvent("click");
  await page.waitForTimeout(4000);
});
</code></pre>
<h3 id="step7gotogoogleclouddashboardsinelastic">Step 7: Go to Google Cloud dashboards in Elastic</h3>
<p>With Elastic Agent running, you can go to Elastic Dashboards to view what’s being ingested. Simply search for “dashboard” in Elastic and choose <strong>Dashboards.</strong></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt99f34efcec28fb3d/6a85c9e5eaf2450b34a49f41/26.png" alt="26 - dashboard" /></p>
<p>This will open the Elastic Dashboards page.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt263a7b1684f098bb/6a85c9e78c294450d1b89035/27.png" alt="27" /></p>
<p>In the Dashboards search box, search for GCP and click the <strong>[Metrics GCP] CloudSQL PostgreSQL Overview</strong> dashboard, one of the many out-of-the-box dashboards available. Let’s see what comes up.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt221cab7a03a1a453/6a85c9ea11893c22f3a7ab76/28.png" alt="28" /></p>
<p>On the Cloud SQL dashboard, we can see the following sampling of some of the many available metrics:</p>
<ul>
<li>Disk write ops</li>
<li>CPU utilization</li>
<li>Network sent and received bytes</li>
<li>Transaction count</li>
<li>Disk bytes used</li>
<li>Disk quota</li>
<li>Memory usage</li>
<li>Disk read ops</li>
</ul>
<p>Next let’s take a look at metrics for Cloud Run.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc43564072438bcca/6a85c9edeaf2459bfea49f45/29.png" alt="29 - line graphs" /></p>
<p>We’ve created a custom dashboard using the <strong>Create dashboard</strong> button on the Elastic Dashboards page. Here we see a few of the numerous available metrics:</p>
<ul>
<li>Container instance count</li>
<li>CPU utilization for the three-tier app frontend and API</li>
<li>Request count for the three-tier app frontend and API</li>
<li>Bytes in and out of the API</li>
</ul>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt117da1e00a38d27b/6a85c9f0e2447a805b8b13e6/30.png" alt="30" /></p>
<p>This is a custom dashboard created for MemoryStore where we can see the following sampling of the available metrics:</p>
<ul>
<li>Network traffic to the Memorystore Redis instance</li>
<li>Count of the keys stored in Memorystore Redis</li>
<li>CPU utilization of the Memorystore Redis instance</li>
<li>Memory usage of the Memorystore Redis instance</li>
</ul>
<p><strong>Congratulations, you have now started monitoring metrics from key Google Cloud services for your application!</strong></p>
<h2 id="whattomonitorongooglecloudnext">What to monitor on Google Cloud next?</h2>
<h3 id="addlogsfromgooglecloudservices">Add logs from Google Cloud Services</h3>
<p>Now that metrics are being monitored, you can also now add logging. There are several options for ingesting logs.</p>
<p>The Google Cloud Platform Integration in the Elastic Agent has four separate logs settings: audit logs, firewall logs, VPC Flow logs, and DNS logs. Just ensure you turn on what you wish to receive.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltebe1cdd2c89adb40/6a85c9f39a32f12a9ba7dfc4/31.png" alt="31" /></p>
<h3 id="analyzeyourdatawithelasticmachinelearning">Analyze your data with Elastic machine learning</h3>
<p>Once metrics and logs (or either one) are in Elastic, start analyzing your data through Elastic’s ML capabilities. A great review of these features can be found here:</p>
<ul>
<li><a href="https://www.elastic.co/blog/apm-correlations-elastic-observability-root-cause-transactions">Correlating APM Telemetry to determine root causes in transactions</a></li>
<li><a href="https://www.elastic.co/elasticon/archive/2020/global/machine-learning-and-the-elastic-stack-everywhere-you-need-it">Introduction to Elastic Machine Learning</a></li>
</ul>
<h2 id="conclusionmonitoringgooglecloudservicemetricswithelasticobservabilityiseasy">Conclusion: Monitoring Google Cloud service metrics with Elastic Observability is easy!</h2>
<p>I hope you’ve gotten an appreciation for how Elastic Observability can help you monitor Google Cloud service metrics. Here’s a quick recap of lessons and what you learned:</p>
<ul>
<li>Elastic Observability supports ingest and analysis of Google Cloud service metrics.</li>
<li>It’s easy to set up ingest from Google Cloud services via the Elastic Agent.</li>
<li>Elastic Observability has multiple out-of-the-box Google Cloud service dashboards you can use to preliminarily review information and then modify for your needs.</li>
<li>For metrics not covered by out-of-the-box dashboards, custom dashboards can be easily created to visualize metrics that are important to you.</li>
<li>16 Google Cloud services are supported as part of Google Cloud Platform Integration on Elastic Observability, with more services being added regularly.</li>
<li>As noted in related blogs, you can analyze your Google Cloud service metrics with Elastic’s machine learning capabilities.</li>
</ul>
<p>Try it out for yourself by signing up via <a href="https://console.cloud.google.com/marketplace/product/elastic-prod/elastic-cloud">Google Cloud Marketplace</a> and quickly spin up a deployment in minutes on any of the <a href="https://www.elastic.co/guide/en/cloud/current/ec-reference-regions.html#ec_google_cloud_platform_gcp_regions">Elastic Cloud regions on Google Cloud</a> around the world. Your Google Cloud Marketplace purchase of Elastic will be included in your monthly consolidated billing statement and will draw against your committed spend with Google Cloud.</p>
<p><em>The release and timing of any features or functionality described in this post remain at Elastic's sole discretion. Any features or functionality not currently available may not be delivered on time or at all.</em></p>]]></content:encoded>
    <link>https://www.elastic.co/observability-labs/blog/observability-monitors-metrics-google-cloud</link>
    <guid isPermaLink="false">observability-monitors-metrics-google-cloud</guid>
    <category><![CDATA[Infrastructure Monitoring]]></category>
    <category><![CDATA[Metrics]]></category>
    <dc:creator><![CDATA[Jonathan Simon,Eric Lowry]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4366673716734c18/6a85c9f6501a85860dfbb30a/serverless-launch-blog-image.jpg" length="0" type="image/jpeg"/>
    <pubDate>Mon, 20 Nov 2023 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[How to deploy a Hello World web app with Elastic Observability on Azure Container Apps]]></title>
    <description><![CDATA[Follow the step-by-step process of instrumenting Elastic Observability for a Hello World web app running on Azure Container Apps.]]></description>
    <content:encoded><![CDATA[<p>Elastic Observability is the optimal tool to provide visibility into your running web apps. Microsoft Azure Container Apps is a fully managed environment that enables you to run containerized applications on a serverless platform so that your applications scale up and down. This allows you to accomplish the dual objective of serving every customer’s need for availability while meeting your needs to do so as efficiently as possible.</p>
<p>Using Elastic Observability and Azure Container Apps is a perfect combination for developers to deploy <a href="https://www.elastic.co/blog/observability-powerful-flexible-efficient">web apps that are auto-scaled with fully observable operations</a>.</p>
<p>This blog post will show you how to deploy a simple Hello World web app to Azure Container Apps and then walk you through the steps to instrument the Hello World web app to enable observation of the application’s operations with Elastic Cloud.</p>
<h2 id="elasticobservabilitysetup">Elastic Observability setup</h2>
<p>We’ll start with setting up an Elastic Cloud deployment, which is where observability will take place for the web app we’ll be deploying.</p>
<p>From the <a href="https://cloud.elastic.co">Elastic Cloud console</a>, select <strong>Create deployment</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt04a8dfdb151a3d22/6a85cb6933f244f73949f516/elastic-blog-1-create-deployment.png" alt="create deployment" /></p>
<p>Enter a deployment name and click <strong>Create deployment</strong>. It takes a few minutes for your deployment to be created. While waiting, you are prompted to save the admin credentials for your deployment, which provides you with superuser access to your Elastic® deployment. Keep these credentials safe as they are shown only once.</p>
<p>Elastic Observability requires an APM Server URL and an APM Secret token for an app to send observability data to Elastic Cloud. Once the deployment is created, we’ll copy the Elastic Observability server URL and secret token and store them somewhere safely for adding to our web app code in a later step.</p>
<p>To copy the APM Server URL and the APM Secret Token, go to <a href="https://cloud.elastic.co/home">Elastic Cloud</a> . Then go to the <a href="https://cloud.elastic.co/deployments">Deployments</a> page, which lists all of the deployments you have created. Select the deployment you want to use, which will open the deployment details page. In the <strong>Kibana</strong> row of links, click on <strong>Open</strong> to open Kibana® for your deployment.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt47482afb48a1d23e/6a85cb6c682666f0011eac15/elastic-blog-2-my-deployment.png" alt="my deployment" /></p>
<p>Select <strong>Integrations</strong> from the top-level menu. Then click the <strong>APM</strong> tile.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt45a4aa16f5df8769/6a85cb6fd7b2e73943fe84de/elastic-blog-3-apm.png" alt="apm" /></p>
<p>On the APM Agents page, copy the secretToken and the serverUrl values and save them for use in a later step.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte655ab8445d7c133/6a85cb72f9373d073096f5a8/elastic-blog-4-apm-agents.png" alt="apm agents" /></p>
<p>Now that we’ve completed the Elastic Cloud setup, the next step is to set up our account in Azure for deploying apps to the Container Apps service.</p>
<h2 id="azurecontainerappssetup">Azure Container Apps setup</h2>
<p>First we’ll need an Azure account, so let’s create one by going to the <a href="https://azure.microsoft.com">Microsoft Azure portal</a> and creating a new project. Click the <strong>Start free</strong> button and follow the steps to sign in or create a new account.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt91f340f08b739bd9/6a85cb75f61d6e74669c2b2f/elastic-blog-5-azure-start-free.png" alt="azure start free" /></p>
<h2 id="deployahelloworldwebapptocontainerapps">Deploy a Hello World web app to Container Apps</h2>
<p>We’ll perform the process of deploying a C# Hello World web app to Container Apps using the handy Azure tool called <a href="https://azure.microsoft.com/en-us/get-started/azure-portal/cloud-shell">Cloud Shell</a>. To deploy the Hello World app, we’ll perform the following 12 steps:</p>
<ol>
<li>From the <a href="https://portal.azure.com/">Azure portal</a>, click the Cloud Shell icon at the top of the portal to open Cloud Shell…</li>
</ol>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc019a1fdbed88bc1/6a85cb789d2b71346af93990/elastic-blog-6-cloud-shell.png" alt="cloud shell" /></p>
<p>… and when the Cloud Shell first opens, select <strong>Bash</strong> as the shell type to use.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9dabc7b5e45e53d2/6a85cb7b80984c73bd668fe8/elastic-blog-7-bash.png" alt="bash" /></p>
<ol>
<li>If you’re prompted that “You have no storage mounted,” then click the <strong>Create storage</strong> button to create a file store to be used for saving and editing files from Cloud Shell.</li>
</ol>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt81412588a4041647/6a85cb7e07829085b4321778/elastic-blog-8-create-storage.png" alt="create storage" /></p>
<ol>
<li>In Cloud Shell, clone a <a href="https://github.com/elastic/observability-examples/tree/main/azure/container-apps/helloworld">C# Hello World sample app</a> repo from GitHub by entering the following command.</li>
</ol>
<pre><code>git clone https://github.com/elastic/observability-examples
</code></pre>
<ol>
<li>Change directory to the location of the Hello World web app code.</li>
</ol>
<pre><code>cd observability-examples/azure/container-apps/helloworld
</code></pre>
<ol>
<li>Define the environment variables that we’ll be using in the commands throughout this blog post.</li>
</ol>
<pre><code>RESOURCE_GROUP="helloworld-containerapps"
LOCATION="centralus"
ENVIRONMENT="env-helloworld-containerapps"
APP_NAME="elastic-helloworld"
</code></pre>
<ol>
<li>Define a registry container name that is unique by running the following command.</li>
</ol>
<pre><code>ACR_NAME="helloworld"$RANDOM
</code></pre>
<ol>
<li>Create an Azure resource group by running the following command.</li>
</ol>
<pre><code>az group create --name $RESOURCE_GROUP --location "$LOCATION"
</code></pre>
<ol>
<li>Run the following command to create a registry container in Azure Container Registry.</li>
</ol>
<pre><code>az acr create --resource-group $RESOURCE_GROUP \
--name $ACR_NAME --sku Basic --admin-enable true
</code></pre>
<ol>
<li>Build the app image and push it to Azure Container Registry by running the following command.</li>
</ol>
<pre><code>az acr build --registry $ACR_NAME --image $APP_NAME .
</code></pre>
<ol>
<li>Register the Microsoft.OperationalInsights namespace as a provider by running the following command.</li>
</ol>
<pre><code>az provider register -n Microsoft.OperationalInsights --wait
</code></pre>
<ol>
<li>Run the following command to create a Container App environment for deploying your app into.</li>
</ol>
<pre><code>az containerapp env create --name $ENVIRONMENT \
--resource-group $RESOURCE_GROUP --location "$LOCATION"
</code></pre>
<ol>
<li>Create a new Container App by deploying the Hello World app’s image to Container Apps, using the following command.</li>
</ol>
<pre><code>az containerapp create \
  --name $APP_NAME \
  --resource-group $RESOURCE_GROUP \
  --environment $ENVIRONMENT \
  --image $ACR_NAME.azurecr.io/$APP_NAME \
  --target-port 3500 \
  --ingress 'external' \
  --registry-server $ACR_NAME.azurecr.io \
  --query properties.configuration.ingress.fqdn
</code></pre>
<p>This command will output the deployed Hello World app's fully qualified domain name (FQDN). Copy and paste the FQDN into a browser to see your running Hello World app.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt3b75b6f92e5b965a/6a85cb812d64d55903081d4e/elastic-blog-9-hello-world.png" alt="hello world" /></p>
<h2 id="instrumentthehelloworldwebappwithelasticobservability">Instrument the Hello World web app with Elastic Observability</h2>
<p>With a web app successfully running in Container Apps, we’re now ready to add the minimal code necessary to enable observability for the Hello World app in Elastic Cloud. We’ll perform the following eight steps:</p>
<ol>
<li>In Azure Cloud Shell, create a new file named Telemetry.cs by typing the following command.</li>
</ol>
<pre><code>touch Telemetry.cs
</code></pre>
<ol>
<li>Open the Azure Cloud Shell file editor by typing the following command in Cloud Shell.</li>
</ol>
<pre><code>code .
</code></pre>
<ol>
<li>In the Azure Cloud Shell editor, open the Telemetry.cs file and paste in the following code. Save the edited file in Cloud Shell by pressing the [Ctrl] + [s] keys on your keyboard (or if you’re on a macOS computer, use the [⌘] + [s] keys). This class file is used to create a tracer ActivitySource, which can generate trace Activity spans for observability.</li>
</ol>
<pre><code>using System.Diagnostics;

public static class Telemetry
{
    public static readonly ActivitySource activitySource = new("Helloworld");
}
</code></pre>
<ol>
<li>In the Azure Cloud Shell editor, edit the file named Dockerfile to add the following Elastic OpenTelemetry environment variables. Replace the ELASTIC_APM_SERVER_URL text and the ELASTIC_APM_SECRET_TOKEN text with the APM Server URL and the APM Secret Token values that you copied and saved in an earlier step.</li>
</ol>
<p>Save the edited file in Cloud Shell by pressing the [Ctrl] + [s] keys on your keyboard (or if you’re on a macOS computer, use the [⌘] + [s] keys).</p>
<p>The updated Dockerfile should look something like this:</p>
<pre><code>FROM ${ARCH}mcr.microsoft.com/dotnet/aspnet:7.0. AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:8.0-preview AS build
ARG TARGETPLATFORM

WORKDIR /src
COPY ["helloworld.csproj", "./"]
RUN dotnet restore "./helloworld.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "helloworld.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "helloworld.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
EXPOSE 3500
ENV ASPNETCORE_URLS=http://+:3500

ENV OTEL_EXPORTER_OTLP_ENDPOINT='https://******.apm.us-east-2.aws.elastic-cloud.com:443'
ENV OTEL_EXPORTER_OTLP_HEADERS='Authorization=Bearer ***********'
ENV OTEL_LOG_LEVEL=info
ENV OTEL_METRICS_EXPORTER=otlp
ENV OTEL_RESOURCE_ATTRIBUTES=service.version=1.0,deployment.environment=production
ENV OTEL_SERVICE_NAME=helloworld
ENV OTEL_TRACES_EXPORTER=otlp

ENTRYPOINT ["dotnet", "helloworld.dll"]
</code></pre>
<ol>
<li>In the Azure Cloud Shell editor, edit the helloworld.csproj file to add the Elastic APM and OpenTelemetry dependencies. The updated helloworld.csproj file should look something like this:</li>
</ol>
<pre><code>&lt;Project Sdk="Microsoft.NET.Sdk.Web"&gt;

  &lt;PropertyGroup&gt;
    &lt;TargetFramework&gt;net7.0&lt;/TargetFramework&gt;
    &lt;Nullable&gt;enable&lt;/Nullable&gt;
    &lt;ImplicitUsings&gt;enable&lt;/ImplicitUsings&gt;
  &lt;/PropertyGroup&gt;
  &lt;ItemGroup&gt;
    &lt;PackageReference Include="Elastic.Apm" Version="1.24.0" /&gt;
    &lt;PackageReference Include="Elastic.Apm.NetCoreAll" Version="1.24.0" /&gt;
    &lt;PackageReference Include="OpenTelemetry" Version="1.6.0" /&gt;
    &lt;PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.6.0" /&gt;
    &lt;PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.6.0" /&gt;
    &lt;PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.6.0" /&gt;
    &lt;PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.5.0-beta.1" /&gt;
  &lt;/ItemGroup&gt;

&lt;/Project&gt;
</code></pre>
<ol>
<li>In the Azure Cloud Shell editor, edit the Program.cs:</li>
</ol>
<ul>
<li>Add a using statement at the top of the file to import System.Diagnostics, which is used to create Activities that are equivalent to “spans” in OpenTelemetry. Also import the OpenTelemetry.Resources and OpenTelemetry.Trace packages.</li>
</ul>
<pre><code>using System.Diagnostics;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
</code></pre>
<ul>
<li>Update the “builder” initialization code block to include configuration to enable Elastic OpenTelemetry observability.</li>
</ul>
<pre><code>builder.Services.AddOpenTelemetry().WithTracing(builder =&gt; builder.AddOtlpExporter()
                    .AddSource("helloworld")
                    .AddAspNetCoreInstrumentation()
                    .AddOtlpExporter()
        .ConfigureResource(resource =&gt;
            resource.AddService(
                serviceName: "helloworld"))
);
builder.Services.AddControllers();
</code></pre>
<ul>
<li>Replace the “Hello World!” HTML output string…</li>
</ul>
<pre><code>&lt;h1&gt;Hello World!&lt;/h1&gt;
</code></pre>
<ul>
<li>…with the “Hello Elastic Observability” HTML output string.</li>
</ul>
<pre><code>&lt;div style="text-align: center;"&gt;
  &lt;h1 style="color: #005A9E; font-family:'Verdana'"&gt;
    Hello Elastic Observability - Azure Container Apps - C#
  &lt;/h1&gt;
  &lt;img
    src="https://elastichelloworld.blob.core.windows.net/elastic-helloworld/elastic-logo.png"
  /&gt;
&lt;/div&gt;
</code></pre>
<ul>
<li>Add a telemetry trace span around the output response utilizing the Telemetry class’ ActivitySource.</li>
</ul>
<pre><code>using (Activity activity = Telemetry.activitySource.StartActivity("HelloSpan")!)
       {
           Console.Write("hello");
           await context.Response.WriteAsync(output);
       }
</code></pre>
<p>The updated Program.cs file should look something like this:</p>
<pre><code>using System.Diagnostics;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenTelemetry().WithTracing(builder =&gt; builder.AddOtlpExporter()
                    .AddSource("helloworld")
                    .AddAspNetCoreInstrumentation()
                    .AddOtlpExporter()
        .ConfigureResource(resource =&gt;
            resource.AddService(
                serviceName: "helloworld"))
);
builder.Services.AddControllers();
var app = builder.Build();

string output =
"""
&lt;div style="text-align: center;"&gt;
&lt;h1 style="color: #005A9E; font-family:'Verdana'"&gt;
Hello Elastic Observability - Azure Container Apps - C#
&lt;/h1&gt;
&lt;img src="https://elastichelloworld.blob.core.windows.net/elastic-helloworld/elastic-logo.png"&gt;
&lt;/div&gt;
""";

app.MapGet("/", async context =&gt;
    {
        using (Activity activity = Telemetry.activitySource.StartActivity("HelloSpan")!)
            {
                Console.Write("hello");
                await context.Response.WriteAsync(output);
            }
    }
);
app.Run();
</code></pre>
<ol>
<li>Rebuild the Hello World app image and push the image to the Azure Container Registry by running the following command.</li>
</ol>
<pre><code>az acr build --registry $ACR_NAME --image $APP_NAME .
</code></pre>
<ol>
<li>Redeploy the updated Hello World app to Azure Container Apps, using the following command.</li>
</ol>
<pre><code>az containerapp create \
  --name $APP_NAME \
  --resource-group $RESOURCE_GROUP \
  --environment $ENVIRONMENT \
  --image $ACR_NAME.azurecr.io/$APP_NAME \
  --target-port 3500 \
  --ingress 'external' \
  --registry-server $ACR_NAME.azurecr.io \
  --query properties.configuration.ingress.fqdn
</code></pre>
<p>This command will output the deployed Hello World app's fully qualified domain name (FQDN). Copy and paste the FQDN into a browser to see the updated Hello World app running in Azure Container Apps.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltf5e133b7b70c41d2/6a85cb8411893c6d5da7ab9a/elastic-blog-10-elastic-hello-observability.png" alt="hello observability" /></p>
<h2 id="observethehelloworldwebapp">Observe the Hello World web app</h2>
<p>Now that we’ve instrumented the web app to send observability data to Elastic Observability, we can now use Elastic Cloud to monitor the web app’s operations.</p>
<ol>
<li><p>In Elastic Cloud, select the Observability <strong>Services</strong> menu item.</p></li>
<li><p>Click the <strong>helloworld</strong> service.</p></li>
<li><p>Click the <strong>Transactions</strong> tab.</p></li>
<li><p>Scroll down and click the <strong>GET /</strong> transaction.Scroll down to the <strong>Trace Sample</strong> section to see the <strong>GET /</strong> , <strong>HelloSpan</strong> trace sample.</p></li>
</ol>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd6b7f8c8650ec965/6a85cb8733f2446c8f49f51a/elastic-blog-12-latency-distribution.png" alt="latency-distribution" /></p>
<h2 id="observabilitymadetoscale">Observability made to scale</h2>
<p>You’ve seen the entire process of deploying a web app to Azure Container Apps that is instrumented with Elastic Observability. This web app is now fully available on the web running on a platform that will auto-scale to serve visitors worldwide. And it’s instrumented for Elastic Observability APM using OpenTelemetry to ingest data into Elastic Cloud’s Kibana dashboards.</p>
<p>Now that you’ve seen how to deploy a Hello World web app with a basic observability setup, visit <a href="https://www.elastic.co/observability">Elastic Observability</a> to learn more about expanding to a full scale observability coverage solution for your apps. Or visit <a href="https://www.elastic.co/getting-started/microsoft-azure">Getting started with Elastic on Microsoft Azure</a> for more examples of how you can drive the data insights you need by combining Microsoft Azure’s cloud computing services with Elastic’s search-powered platform.</p>
<p><em>The release and timing of any features or functionality described in this post remain at Elastic's sole discretion. Any features or functionality not currently available may not be delivered on time or at all.</em></p>]]></content:encoded>
    <link>https://www.elastic.co/observability-labs/blog/deploy-app-observability-azure-container-apps</link>
    <guid isPermaLink="false">deploy-app-observability-azure-container-apps</guid>
    <category><![CDATA[Infrastructure Monitoring]]></category>
    <category><![CDATA[APM]]></category>
    <dc:creator><![CDATA[Jonathan Simon]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt5b73df829b9751f9/6a85cb8943c0b70ca92f061e/library-branding-elastic-observability-midnight-1680x980.png" length="0" type="image/png"/>
    <pubDate>Mon, 23 Oct 2023 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[How to deploy a Hello World web app with Elastic Observability on AWS App Runner]]></title>
    <description><![CDATA[Follow the step-by-step process of instrumenting Elastic Observability for a Hello World web app running on AWS App Runner.]]></description>
    <content:encoded><![CDATA[<p>Elastic Observability is the premiere tool to provide visibility into web apps running in your environment. AWS App Runner is the serverless platform of choice to run your web apps that need to scale up and down massively to meet demand or minimize costs. Elastic Observability combined with AWS App Runner is the perfect solution for developers to deploy <a href="https://www.elastic.co/blog/observability-powerful-flexible-efficient">web apps that are auto-scaled with fully observable operations</a>, in a way that’s straightforward to implement and manage.</p>
<p>This blog post will show you how to deploy a simple Hello World web app to App Runner and then walk you through the steps to instrument the Hello World web app to enable observation of the application’s operations with Elastic Cloud.</p>
<h2 id="elasticobservabilitysetup">Elastic Observability setup</h2>
<p>We’ll start with setting up an Elastic Cloud deployment, which is where observability will take place for the web app we’ll be deploying.</p>
<p>From the <a href="https://cloud.elastic.co">Elastic Cloud console</a>, select <strong>Create deployment</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9db93cd5f13c539e/6a85c87ef5f1a063972ec87f/elastic-blog-1-create-deployment.png" alt="1 create deployment" /></p>
<p>Enter a deployment name and click <strong>Create deployment</strong>. It takes a few minutes for your deployment to be created. While waiting, you are prompted to save the admin credentials for your deployment, which provides you with superuser access to your Elastic® deployment. Keep these credentials safe as they are shown only once.</p>
<p>Elastic Observability requires an APM Server URL and an APM Secret token for an app to send observability data to Elastic Cloud. Once the deployment is created, we’ll copy the Elastic Observability server URL and secret token and store them somewhere safely for adding to our web app code in a later step.</p>
<p>To copy the APM Server URL and the APM Secret Token, go to <a href="https://cloud.elastic.co/home">Elastic Cloud</a>. Then go to the<a href="https://cloud.elastic.co/deployments">Deployments</a> page, which lists all of the deployments you have created. Select the deployment you want to use, which will open the deployment details page. In the Kibana® row of links, click on <strong>Open</strong> to open <strong>Kibana</strong> for your deployment.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt73be96fc7746dfb5/6a85c8819a32f12924a7dfa8/elastic-blog-2-my-deployment.png" alt="2 my deployment" /></p>
<p>Select <strong>Integrations</strong> from the top-level menu. Then click the <strong>APM</strong> tile.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blta57518a50288d231/6a85c884eaf245ca11a49ef9/elastic-blog-3-apm.png" alt="3 apm" /></p>
<p>On the APM Agents page, copy the secretToken and the serverUrl values and save them for use in a later step.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt08e1f088d414b842/6a85c88793ffb91321b913db/elastic-blog-4-apm-agents.png" alt="4 apm agents" /></p>
<p>Now that we’ve completed the Elastic Cloud setup, the next step is to set up our AWS project for deploying apps to App Runner.</p>
<h2 id="awsapprunnersetup">AWS App Runner setup</h2>
<p>To start using AWS App Runner, you need an AWS account. If you’re a brand new user, go to <a href="https://aws.amazon.com">aws.amazon.com</a> to sign up for a new account.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9bbaa139488840d0/6a85c88af9373d536e96f524/elastic-blog-5-start-building.png" alt="5 start building on aws today" /></p>
<h2 id="setupawscloudshell">Set up AWS CloudShell</h2>
<p>We’ll perform the process of creating a Python Hello World App image and pushing it to the AWS ECR using AWS CloudShell.</p>
<p>We’re going to use Docker to build the sample app image. Perform the following five steps to set up Docker within CloudShell.</p>
<ol>
<li>Open <a href="https://console.aws.amazon.com/cloudshell/">AWS CloudShell</a>.</li>
</ol>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltfa807c1f935903af/6a85c88df9373da04796f528/elastic-blog-6-welcome-to-aws-cloudshell.png" alt="6 welcome to aws cloudshell" /></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltf91706b828b599db/6a85c88f93ffb9e8abb913df/elastic-blog-7-aws-cloudshell.png" alt="7 aws cloudshell" /></p>
<ol>
<li>Run the following two commands to install Docker in CloudShell:</li>
</ol>
<pre><code>sudo yum update -y
sudo amazon-linux-extras install docker
</code></pre>
<ol>
<li>Start Docker by running the command:</li>
</ol>
<pre><code>sudo dockerd
</code></pre>
<ol>
<li>With Docker running, open a new tab in CloudShell by clicking the <strong>Actions</strong> dropdown menu and selecting <strong>New tab</strong>.</li>
</ol>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blta0babd2101bc0dab/6a85c89311893cce4da7ab26/elastic-blog-8-aws-cloudshell-with-code.png" alt="8 aws cloudshell with code" /></p>
<ol>
<li>Run the following command to authenticate Docker within CloudShell. Replace \&lt;account_id&gt; with your AWS Account ID in the Docker command below, and then run it in CloudShell.</li>
</ol>
<pre><code>aws ecr get-login-password --region us-east-2 | sudo docker login --username AWS --password-stdin &lt;account_id&gt;.dkr.ecr.us-east-2.amazonaws.com
</code></pre>
<h2 id="buildthehelloworldwebappimageandpushittoawsecr">Build the Hello World web app image and push it to AWS ECR</h2>
<p>We’ll be using <a href="https://aws.amazon.com/ecr/">AWS ECR</a>, Amazon’s fully managed container registry for storing and deploying application images. To build and push the Hello World app image to AWS ECR, we’ll perform the following six steps in <a href="https://console.aws.amazon.com/cloudshell/">AWS CloudShell</a>:</p>
<ol>
<li>Run the command below in CloudShell to create a repository in AWS ECR.</li>
</ol>
<pre><code>aws ecr create-repository \
    --repository-name elastic-helloworld/web \
    --image-scanning-configuration scanOnPush=true \
    --region us-east-2
</code></pre>
<p><strong>“elastic-helloworld”</strong> will be the application's name and “ <strong>web”</strong> will be the service name.</p>
<ol>
<li>In the newly created tab within CloudShell, clone a <a href="https://github.com/elastic/observability-examples/tree/main/aws/app-runner/helloworld">Python Hello World sample app</a> repo from GitHub by entering the following command.</li>
</ol>
<pre><code>git clone https://github.com/elastic/observability-examples
</code></pre>
<ol>
<li>Change directory to the location of the Hello World web app code by running the following command:</li>
</ol>
<pre><code>cd observability-examples/aws/app-runner/helloworld
</code></pre>
<ol>
<li>Build the Hello World sample app from the application’s directory. Run the following Docker command in CloudShell.</li>
</ol>
<pre><code>sudo docker build -t elastic-helloworld/web .
</code></pre>
<ol>
<li>Tag the application image. Replace \&lt;account_id&gt; with your AWS Account ID in the Docker command below, and then run it in CloudShell.</li>
</ol>
<pre><code>sudo docker tag elastic-helloworld/web:latest &lt;account_id&gt;.dkr.ecr.us-east-2.amazonaws.com/elastic-helloworld/web:latest
</code></pre>
<ol>
<li>Push the application image to ECR. Replace \&lt;account_id&gt; with your AWS Account ID in the command below, and then run it in CloudShell.</li>
</ol>
<pre><code>sudo docker push &lt;account_id&gt;.dkr.ecr.us-east-2.amazonaws.com/elastic-helloworld/web:latest
</code></pre>
<h2 id="deployahelloworldwebapptoawsapprunner">Deploy a Hello World web app to AWS App Runner</h2>
<p>We’ll perform the process of deploying a Python Hello World App to App Runner using the AWS App Runner console.</p>
<ol>
<li>Open the <a href="https://console.aws.amazon.com/apprunner/">App Runner console</a> and click the <strong>Create an App Runner service</strong> button.</li>
</ol>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt10a06a047e45f19e/6a85c895abdc29245412249a/elastic-blog-9-aws-app-runner.png" alt="9 aws app runner" /></p>
<ol>
<li>On the Source and deployment page, set the following deployment details:</li>
</ol>
<ul>
<li>In the Source section, for Repository type, choose <strong>Container registry</strong>.</li>
<li>For Provider, choose <strong>Amazon ECR</strong>.</li>
<li>For Container image URI, choose <strong>Browse</strong> to select the Hello World application image that we previously pushed to AWS ECR.</li>
<li>In the Select Amazon ECR container image dialog box, for Image repository, select the “ <strong>elastic-helloworld/web”</strong> repository.</li>
<li>For Image tag, select “ <strong>latest”</strong> and then choose <strong>Continue</strong>.</li>
<li>In the Deployment settings section, choose <strong>Automatic</strong>.</li>
<li>For ECR access role, choose <strong>Create new service role.</strong></li>
<li>Click <strong>Next</strong>.</li>
</ul>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb40411c9c5a1d34d/6a85c899331d7a7381c31721/elastic-blog-10-source-and-deployment.png" alt="10 source and deployment" /></p>
<ol>
<li>On the Configure service page, in the Service settings section, enter the service name “ <strong>helloworld-app</strong>.” Leave all the other settings as they are and click <strong>Next</strong>.</li>
</ol>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltf51afc194b24e44e/6a85c89c1aa1e11ba8ff8d0b/elastic-blog-11-configure-service.png" alt="11 configure service" /></p>
<ol>
<li>On the Review and create page, click <strong>Create &amp; deploy</strong>.</li>
</ol>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltff71ccfa1d6176d4/6a85c89f07829000d2321720/elastic-blog-12-review-and-create.png" alt="12 review and create" /></p>
<p>After a few minutes, the Hello World app will be deployed to App Runner.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt26b3d560060dd7d6/6a85c8a25c2790004af59ac3/elastic-blog-13-helloworld-app.png" alt="13 hello world app green text" /></p>
<ol>
<li>Click the <strong>Default domain</strong> URL to view the Hello World app running in App Runner.</li>
</ol>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt8f34de23c9dc1f30/6a85c8a443c0b720782f05cc/elastic-blog-14-hello-world.png" alt="14 hello world" /></p>
<h2 id="instrumentthehelloworldwebappwithelasticobservability">Instrument the Hello World web app with Elastic Observability</h2>
<p>With a web app successfully running in App Runner, we’re now ready to add the minimal code necessary to start monitoring the app. To enable observability for the Hello World app in Elastic Cloud, we’ll perform the following five steps in <a href="https://console.aws.amazon.com/cloudshell">AWS CloudShell</a>:</p>
<ol>
<li>Edit the Dockerfile file to add the following Elastic Open Telemetry environment variables along with the commands to install and run the Elastic APM agent. Use the “nano” text editor by typing “nano Dockerfile”. Be sure to replace the \&lt;ELASTIC_APM_SERVER_URL&gt; text and the \&lt;ELASTIC_APM_SECRET_TOKEN&gt; text with the APM Server URL and the APM Secret Token values that you copied and saved in an earlier step. The updated Dockerfile should look something like this:</li>
</ol>
<pre><code>FROM python:3.9-slim as base

# get packages
COPY requirements.txt .
RUN pip install -r requirements.txt

WORKDIR /app

# install opentelemetry packages
RUN pip install opentelemetry-distro opentelemetry-exporter-otlp
RUN opentelemetry-bootstrap -a install

ENV OTEL_EXPORTER_OTLP_ENDPOINT='&lt;ELASTIC_APM_SERVER_URL&gt;'
ENV OTEL_EXPORTER_OTLP_HEADERS='Authorization=Bearer%20&lt;ELASTIC_APM_SECRET_TOKEN&gt;'
ENV OTEL_LOG_LEVEL=info
ENV OTEL_METRICS_EXPORTER=otlp
ENV OTEL_RESOURCE_ATTRIBUTES=service.version=1.0,deployment.environment=production
ENV OTEL_SERVICE_NAME=helloworld
ENV OTEL_TRACES_EXPORTER=otlp

COPY . .
ENV FLASK_APP=helloworld
ENV FLASK_RUN_HOST=0.0.0.0
ENV FLASK_RUN_PORT=8080
EXPOSE 8080
ENTRYPOINT [ "opentelemetry-instrument", "flask", "run" ]
</code></pre>
<p>Note: You can close the nano text editor and save the file by typing “Ctrl + x”. Press the “y” key and then the “Enter” key to save the changes.</p>
<ol>
<li>Edit the helloworld.py file to add observability traces. In CloudShell, type “nano helloworld.py” to edit the file.</li>
</ol>
<ul>
<li>After the import statements at the top of the file, add the code required to initialize the Elastic Open Telemetry APM agent:</li>
</ul>
<pre><code>from opentelemetry import trace
tracer = trace.get_tracer("hello-world")
</code></pre>
<ul>
<li>Replace the “Hello World!” output code . . .</li>
</ul>
<pre><code>return "&lt;h1&gt;Hello World!&lt;/h1&gt;";
</code></pre>
<ul>
<li>… with the Hello Elastic Observability code block.</li>
</ul>
<pre><code>return '''
&lt;div style="text-align: center;"&gt;
&lt;h1 style="color: #005A9E; font-family:'Verdana'"&gt;
Hello Elastic Observability - AWS App Runner - Python
&lt;/h1&gt;
&lt;img src="https://elastic-helloworld.s3.us-east-2.amazonaws.com/elastic-logo.png"&gt;
&lt;/div&gt;
'''
</code></pre>
<ul>
<li>Then add a “hi” trace before the Hello Elastic Observability code block along with an additional “@app.after_request” method placed afterward to implement a “bye” trace.</li>
</ul>
<pre><code>@app.route("/")
def helloworld():
    with tracer.start_as_current_span("hi") as span:
        logging.info("hello")
        return '''
        &lt;div style="text-align: center;"&gt;
        &lt;h1 style="color: #005A9E; font-family:'Verdana'"&gt;
        Hello Elastic Observability - AWS App Runner - Python
        &lt;/h1&gt;
        &lt;img src="https://elastic-helloworld.s3.us-east-2.amazonaws.com/elastic-logo.png"&gt;
        &lt;/div&gt;
        '''

@app.after_request
def after_request(response):
    with tracer.start_as_current_span("bye"):
        logging.info("goodbye")
        return response
</code></pre>
<p>The completed helloworld.py file should look something like this:</p>
<pre><code>import logging
from flask import Flask

from opentelemetry import trace
tracer = trace.get_tracer("hello-world")

app = Flask(__name__)

@app.route("/")
def helloworld():
    with tracer.start_as_current_span("hi") as span:
        logging.info("hello")
        return '''
        &lt;div style="text-align: center;"&gt;
        &lt;h1 style="color: #005A9E; font-family:'Verdana'"&gt;
        Hello Elastic Observability - AWS App Runner - Python
        &lt;/h1&gt;
        &lt;img src="https://elastic-helloworld.s3.us-east-2.amazonaws.com/elastic-logo.png"&gt;
        &lt;/div&gt;
        '''

@app.after_request
def after_request(response):
    with tracer.start_as_current_span("bye"):
        logging.info("goodbye")
        return response
</code></pre>
<p>Note: You can close the nano text editor and save the file by typing “Ctrl + x”. Press the “y” key and then the “Enter” key to save the changes.</p>
<ol>
<li>Rebuild the updated Hello World sample app using Docker from within the application’s directory. Run the following command in CloudShell.</li>
</ol>
<pre><code>sudo docker build -t elastic-helloworld/web .
</code></pre>
<ol>
<li>Tag the application image using Docker. Replace \&lt;account_id&gt; with your AWS Account ID in the Docker command below and then run it in CloudShell.</li>
</ol>
<pre><code>sudo docker tag elastic-helloworld/web:latest &lt;account_id&gt;.dkr.ecr.us-east-2.amazonaws.com/elastic-helloworld/web:latest
</code></pre>
<ol>
<li>Push the updated application image to ECR. Replace \&lt;account_id&gt; with your AWS Account ID in the Docker command below and then run it in CloudShell.</li>
</ol>
<pre><code>sudo docker push &lt;account_id&gt;.dkr.ecr.us-east-2.amazonaws.com/elastic-helloworld/web:latest
</code></pre>
<p>Pushing the image to ECR will automatically deploy the new version of the Hello World app.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt0a8c9b9db2a545ab/6a85c8a711893c1df1a7ab32/elastic-blog-15-green-banner-successfully.png" alt="15 green banner successful deployment" /></p>
<p>Open the <a href="http://console.aws.amazon.com/apprunner">App Runner</a> console. After a few minutes, the Hello World app will be deployed to App Runner. Click the <strong>Default domain</strong> URL to view the updated Hello World app running in App Runner.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt65db284a7eb00d66/6a85c8aaf61d6eb6bb9c2ac3/elastic-blog-16-elastic-logo-text-top.png" alt="16 elastic" /></p>
<h2 id="observethehelloworldwebapp">Observe the Hello World web app</h2>
<p>Now that we’ve instrumented the web app to send observability data to Elastic Observability, we can now use Elastic Cloud to monitor the web app’s operations.</p>
<ol>
<li><p>In Elastic Cloud, select the Observability <strong>Services</strong> menu item.</p></li>
<li><p>Click the <strong>helloworld</strong> service.</p></li>
<li><p>Click the <strong>Transactions</strong> tab.</p></li>
<li><p>Scroll down and click the <strong>“/”</strong> transaction.</p></li>
<li><p>Scroll down to the Trace Sample section to see the <strong>“/,” “hi,”</strong> and <strong>“bye”</strong> trace samples.</p></li>
</ol>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt6aea5ad7fcd9fd2c/6a85c8ad33f244bad049f4c0/elastic-blog-17-trace-sample.png" alt="17 trace sample" /></p>
<h2 id="observabilitymadetoscale">Observability made to scale</h2>
<p>You’ve seen the complete process of deploying a web app to AWS App Runner that is instrumented with Elastic Observability. The end result is a web app that will scale up and down with usage, combined with the observability tools to monitor the web app as it serves one user or millions of users.</p>
<p>Now that you’ve seen how to deploy a serverless web app instrumented with observability, visit <a href="https://www.elastic.co/observability">Elastic Observability</a> to learn more about how to implement a complete observability solution for your apps. Or visit <a href="https://www.elastic.co/getting-started/aws">Getting started with Elastic on AWS</a> for more examples of how you can drive the data insights you need by combining AWS’s cloud computing services with Elastic’s search-powered platform.</p>
<p><em>The release and timing of any features or functionality described in this post remain at Elastic's sole discretion. Any features or functionality not currently available may not be delivered on time or at all.</em></p>]]></content:encoded>
    <link>https://www.elastic.co/observability-labs/blog/deploy-app-observability-aws-app-runner</link>
    <guid isPermaLink="false">deploy-app-observability-aws-app-runner</guid>
    <category><![CDATA[APM]]></category>
    <category><![CDATA[Infrastructure Monitoring]]></category>
    <dc:creator><![CDATA[Jonathan Simon]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt5b613993e5cae1c3/6a85c8b0f61d6ecd539c2ad1/library-branding-elastic-observability-white-1680x980.png" length="0" type="image/png"/>
    <pubDate>Mon, 02 Oct 2023 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[How to deploy Hello World Elastic Observability on Google Cloud Run]]></title>
    <description><![CDATA[Follow the step-by-step process of instrumenting Elastic Observability for a Hello World web app running on Google Cloud Run.]]></description>
    <content:encoded><![CDATA[<p>Elastic Cloud Observability is the premiere tool to provide visibility into your running web apps. Google Cloud Run is the serverless platform of choice to run your web apps that need to scale up massively and scale down to zero. Elastic Observability combined with Google Cloud Run is the perfect solution for developers to deploy <a href="https://www.elastic.co/blog/observability-powerful-flexible-efficient">web apps that are auto-scaled with fully observable operations</a>, in a way that’s straightforward to implement and manage.</p>
<p>This blog post will show you how to deploy a simple Hello World web app to Cloud Run and then walk you through the steps to instrument the Hello World web app to enable observation of the application’s operations with Elastic Cloud.</p>
<h2 id="elasticobservabilitysetup">Elastic Observability setup</h2>
<p>We’ll start with setting up an Elastic Cloud deployment, which is where observability will take place for the web app we’ll be deploying.</p>
<p>From the <a href="https://cloud.elastic.co">Elastic Cloud console</a>, select <strong>Create deployment</strong>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt794a66370574c9d9/6a85cb45331d7a5ad6c3179b/elastic-blog-1-create-deployment.png" alt="create deployment" /></p>
<p>Enter a deployment name and click <strong>Create deployment</strong>. It takes a few minutes for your deployment to be created. While waiting, you are prompted to save the admin credentials for your deployment, which provides you with superuser access to your Elastic<sup>®</sup> deployment. Keep these credentials safe as they are shown only once.</p>
<p>Elastic Observability requires an APM Server URL and an APM Secret token for an app to send observability data to Elastic Cloud. Once the deployment is created, we’ll copy the Elastic Observability server URL and secret token and store them somewhere safely for adding to our web app code in a later step.</p>
<p>To copy the APM Server URL and the APM Secret Token, go to <a href="https://cloud.elastic.co/home">Elastic Cloud</a>. Then go to the <a href="https://cloud.elastic.co/deployments">Deployments</a> page which lists all of the deployments you have created. Select the deployment you want to use, which will open the deployment details page. In the <strong>Kibana</strong> row of links, click on <strong>Open</strong> to open <strong>Kibana</strong> for your deployment.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1b98ae3828170fd6/6a85cb479bf99464a60a0579/elastic-blog-2-my-deployment.png" alt="my deployment" /></p>
<p>Select <strong>Integrations</strong> from the top-level menu. Then click the <strong>APM</strong> tile.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt970877511664c0bb/6a85cb4a682666c4891eac0f/elastic-blog-3-apm.png" alt="apm" /></p>
<p>On the APM Agents page, copy the secretToken and the serverUrl values and save them for use in a later step.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt306a2bfcec5a0c94/6a85cb4dbc5bb3e6a7f81b07/elastic-blog-4-apm-agents.png" alt="apm agents" /></p>
<p>Now that we’ve completed the Elastic Cloud setup, the next step is to set up our Google Cloud project for deploying apps to Cloud Run.</p>
<h2 id="googlecloudrunsetup">Google Cloud Run setup</h2>
<p>First we’ll need a Google Cloud project, so let’s create one by going to the <a href="https://console.cloud.google.com">Google Cloud console</a> and creating a new project. Select the project menu and then click the <strong>New Project</strong> button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1361049eefbcb893/6a85cb5093ffb94956b91439/elastic-blog-5-google-cloud-gray-dropdown.png" alt="google cloud with gray dropdown" /></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt50aaf60c2197b967/6a85cb53501a850afbfbb331/elastic-blog-5-select-a-project.png" alt="select a project" /></p>
<p>Once the new project is created, we’ll need to enable the necessary APIs that our Hello World app will be using. This can be done by clicking this <a href="https://console.cloud.google.com/flows/enableapi?apiid=compute.googleapis.com,,run.googleapis.com,containerregistry.googleapis.com,cloudbuild.googleapis.com">enable APIs</a> link, which opens a page in the Google Cloud console that lists the APIs that will be enabled and allows us to confirm their activation.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltaffea5bf8711fd60/6a85cb560782907802321774/elastic-blog-6-enable-apis.png" alt="enable apis" /></p>
<p>After we’ve enabled the necessary APIs, we’ll need to set up the required permissions for our Hello World app, which can be done in the <a href="https://console.cloud.google.com/iam-admin">IAM section</a> of the Google Cloud Console. Within the IAM section, select the <strong>Compute Engine</strong> default service account and add the following roles:</p>
<ul>
<li>Logs Viewer</li>
<li>Monitoring Viewer</li>
<li>Pub/Sub Subscriber</li>
</ul>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4acf3604f25e2b44/6a85cb59501a855036fbb337/elastic-blog-7-principals.png" alt="principals" /></p>
<h2 id="deployahelloworldwebapptocloudrun">Deploy a Hello World web app to Cloud Run</h2>
<p>We’ll perform the process of deploying a Node.js Hello World web app to Cloud Run using the handy Google Cloud tool called <a href="https://console.cloud.google.com/cloudshelleditor">Cloud Shell Editor</a>. To deploy the Hello World app, we’ll perform the following five steps:</p>
<ol>
<li>In Cloud Shell Editor, in the terminal window that appears at the bottom of the screen, clone a <a href="https://github.com/elastic/observability-examples/tree/main/gcp/run/helloworld">Node.js Hello World sample app</a> repo from GitHub by entering the following command.</li>
</ol>
<pre><code>git clone https://github.com/elastic/observability-examples
</code></pre>
<ol>
<li>Change directory to the location of the Hello World web app code.</li>
</ol>
<pre><code>cd gcp/run/helloworld
</code></pre>
<ol>
<li>Build the Hello World app image and push the image to Google Container Registry by running the command below in the terminal. Be sure to replace your-project-id in the command below with your actual Google Cloud project ID.</li>
</ol>
<pre><code>gcloud builds submit --tag gcr.io/your-project-id/elastic-helloworld
</code></pre>
<ol>
<li>Deploy the Hello World app to Google Cloud Run by running the command below. Be sure to replace your-project-id in the command below with your actual Google Cloud project ID.</li>
</ol>
<pre><code>gcloud run deploy elastic-helloworld --image gcr.io/your-project-id/elastic-helloworld
</code></pre>
<ol>
<li>When the deployment process is complete, a Service URL will be displayed within the terminal. Copy and paste the Service URL in a browser to view the Hello World app running in Cloud Run.</li>
</ol>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt878d233fbf177588/6a85cb5cf61d6ec4629c2b27/elastic-blog-8-hello-world.png" alt="hello world" /></p>
<h2 id="instrumentthehelloworldwebappwithelasticobservability">Instrument the Hello World web app with Elastic Observability</h2>
<p>With a web app successfully running in Cloud Run, we’re now ready to add the minimal code necessary to start monitoring the app. To enable observability for the Hello World app in Elastic Cloud, we’ll perform the following six steps:</p>
<ol>
<li>In the Google Cloud Shell Editor, edit the Dockerfile file to add the following Elastic Open Telemetry environment variables along with the commands to install and run the Elastic APM agent. Replace the ELASTIC_APM_SERVER_URL text and the ELASTIC_APM_SECRET_TOKEN text with the APM Server URL and the APM Secret Token values that you copied and saved in an earlier step.</li>
</ol>
<pre><code>ENV OTEL_EXPORTER_OTLP_ENDPOINT='ELASTIC_APM_SERVER_URL'
ENV OTEL_EXPORTER_OTLP_HEADERS='Authorization=Bearer ELASTIC_APM_SECRET_TOKEN'
ENV OTEL_LOG_LEVEL=info
ENV OTEL_METRICS_EXPORTER=otlp
ENV OTEL_RESOURCE_ATTRIBUTES=service.version=1.0,deployment.environment=production
ENV OTEL_SERVICE_NAME=helloworld
ENV OTEL_TRACES_EXPORTER=otlp
RUN npm install --save @opentelemetry/api
RUN npm install --save @opentelemetry/auto-instrumentations-node
CMD ["node", "--require", "@opentelemetry/auto-instrumentations-node/register", "index.js"]
</code></pre>
<p>The updated Dockerfile should look something like this:</p>
<pre><code>FROM node:18-slim
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install --only=production
COPY . ./
OTEL_EXPORTER_OTLP_ENDPOINT='https://******.apm.us-central1.gcp.cloud.es.io:443'
ENV OTEL_EXPORTER_OTLP_HEADERS='Authorization=Bearer ******************'
ENV OTEL_LOG_LEVEL=info
ENV OTEL_METRICS_EXPORTER=otlp
ENV OTEL_RESOURCE_ATTRIBUTES=service.version=1.0,deployment.environment=production
ENV OTEL_SERVICE_NAME=helloworld
ENV OTEL_TRACES_EXPORTER=otlp
RUN npm install --save @opentelemetry/api
RUN npm install --save @opentelemetry/auto-instrumentations-node
CMD ["node", "--require", "@opentelemetry/auto-instrumentations-node/register", "index.js"]
</code></pre>
<ol>
<li>In the Google Cloud Shell Editor, edit the package.json file to add the Elastic APM dependency. The dependencies section in package.json should look something like this:</li>
</ol>
<pre><code>"dependencies": {
      "express": "^4.18.2",
      "elastic-apm-node": "^3.49.1"
  },
</code></pre>
<ol>
<li>In the Google Cloud Shell Editor, edit the index.js file:</li>
</ol>
<ul>
<li>Add the code required to initialize the Elastic Open Telemetry APM agent:</li>
</ul>
<pre><code>const otel = require("@opentelemetry/api");
const tracer = otel.trace.getTracer("hello-world");
</code></pre>
<ul>
<li>Replace the “Hello World!” output code . . .</li>
</ul>
<pre><code>res.send(`&lt;h1&gt;Hello World!&lt;/h1&gt;`);
</code></pre>
<p>…with the “Hello Elastic Observability” code block.</p>
<pre><code>res.send(
  `&lt;div style="text-align: center;"&gt;
   &lt;h1 style="color: #005A9E; font-family:'Verdana'"&gt;
   Hello Elastic Observability - Google Cloud Run - Node.js
   &lt;/h1&gt;
   &lt;img src="https://storage.googleapis.com/elastic-helloworld/elastic-logo.png"&gt;
   &lt;/div&gt;`
);
</code></pre>
<ul>
<li>Add a trace “hi” before the “Hello Elastic Observability” code block and add a trace “bye” after the “Hello Elastic Observability” code block.</li>
</ul>
<pre><code>tracer.startActiveSpan("hi", (span) =&gt; {
  console.log("hello");
  span.end();
});
res.send(
  `&lt;div style="text-align: center;"&gt;
   &lt;h1 style="color: #005A9E; font-family:'Verdana'"&gt;
   Hello Elastic Observability - Google Cloud Run - Node.js
   &lt;/h1&gt;
   &lt;img src="https://storage.googleapis.com/elastic-helloworld/elastic-logo.png"&gt;
   &lt;/div&gt;`
);
tracer.startActiveSpan("bye", (span) =&gt; {
  console.log("goodbye");
  span.end();
});
</code></pre>
<ul>
<li>The completed index.js file should look something like this:</li>
</ul>
<pre><code>const otel = require("@opentelemetry/api");
const tracer = otel.trace.getTracer("hello-world");

const express = require("express");
const app = express();

app.get("/", (req, res) =&gt; {
  tracer.startActiveSpan("hi", (span) =&gt; {
    console.log("hello");
    span.end();
  });
  res.send(
    `&lt;div style="text-align: center;"&gt;
    &lt;h1 style="color: #005A9E; font-family:'Verdana'"&gt;
    Hello Elastic Observability - Google Cloud Run - Node.js
    &lt;/h1&gt;
   &lt;img src="https://storage.googleapis.com/elastic-helloworld/elastic-logo.png"&gt;
    &lt;/div&gt;`
  );
  tracer.startActiveSpan("bye", (span) =&gt; {
    console.log("goodbye");
    span.end();
  });
});

const port = parseInt(process.env.PORT) || 8080;
app.listen(port, () =&gt; {
  console.log(`helloworld: listening on port ${port}`);
});
</code></pre>
<ol>
<li>Rebuild the Hello World app image and push the image to the Google Container Registry by running the command below in the terminal. Be sure to replace your-project-id in the command below with your actual Google Cloud project ID.</li>
</ol>
<pre><code>gcloud builds submit --tag gcr.io/your-project-id/elastic-helloworld
</code></pre>
<ol>
<li>Redeploy the Hello World app to Google Cloud Run by running the command below. Be sure to replace your-project-id in the command below with your actual Google Cloud project ID.</li>
</ol>
<pre><code>gcloud run deploy elastic-helloworld --image gcr.io/your-project-id/elastic-helloworld
</code></pre>
<ol>
<li>When the deployment process is complete, a Service URL will be displayed within the terminal. Copy and paste the Service URL in a browser to view the updated Hello World app running in Cloud Run.</li>
</ol>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt3a655bc1371c8bc8/6a85cb5fd7b2e7b297fe84da/elastic-blog-9-elastic-logo.png" alt="elastic logo" /></p>
<h2 id="observethehelloworldwebapp">Observe the Hello World web app</h2>
<p>Now that we’ve instrumented the web app to send observability data to Elastic Observability, we can now use Elastic Cloud to monitor the web app’s operations.</p>
<ol>
<li><p>In Elastic Cloud, select the Observability <strong>Services</strong> menu item.</p></li>
<li><p>Click the <strong>helloworld</strong> service.</p></li>
<li><p>Click the <strong>Transactions</strong> tab.</p></li>
<li><p>Scroll down and click the <strong>GET /</strong> transaction.</p></li>
<li><p>Scroll down to the <strong>Trace Sample</strong> section to see the <strong>GET /</strong> , <strong>hi</strong> and <strong>bye</strong> trace samples.</p></li>
</ol>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltee3cd0244463c5a9/6a85cb622d64d5f7f3081d48/elastic-blog-10-trace-sample.png" alt="trace sample" /></p>
<h2 id="observabilitymadetoscale">Observability made to scale</h2>
<p>You’ve seen the entire process of deploying a web app to Google Cloud Run that is instrumented with Elastic Observability. The end result is a web app that will scale up and down with demand combined with the observability tools to monitor the web app as it serves a single user or millions of users.</p>
<p>Now that you’ve seen how to deploy a serverless web app instrumented with observability, visit <a href="https://www.elastic.co/observability">Elastic Observability</a> to learn more about how to implement a complete observability solution for your apps. Or visit <a href="https://www.elastic.co/getting-started/google-cloud">Getting started with Elastic on Google Cloud</a> for more examples of how you can drive the data insights you need by combining <a href="https://www.elastic.co/observability/google-cloud-monitoring">Google Cloud monitoring</a> and cloud computing services with Elastic’s search-powered platform.</p>
<p><em>The release and timing of any features or functionality described in this post remain at Elastic's sole discretion. Any features or functionality not currently available may not be delivered on time or at all.</em></p>]]></content:encoded>
    <link>https://www.elastic.co/observability-labs/blog/deploy-observability-google-cloud-run</link>
    <guid isPermaLink="false">deploy-observability-google-cloud-run</guid>
    <category><![CDATA[Infrastructure Monitoring]]></category>
    <category><![CDATA[APM]]></category>
    <dc:creator><![CDATA[Jonathan Simon]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltab62612301e9c429/6a85cb65f5f1a02e662ec909/illustration-dev-sec-ops-cloud-automations-1680x980.png" length="0" type="image/png"/>
    <pubDate>Mon, 28 Aug 2023 00:00:00 GMT</pubDate>
  </item>
  </channel>
</rss>