How can I use appInsights with HDInsight cluster - azure

I have a spark cluster on azure hdinsight. Is there any way I can integrate azure applicationInsights with it to get all the monitoring and log analysis capabilties. This can be done through Azure Monitor Logs according to Microsoft docs but for some reason I need to specifically integrate my spark app on hdinsight with applicationInsights only. Couldn't find any documentation or example for the same anywhere.

Unfortunately, you cannot use Application Insight to get logs of HDInsight cluster.
Azure Monitor logs enable data generated by multiple resources, such as HDInsight clusters, to be collected and aggregated in one place to achieve a unified monitoring experience.
As a prerequisite, you'll need a Log Analytics Workspace to store the collected data. If you haven't already created one, you can follow instructions here: Create a Log Analytics Workspace.
What's the difference between Azure Monitor, Log Analytics, and
Application Insights?
In September 2018, Microsoft combined Azure Monitor, Log Analytics, and Application Insights into a single service to provide powerful end-to-end monitoring of your applications and the components they rely on. Features in Log Analytics and Application Insights have not changed, although some features have been rebranded to Azure Monitor in order to better reflect their new scope. The log data engine and query language of Log Analytics is now referred to as Azure Monitor Logs. See Azure Monitor terminology updates.
Can I use Application Insights with ...?
Web apps on an IIS server in Azure VM or Azure virtual machine scale
set Web apps on an IIS server - on-premises or in a VM
Java web apps
Node.js apps
Web apps on Azure
Cloud Services on Azure
App servers running in Docker
Single-page web apps
SharePoint
Windows desktop app
Other platforms

Found a way of making ApplicationInsights work with HdInsight (Spark) cluster. The application deployed on the cluster is a Spark application written in Scala (maven based). Though Microsoft doesn't have an SDK for Scala at this point, I was able to use the applicationinsights-logging-log4j dependency to send app logs as well as spark yarn logs to AppInsights, which was the end goal in my case.
Here's how to do it:
Add these dependencies to pom.xml
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-core</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-logging-log4j1_2</artifactId>
<version>2.6.1</version>
</dependency>
Use the ApplicationInsightsAppender class
import org.apache.log4j.{ Logger, Level }
import com.microsoft.applicationinsights.log4j.v1_2.ApplicationInsightsAppender
object AppInsightLogger {
var rootLogger = Logger.getRootLogger()
var ai = new ApplicationInsightsAppender()
ai.setInstrumentationKey("your-key")
ai.activateOptions()
#transient lazy val logger = Logger.getLogger(this.getClass)
logger.setLevel(Level.INFO)
rootLogger.addAppender(ai)
def info(message: String): Unit = {
logger.info(message)
}
}
Finally, this can be used anywhere in the application such as:
AppInsightLogger.info("Streaming messages from EH")
I was able to get Spark yarn logs as well as custom logs from the application deployed on HdInsight to AppInsights without using an SDK for scala! (The dashboards and telemetry data cannot be seen using this approach. We get the logs as "Trace" having different severity levels. We can see exceptions as well if any. Use the "Search" option on the portal for viewing the logs)
Logs seen on AppInsights
Exception logs seen on AppInsights

Related

Application Insights return empty charts on Grafana

I'm trying to display azure application insights on a grafana dashboard, the application insights are enabled for a web service on the Azure ML studio but end up with empty charts for all the available metrics. Can you please tell me where I'm doing it wrong or if I'm missing something? Thank you.
Application Insights is an Application Performance Management service from Azure for web developers on multiple platforms and it can be used to monitor your web application. You would get the charts in Grafana if you are following steps mentioned below.
In Grafana, use the Azure Monitor Data Source plugin which supports Azure Monitor, Azure Log Analytics and Application Insights metrics. But remember this plugin requires Grafana 4.5.0 or newer for Application Insights. You can install the plugin in after updating your Grafana in CLI with the following command.
grafana-cli plugins install grafana-azure-monitor-datasource
You can also set up Grafana on Azure through the Azure Marketplace.
The plugin can access metrics from both the Azure Monitor service and the Application Insights API. But you would need to configure access to the services. If you are using Application Insights, then you need two pieces of information from the Azure Portal which are the Application ID and an API key. Check this Application Insights API QuickStart for more information.
Write analytic queries for the Application Insights. When you set service type to "Application Insights", the menu icon to the right adds another option, "Toggle Edit Mode". Once clicked, it gives you a full text area in which to write log analytics queries. Check this Writing Analytics Queries For Application Insights section of the Grafana document for more information.
The above mentioned procedure will help you get the proper charts in the Grafana. I would also suggest to read this Monitor your Azure services in Grafana document from Microsoft for more information.

Possible to integrate Azure Application insights with existing service fabric cluster in code-less manner?

