Git Product home page Git Product logo

ssrikantan / logs-ehub-sink Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 822 KB

Sample that demonstrates the use of Azure Event Hubs to ingest streaming Diagnostic Logs originating from across Azure Services. Azure Functions is used to pick up the messages from Event Hubs and send them to a custom REST API

C# 100.00%
azure azure-eventhub azure-functions azure-monitor aspnet-web-api app-insights diagnostics logs

logs-ehub-sink's Introduction

logs-ehub-sink

Sample demonstrates the use of Azure Event Hubs to ingest streaming Diagnostic Logs that originate from across different Azure Services. Azure Functions uses an input trigger from Event Hubs to pick the log messages and sends them to a custom REST Service

Streaming diagnostic logs from Azure Monitor

Diagnostic logs from different Azure Services can be streamed to Log Analytics, or to Azure Event Hubs, using Azure Monitor. This article - https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-stream-diagnostic-logs-to-event-hubs - has the guidance. For this sample, Azure Monitor was configured to stream logs from a Cosmos DB Service and Azure Search Service. An Event Hub namespace + Event Hub endpoint have to exist to complete the above step. After configuring the diagnostics, navigate to the Event Hub end point and in the metrics view, ensure the 'Messages' part shows incoming messages. The outgoing messages metrics will show up only after client consumers (Azure Functions in this example) are configured.

drawing

Deploy the custom REST Service to receive the logs from Azure Functions

This is a simple ASP.NET Core 2.0 Web API project that will receive the Logs coming in from Azure Functions (configured in the next section below). This is to mimic a third party Solution that would want to handle Diagnostic logs. The Visual Studio 2017 Project for this REST Service 'LogReceiverService' is included in this repository. This custom code uses Application Insights to send the trace information. To view the telemetry when running this sample, create an Application Inisights resource in Azure, and enter its Security key inside the appsettings.json file of the Project. Publish this Project to a Web App in Azure. The URL of the LogReceiverController Service would be required in the next section below, in the Function App.

The REST Service deserializes the incoming Diagnostic log messages based on the common schema definition, that applies to all the Azure Services. In the property attribute of the Message, attributes specific and unique to each Azure Service are captured. Refer to this link - https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-diagnostic-logs-schema for details of the common schema.

Create an Azure Function (Event Hub Consumer)

Create a new Azure Function App (version 1.x is used in this example) and configure an input trigger on the EVent Hub created in the earlier steps. This link https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-azure-function pertains to configuring a HTTP Trigger, but the steps for Event Hub input triggers are similar.

Copy the code from folder "Azure Functions Code\run.cs", available in this repository, into the Function app's run.csx editor in the Azure Portal.

Since this code depends on additional packages to run, create a Project.JSON file in the Kudu console of the Function App, and copy the content of the Project.json file included in this repository. After it is saved, restart the Function App from the Azure Portal. Ensure the Log console on the Function's run.csx file indicates it has successfully compiled and is running. The Messages from Event Hubs should start showing up in this console after some time.

drawing

Update the URL of the custom REST Service in the run.csx to send the Messages to (from the previous section).

Refer to these links below to understand how to develop applications using Azure Functions. https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference#fileupdate https://docs.microsoft.com/en-us/azure/azure-functions/functions-develop-local

drawing

View the Application Insights Telemetry

View the Trace in Application Insights to ensure the Diagnostics Logs were received from the Function App. drawing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.