Home > Enterprise >  How to save copy of Application Insights telemetry into a file locally (on the machine which produce
How to save copy of Application Insights telemetry into a file locally (on the machine which produce

Time:11-13

I have an ASP .NET CORE app with application insights installed. How do I configure it to save a copy of telemetry into a local file (in addition to sending to cloud)?

I'm not looking for Continuous Export feature (AFAIU, it has to go through portal first). I'm looking for a scenario like "save 100% of telemetry locally, but send a sampled subset to Azure".

CodePudding user response:

One way - add a TelemetryProcessor which saves a telemetry item locally and calls this.Next.Process(item).

Alternatively you can achieve the same with TelemetrySink.

The first approach is probably easier.

To save them in text representation you can use Microsoft.ApplicationInsights.Extensibility.Implementation.JsonSerializer.Serialize (takes IEnumerable<ITelemetry> telemetryItems). This will return a byte array. I guess calling Deserialize on that byte array should give you string representation of json.

  • Related