serilog-sinks-applicationinsights
serilog-sinks-applicationinsights copied to clipboard
Live Metrics Stream is not working with serilog-sinks-applicationinsights
Live Metrics Stream is not working with serilog-sinks-applicationinsights. If i am not wrong it needs to install Microsoft.ApplicationInsights.AspNetCore 2.2.0 But serilog-sinks-applicationinsights is working without Microsoft.ApplicationInsights.AspNetCore So is there any way to solve this issue and run Live Metrics Stream on azure portal ?
would be nice to have support for this feature
I don't mind adding live metrics stream here.
Are there any updates about this issue? I'm currently not able to use Live Metrics with serilog sinks using the settings provided on the documentation. Is there an example on how to make it work, or are we waiting for a fix?
You would normally have live metric stream configured upstream, for instance asp.net core adds it in by default. We could add a helper method to enable it from this sink, it's a matter of adding it to telemetry configuration with something like this:
TelemetryProcessorChainBuilder builder = TelemetryConfiguration.Active.TelemetryProcessorChainBuilder;
QuickPulseTelemetryProcessor quickPulseProcessor = null;
builder.Use((next) =>
{
quickPulseProcessor = new QuickPulseTelemetryProcessor(next);
return quickPulseProcessor;
});
builder.Build();
var quickPulse = new QuickPulseTelemetryModule();
quickPulse.Initialize(TelemetryConfiguration.Active);
quickPulse.RegisterTelemetryProcessor(quickPulseProcessor);
Note that live stream (aka Quick Pulse) requires a reference to Microsoft.ApplicationInsights.PerfCounterCollector nuget package. You can add live stream either by using the sample above or raising a PR to add this to the library.
@aloneguid Should I be able to add your code from above right below the serilog initialization? like this? ` public static int Main(string[] args) { Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(Configuration) .CreateLogger();
// update logger to include live metric stream
TelemetryProcessorChainBuilder builder = TelemetryConfiguration.Active.TelemetryProcessorChainBuilder;
QuickPulseTelemetryProcessor quickPulseProcessor = null;
builder.Use((next) =>
{
quickPulseProcessor = new QuickPulseTelemetryProcessor(next);
return quickPulseProcessor;
});
builder.Build();
var quickPulse = new QuickPulseTelemetryModule();
quickPulse.Initialize(TelemetryConfiguration.Active);
quickPulse.RegisterTelemetryProcessor(quickPulseProcessor);
`
does not seem to work for me :(
This is affecting us as well.
Is there any update regarding live metrics with Serilog?
I would like this updated as well. I pulled the code and I believe the telemtryClient.Track method doesn't call the necessary pieces to make it available on live metrics. But if the code would call telemetryClient.TrackTrace (or TrackEvent) then it should pop up on the live metrics. In my code, if I call those functions directly then I will see my messages in the live metrics.
.NET Core doesn't have the ability to call .Track directly as that looks to be only available in the .NET 4.5 version and not the standard version. Going to try and write some code to test this theory when I have some free time.
Bumping this. Having access to live sample-telemetry is pretty vital to my team.
Is anyone able to help out by proposing a solution and then working through a pull request? We're low on maintainer bandwidth so it's unlikely any of the maintainers will design/implement this in the short term, but a well-thought-out implementation would make a very useful contribution. Thanks!
It did work for me after using this piece of code, the serilog Logger has to be created before this. Also make sure the appinsights.config has the required
<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector" />
services.AddApplicationInsightsTelemetry(options=>
{
options.EnableActiveTelemetryConfigurationSetup = true;
options.InstrumentationKey = "";
options.EnableQuickPulseMetricStream = true;
});