服务结构和应用程序见解 [英] Service Fabric and Application Insights

查看:63
本文介绍了服务结构和应用程序见解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是服务Fabric的新手,正在尝试将Windows Service应用程序集成到服务Fabric中.对于日志记录信息,我们计划使用Application Insights.但是,如果我通过SF应用程序发送事件,则不会记录该事件.同时,通过普通的控制台/Windows应用程序,我可以将消息记录到applicationinsights中,并可以在那里查看.

I am new to service Fabric and trying to integrate my windows service application into service fabric. For logging information, we are planning to use Application Insights. But the events are not logged if i send it through my SF application. At the same time, through a normal console/windows application, I can able to log the message to applicationinsights and can be viewed from there.

然后,我尝试在azure环境中创建VM,然后在其中创建SF应用程序,然后将日志信息发送到AI,并且该AI工作成功.我将相同的代码库复制到本地计算机上并运行它,但无法正常工作.我不确定它是否与任何防火墙或代理设置有关.有人可以帮忙吗?

Then I tried to create a VM in azure environment, and create SF application there and send the log information to AI and its worked successfully. I copied the same codebase into my local machine and run it, its not working. I am not sure whether its related to any firewall or proxy settings. Can anyone help on this?

我已使用nuget软件包在我的计算机上安装Microsoft.ApplicationInsights dll.我使用的版本是2.2.0.我正在使用.Net Framework 4.6.1

I have used the nuget package to install Microsoft.ApplicationInsights dll in my machine. The version that I used is 2.2.0. And I am using .Net framework 4.6.1

推荐答案

您可以查看 EventFlow 帮助您从SF服务捕获Service Fabric ETW事件并将其发送到Application Insights.

You could look at EventFlow to help you capture Service Fabric ETW Events from your SF services and send them to Application Insights.

设置非常简单,只需将Microsoft.Diagnostics.EventFlow.ServiceFabric NuGet添加到您的Service Fabric服务项目中,然后

It's easy enough to setup, simply add Microsoft.Diagnostics.EventFlow.ServiceFabric NuGet to your Service Fabric service project and then setup a pipline

public static void Main(string[] args)
{
    try
    {
        using (var diagnosticsPipeline = ServiceFabricDiagnosticPipelineFactory.CreatePipeline("MyApplication-MyService-DiagnosticsPipeline"))
        {
            ServiceRuntime.RegisterServiceAsync("MyServiceType", ctx => new MyService(ctx)).Wait();

            ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(MyService).Name);

            Thread.Sleep(Timeout.Infinite);
        }
    }
    catch (Exception e)
    {
        ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());
        throw;
    }
}

然后在您的eventflow.config中,您可以设置Application Insights 作为输出:

In your eventflow.config you can then setup Application Insights as an output:

{
    "inputs": [
        {
            "type": "EventSource",
            "sources": [
                 { "providerName": "Your-Service-EventSource" }
           ]
        },
    ],
    "filters": [
        {
            "type": "drop",
            "include": "Level == Verbose"
        }
    ],
    "outputs": [
        // Please update the instrumentationKey.
        {
            "type": "ApplicationInsights",
            "instrumentationKey": "00000000-0000-0000-0000-000000000000"
        }
    ],
    "schemaVersion": "2016-08-11",
    "extensions": []
}

这篇关于服务结构和应用程序见解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