Would like to use Application insights especially, "Azure live metrics stream" feature on existing PROD Azure service fabric workloads to do performance analysis.Is service fabric has built-in integration with Azure Application Insights?
Is it possible do it in code less manner like how Application insights can be enabled via portal for web Apps/Azure functions? If not, why?
Then, how to do it code based manner? Any reference to do code changes would be helpful.
What is the difference between code less & code based monitoring? When to choose one over another? Our requirement is to study performance of application (deployed on various nodes of PROD service fabric cluster) under different load.
Please clarify above list of queries.
Is service fabric has built-in integration with Azure Application Insights?
You could leverage Windows Azure Diagnostics (WAD) extension to sink SF cluster logs and/or Perf metrics into App Insights - Configuring Application Insights with WAD
There is no way to monitor an application running in SF via AppInsights without a small amount of coding.
Then, how to do it code based manner? Any reference to do code changes would be helpful.
Here you go - Monitor and diagnose an ASP.NET Core application on Service Fabric using Application Insights.
What is the difference between code less & code based monitoring? When to choose one over another? Our requirement is to study performance of application (deployed on various nodes of PROD service fabric cluster) under different load.
As I said, to monitor your app you have to code. Although it's super simple. Other from that, here is a general recommendation - Event analysis and visualization with Application Insights:
It is recommended to use EventFlow and WAD as aggregation solutions,
because they allow for a more modular approach to diagnostics and
monitoring, i.e. if you want to change your outputs from EventFlow, it
requires no change to your actual instrumentation, just a simple
modification to your config file. If, however, you decide to invest in
using Application Insights and are not likely to change to a different
platform, you should look into using Application Insights' new SDK for
aggregating events and sending them to Application Insights. This
means that you will no longer have to configure EventFlow to send your
data to Application Insights, but instead will install the
ApplicationInsight's Service Fabric NuGet package.
Here is the link to the best practices - Monitoring and diagnostics on SF platform.

Azure PaaS for Storing Centralized Log Data for Microservices

If we deploy a Microservice in azure AKS, there may be multiple pods and replica of same services. If Microservice want to keep any custom log information about it's flow or errors , where better to store such logs centrally? Any PaaS services? e. g. Azure Storage? Any real experience to share here?
I would suggest Azure Application Insigths. You can enrich your telemetry with aks details using this integration package:
... when using Microsoft Application Insights for Kubernetes, you will see Kubernetes related properties like Pod-Name, Deployment ... on all your telemetry entries. Proper values will also be set to make use of the rich features like enabling the Application Map to show the multiple micro services on the same map.
For logging within your application you can use the ILogger interface (if using .net) and pipe it to app insights.
Or you can write your own logging using the sdk, available in selected languages.
For java applications, you can pipe your logs as well. You probably have to manually add pod details to your telemetry using telemetry initializers as the Microsoft Application Insights for Kubernetes package is .Net only. As far as I know they use the kubernetes rest api to query for details.

Azure application insights or log analytics

What is the use case for Azure application insights or log analytics?
I am using APIM and Azure Functions and want to perform logging for requests. Which one is the best fit, application insights or log analytics?
https://learn.microsoft.com/en-gb/azure/azure-monitor/overview
Update
In particular, any info on Azure application insights vs log analytics used for APIM?
What used to be known as Application Insights and Log Analytics independent offerings - are now a part of Azure Monitor. We're actively merging both platforms.
For instance, Analytics exploration part is exactly the same (same backend, same UX, same capabilities, just different data schema). Alerts are the same. Some experiences are still different (for instance, app experiences such as Application Map).
Example: in Azure Monitor Overview (https://learn.microsoft.com/en-gb/azure/azure-monitor/overview):
"Log Analytics" is referred as a feature and not what used to be known as Log Analytics as a product. For instance, Application Insights resources provide the same "Log Analytics" feature.
For Azure Functions / APIM the native integration with Azure Monitor is through Application Insights.
Update (October, 2020). Application Insights can now store data in Log Analytics workspaces. Now many workspace related features are available to Application Insights resources. How to migrate.
Azure function better to go with application insights and if you working with kubernetes cluster choose Log analytics work space
Azure Functions offers built-in integration with Azure Application Insights to monitor functions.
So for azure function, you'd better use application insights, which is easy configure.
Details are here.
Application Insights
Application Insights is an Application Performance Management (APM) service, that you use to monitor your application. It helps to detect performance anomalies, has analytic abilities, and can help you understand how users interact with your application.
Not only can it collect telemetry data from your application, but it can also collect information from the application host, Azure Diagnostics, or Docker logs. It’s also nice that you can use Application Insights to set up tests that send requests to your website/service to check for availability (and receive a notice if these fail).
One of the most powerful things that I’ve noticed in my use of Application Insights (which is monitoring this blog), is the Smart Detection feature. This feature proactively analyzes and detects changes in your application. So even if you hadn’t set up an Alert of monitoring of a specific metric, it can pick it up and react to it.

Can Azure Insights API be used for completely stand-alone custom metrics?

I am hoping I can put in some simple API calls in legacy systems so I can capture point-in-time metrics "somewhere" in Azure, so that I can then take advantage of the Azure Portal dashboard and metrics graphing. I looked into Insights SDK but that seems to require that whatever I'm running be deployed somewhere in Azure cloud. I just want to run a simple powershell script or simple .net console app that connects to a legacy database in our internal network, pulls very basic point-in-time counts for message processing backlog... and then pushes that info with a timestamp out "somewhere" for visualization.
Any ideas what I can use for this in Azure?
Thanks,
Andres
You can use the TrackMetric API in Application Insights SDK.
https://learn.microsoft.com/en-us/azure/application-insights/app-insights-api-custom-events-metrics

Resources