Is there a solution if I have lost Azure Functions apps logs?

Dewa Tsukasa 40 Reputation points
2024-12-02T05:22:12.8733333+00:00

Hello Everyone.

I am using a BI tool to check Azure Functions apps logs, but am having problems with some data being missing.

I followed the instructions on the official page

https://learn.microsoft.com/en-us/troubleshoot/azure/azure-functions/monitoring/functions-monitoring-appinsightslogs#logs-are-missing-or-partial

and was told that I could adjust it in host.json, so I entered the following information:

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": false
      },
      "enableLiveMetricsFilters": true
    },
    "logLevel": {
      "default": "Warning",
      "Function.Function1.User": "Information",
      "Function.Function2.User": "Information",
      "Function.Function3.User": "Information",
      "Host.Results": "Information"
    }
  },
  "concurrency": {
    "dynamicConcurrencyEnabled": true,
    "snapshotPersistenceEnabled": true
  },
  "functionTimeout": "00:00:20"
}

But data was still missing:

union requests,dependencies,pageViews,browserTimings,exceptions,traces
| where timestamp > todatetime("11/27/2024 15:00:00") and timestamp < todatetime("11/28/2024 14:59:59")
| summarize TelemetrySavedPercentage = 100/avg(itemCount), TelemetryDroppedPercentage = 100-100/avg(itemCount) by bin(timestamp, 1h), itemType
| sort by timestamp asc

query_data.csv.txt

The solution I looked into was to set the maxTelemetryItemsPerSecond value in host.json to a large value such as 100 (the default value is 20), but I'm not sure if that really solves the problem.

Please tell me how to solve this problem.

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,396 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,250 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Rahul Podila 805 Reputation points Microsoft Vendor
    2024-12-12T01:52:24.51+00:00

    Hi @Dewa Tsukasa

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here. 

    Setting the maxTelemetryItemsPerSecond value in host.json to a larger value can help in increasing the amount of data that is collected and sent to Application Insights. However, it may not solve the problem of missing data completely.

    There could be other reasons why data is missing in the logs. One reason could be that the logs are not being generated due to a configuration issue. Another reason could be that the logs are being generated, but are not being sent to Application Insights due to a connectivity issue.

    To troubleshoot this issue, you can try the following steps:

    Check if the logs are being generated in the first place. You can do this by checking the logs in the Azure portal or by using the Azure Functions Core Tools.

    Check if the logs are being sent to Application Insights. You can do this by checking the Application Insights logs in the Azure portal or by using the Application Insights API.

    Check if there are any configuration issues with the Azure Functions app or the BI tool that you are using. You can do this by reviewing the configuration settings and making sure that they are correct.

    Check if there are any connectivity issues between the Azure Functions app and Application Insights. You can check the network settings and make sure that they are correct. You can also try pinging the Application Insights endpoint to see if there are any connectivity issues.

    If you are still facing issues with missing data in the logs, you can try reaching out to Microsoft support for further assistance.

    If you have any further queries, do let us know.

    1 person found this answer helpful.

  2. Pinaki Ghatak 5,310 Reputation points Microsoft Employee
    2024-12-03T09:53:54.1+00:00

    Hi @Dewa Tsukasa

    Before adjusting the maxTelemetryItemsPerSecond value, I recommend checking a few things:

    1. Make sure that the logs you're looking for are within the retention period of your Application Insights instance. By default, logs are retained for 90 days, but this can be changed in the Application Insights settings.
    2. Check that the logs you're looking for are being sent to the correct Application Insights instance. You can check this by looking at the instrumentationKey value in your local.settings.json file or in the Application Insights settings.
    3. Verify that the logs you're looking for are being generated by your Azure Functions app. You can do this by checking the code for your app and making sure that logging statements are being used appropriately.

    If you've checked these things and are still experiencing missing logs, you can try adjusting the maxTelemetryItemsPerSecond value in the host.json file. However, keep in mind that increasing this value can increase the cost of your Application Insights instance.

    I hope this helps.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.