ApplicationInsights-dotnet
ApplicationInsights-dotnet copied to clipboard
Is it possible to send ApplicationInsightsTelemetry to multiple ingestion endpoints?
I am looking for ways to send (Trace, Metrics, RemoteDependency) telemetry data to multiple application insight endpoints from the same azure function.
Its not clear what you are trying to achieve. Could you explain a bit more?
Sure thing. AFAIK, currently there is only one setting 'APPLICATIONINSIGHTS_CONNECTION_STRING' that can be set to send ApplicationInsightTelemetry data to azure app insights. I would like to set two connection strings instead of one. I would like to send ApplicationInsightTelemetry data to two different places. I am wondering whether it is possible?
If your intention is to send same telemetry to more than one ikey, then its possible with the use of TelemetrySinks concept in this SDK. There are no e2e examples for it here, and also I'm not sure if it'll work inside Azure functions, as this requires modififying TelemetryProcessor chains, which can be tricky inside Functions.
Also sending same data to 2 ikeys will double your bill. If you still want to do this @TimothyMothra Do you have samples for using sinks to add 2 AppInsight channel with 2 ikeys?
Yes please, it is exactly what I would like to achieve. Any guidance would be great.
I was able to achieve partial success with https://github.com/serilog/serilog-sinks-applicationinsights/. However, data were missing RemoteDependency and Metrics, it only had the Traces. My understanding is that it is related to initializers/processors mismatch between TelemetryConfiguration.Active and TelemetryConfiguration.CreateDefault().
It is not clear how I can make config from TelemetryConfiguration.CreateDefault() similar to TelemetryConfiguration.Active.
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.AddLogging(loggingBuilder =>
{
var config1 = TelemetryConfiguration.CreateDefault();
config1.InstrumentationKey = "...";
var config2 = TelemetryConfiguration.CreateDefault();
config2.InstrumentationKey = "...";
var logger = new LoggerConfiguration()
.WriteTo.ApplicationInsights(config1, TelemetryConverter.Traces)
.WriteTo.ApplicationInsights(config2, TelemetryConverter.Traces)
.CreateLogger();
loggingBuilder.AddSerilog(logger);
});
}
But if there is any solution that does not rely on serilog, would be even better.
In case anyone has a similar question, I was able to get it working with a custom telemetry channel. Thank you for the TelemetrySinker direction.
I'm trying to do the same thing. What does that custom telemetry channel of yours do? One would think you just register an additional TelemetrySink
with one of the provided telemetry channel implementations (either InMemoryChannel
or ServerTelemetryChannel
) and then perhaps call the TelemetryProcessorChainBuilder.Build()
as mentioned in #957 but I had no luck with that approach so far.
This worked for me for my node.js application: https://docs.microsoft.com/en-us/azure/azure-monitor/app/nodejs#use-multiple-instrumentation-keys
let appInsights = require("applicationinsights");
// configure auto-collection under one ikey appInsights.setup("ikey-A").start();
// track some events manually under another ikey let otherClient = new appInsights.TelemetryClient("ikey-B"); otherClient.trackEvent({name: "my custom event"});
I've kind of the same question. I've 2 applications both with their own instrumentation key but I would like to view the telemetry traces as if there was only 1 instrumentation key (the flow over applications). Now I could reuse the key but that would result in the forced use of a single key for every application in the whole organization. Alternative I could try to send data to a shared secondary instrumentation key (to "opt-in" on the flow over the applications) but it feels a bit like a work around. Isn't there any way to view data from multiple instrumentation keys from a single perspectvie.
This issue is stale because it has been open 300 days with no activity. Remove stale label or this will be closed in 7 days. Commenting will instruct the bot to automatically remove the label.
Hello! Do we have a working example for this? I tried the custom telemetry channel option but without luck.