Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support configuring log levels/sampling overrides with java app insights agent #731

Open
ejizba opened this issue Oct 5, 2023 · 4 comments

Comments

@ejizba
Copy link
Contributor

ejizba commented Oct 5, 2023

When using the app insights java agent, the only known way to configure log levels is by using sampling overrides as described in these docs. However, it's not possible to add an "applicationinsights.json" file next to the agent jar file because it's stored/shipped with the worker, not the app.

Related IcM (internal link only)

@tdkeeley
Copy link

tdkeeley commented Oct 5, 2023

+1

@kaibocai
Copy link
Member

kaibocai commented Oct 5, 2023

Adding @trask for help on configuring the agent using applicationinsight.json file.

@RohitRanjanMS
Copy link
Member

@heyams was helping me troubleshoot this.
The config file won't work for the agent, and it seems the only way to enable this through the environment variable APPLICATIONINSIGHTS_CONFIGURATION_CONTENT.
Another option is to use workspace transformation to filter out logs.
https://learn.microsoft.com/en-us/azure/azure-monitor/logs/tutorial-workspace-transformations-portal#:~:text=the%20audit%20log.-,Add%20a%20transformation%20to%20the%20table,-Now%20that%20the

@mlanglet
Copy link

I tried using APPLICATIONINSIGHTS_CONFIGURATION_CONTENT but the cloud role name in the logs is still the function app name rather than myapp so I'm doubting that it actually takes effect, it seems like it is still host.json that controls the logging even though the documentation says it will bypass the host when enabling the insights agent.

{
  "connectionString": "${APPLICATIONINSIGHTS_CONNECTION_STRING}",
  "role": {
    "name": "myapp"
  },
  "sampling": {
    "percentage": 100,
    "overrides": [
      {
        "telemetryType": "dependency",
        "percentage": 3
      }
    ]
  },
  "instrumentation": {
    "logging": {
      "level": "DEBUG"
    }
  }
}
{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "initialSamplingPercentage": 3.0,
        "minSamplingPercentage": 1.0,
        "maxSamplingPercentage": 3.0,
        "includedTypes": "Dependency"
      }
    }
  }
}
        {
          name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
          value: appInsightsConnectionString
        }
        {
          name: 'APPLICATIONINSIGHTS_ENABLE_AGENT'
          value: 'true'
        }
        {
          name: 'APPLICATIONINSIGHTS_CONFIGURATION_CONTENT'
          value: loadTextContent('../applicationinsights.json')   
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants