I am trying to integrate Azure App insights service into the service fabric app for logging and instrumentation. I am running fabric code on my local VM. I exactly followed the document here [scenario 2]. Other resources on docs.microsoft.com also seem to indicate the same steps. [ex: https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-diagnostics-event-aggregation-eventflow For some reason, I don’t see any event entries in App insights. No errors in code when I do this:
ServiceEventSource.Current.ProcessedCountMetric("synced",sw.ElapsedMilliseconds, crc.DataTable.Rows.Count);
eventflowconfig.json contents
{ "inputs": [ { "type": "EventSource", "sources": [ { "providerName": "Microsoft-ServiceFabric-Services" }, { "providerName": "Microsoft-ServiceFabric-Actors" }, { "providerName": "mystatefulservice" } ] } ], "filters": [ { "type": "drop", "include": "Level == Verbose" } ], "outputs": [ { "type": "ApplicationInsights", // (replace the following value with your AI resource's instrumentation key) "instrumentationKey": "XXXXXXXXXXXXXXXXXXXXXX", "filters": [ { "type": "metadata", "metadata": "metric", "include": "ProviderName == mystatefulservice && EventName == ProcessedCountMetric", "operationProperty": "operation", "elapsedMilliSecondsProperty": "elapsedMilliSeconds", "recordCountProperty": "recordCount" } ] } ], "schemaVersion": "2016-08-11" }
In ServiceEventSource.cs
[Event(ProcessedCountMetricEventId, Level = EventLevel.Informational)]
public void ProcessedCountMetric(string operation, long elapsedMilliSeconds, int recordCount)
{
if (IsEnabled())
WriteEvent(ProcessedCountMetricEventId, operation, elapsedMilliSeconds, recordCount);
}
EDIT Adding diagnostics pipeline code from "Program.cs in fabric stateful service
using (var diagnosticsPipeline =
ServiceFabricDiagnosticPipelineFactory.CreatePipeline($"{ServiceFabricGlobalConstants.AppName}-mystatefulservice-DiagnosticsPipeline")
)
{
ServiceRuntime.RegisterServiceAsync("mystatefulserviceType",
context => new mystatefulservice(context)).GetAwaiter().GetResult();
ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id,
typeof(mystatefulservice).Name);
// Prevents this host process from terminating so services keep running.
Thread.Sleep(Timeout.Infinite);
}