0

I have an ASP.NET Core 5.0 MVC web application and app insights enabled. I am trying to post application insights data to REST API, which I developed using nodejs.

My appsettings.json details are below. Here, API got trigger, but I'm not getting any body content (Insight's data).

Please guide me. Thanks in advance.

{
  "Logging": {
    "ApplicationInsights": {
      "LogLevel": {
        "Default": "Information",
        "Microsoft": "Warning",
        "Microsoft.Hosting.Lifetime": "Information"
      }
    },
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "ApplicationInsights": {
    "InstrumentationKey": "123",
    "TelemetryChannel": {
      "EndpointAddress": "http://localhost:3000/v2/track"
    }
  }
}

enter image description here

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0
  • You won't be able to get the data directly through the application as it will not send the application insights directly to you, but it will save it in the storage account in form of blob storage.

  • What you can do is either get the data directly through the storage account or you can get data from the application insights.

  • If you want to take data from the storage account, you will have to use @azure/storage-blob npm package with node js .

    const container = blobServiceClient.getContainerClient(containerName);
    const blockBlob = container.getBlockBlobClient(blobName); 
      const download = await blockBlob.download(0);
    
  • you can get containername from the portal under containers section of the storage account.

  • Another way would be to run a query in the application insights. This can be achieved by making http requests and the request has to be authenticated by either azure ad token or the access key which is in the portal.

     HTTP GET  https://api.applicationinsights.io/v1/apps/{appId}/query?query={query}
    

Reference: Export telemetry from Application Insights by Anton Fritz

Export data using Query

Mohit Ganorkar
  • 1,917
  • 2
  • 6
  • 11