Comments (10)
@tamasvincze i will try it myself and let you know.
from applicationinsights-java.
@tamasvincze APPLICATIONINSIGHTS_CONFIGURATION_CONTENT
has higher precedence over the json config. that is why when this is present and you only set connection string in it, nothing gets applied.
APPLICATIONINSIGHTS_CONFIGURATION_CONTENT
is equivalent to the json config. For connection string, you can use this env var called APPLICATIONINSIGHTS_CONNECTION_STRING
or specify it in the json config.
It's great to hear that it's working for you. "Loaded Class Count" can't be filtered out. Please let me know if i can close this issue.
from applicationinsights-java.
@tamasvincze your config looks good to me. it didn't work probably because config didn't get picked up.
Since you enabled App Insights Java programmatically, the configuration file will be read from the classpath ((src/main/resources, src/test/resources). or use system property applicationinsights.runtime-attach.configuration.classpath.file
to specify the json config file path.
from applicationinsights-java.
@tamasvincze we GA sampling overrides since 3.5.0 and the latest is 3.5.1 GA.
from applicationinsights-java.
Hey @heyams, thanks for the responses.
My applicationinsights.json file is on the classpath: C:\Dev\redacted-app\src\main\resources\applicationinsights.json
I upgraded to 3.5.1:
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-core</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-runtime-attach</artifactId>
<version>3.5.1</version>
</dependency>
My current config file (on the same location:
{
"sampling": {
"requestsPerSecond": 0.5
},
"preview": {
"sampling": {
"requestsPerSecond": 0.5,
"overrides": [
{
"telemetryType": "dependency",
"percentage": 0
}
]
}
},
"processors": [
{
"type": "metric-filter",
"exclude": {
"matchType": "strict",
"metricNames": [
"process_cpu_usage",
"log4j2_events",
"jvm_threads_states",
"executor_pool_core",
"executor_pool_max",
"jvm_gc_overhead",
"% Of Max Heap Memory Used",
"Loaded Class Count"
]
}
}
]
}
In the log I see the newest version being used:
2024-03-13 17:46:52.829Z INFO c.m.applicationinsights.agent - Application Insights Java Agent 3.5.1 started successfully (PID 32080, JVM running for 5.752 s)
However on the azure portal, I still see the event that should have been excluded:
from applicationinsights-java.
please try this instead without preview for sampling:
{
"sampling": {
"requestsPerSecond": 0.5,
"overrides": [
{
"telemetryType": "dependency",
"percentage": 0
}
]
},
"preview": {
"processors": [
{
"type": "metric-filter",
"exclude": {
"matchType": "strict",
"metricNames": [
"process_cpu_usage",
"log4j2_events",
"jvm_threads_states",
"executor_pool_core",
"executor_pool_max",
"jvm_gc_overhead",
"% Of Max Heap Memory Used",
"Loaded Class Count"
]
}
}
]
}
}
if you set the self-diagnostics log to debug level, it should output your json config. that is one way to verify that your config gets picked up.
from applicationinsights-java.
I'm added selfDiagnostics to the json:
{
"sampling": {
"requestsPerSecond": 0.5,
"overrides": [
{
"telemetryType": "dependency",
"percentage": 0
}
]
},
"preview": {
"processors": [
{
"type": "metric-filter",
"exclude": {
"matchType": "strict",
"metricNames": [
"process_cpu_usage",
"log4j2_events",
"jvm_threads_states",
"executor_pool_core",
"executor_pool_max",
"jvm_gc_overhead",
"% Of Max Heap Memory Used",
"Loaded Class Count"
]
}
}
]
},
"selfDiagnostics": {
"destination": "file+console",
"level": "DEBUG",
"file": {
"path": "applicationinsights.log",
"maxSizeMb": 5,
"maxHistory": 1
}
}
}
The applicationinsights.log in the root of my project does not show any debug level info:
2024-03-13 18:09:31.441Z WARN c.a.c.h.netty.implementation.Utility - The following Netty dependencies have versions that do not match the versions specified in the azure-core-http-netty pom.xml file. This may result in unexpected behavior. If your application runs without issue this message can be ignored, otherwise please update the Netty dependencies to match the versions specified in the pom.xml file. Versions found in runtime: 'io.netty:netty-common' version not found (expected: 4.1.101.Final),'io.netty:netty-handler' version not found (expected: 4.1.101.Final),'io.netty:netty-handler-proxy' version not found (expected: 4.1.101.Final),'io.netty:netty-buffer' version not found (expected: 4.1.101.Final),'io.netty:netty-codec' version not found (expected: 4.1.101.Final),'io.netty:netty-codec-http' version not found (expected: 4.1.101.Final),'io.netty:netty-codec-http2' version not found (expected: 4.1.101.Final)
2024-03-13 18:09:33.742Z INFO c.m.applicationinsights.agent - Application Insights Java Agent 3.5.1 started successfully (PID 20072, JVM running for 7.776 s)
2024-03-13 18:09:33.745Z INFO c.m.applicationinsights.agent - Java version: 17.0.10, vendor: Oracle Corporation, home: C:\Program Files\Java\jdk-17.0.10
However my application is logging out all properties through Spring's ConfigurableEnvironment, and I see this printed:
Mar 13 2024 18:09:48 main INFO redacted.app.PropertySourceLogger [] - applicationinsights.internal.runtime.attached.json={ "sampling": { "requestsPerSecond": 0.5, "overrides": [ { "telemetryType": "dependency", "percentage": 0 } ] }, "preview": { "processors": [ { "type": "metric-filter", "exclude": { "matchType": "strict", "metricNames": [ "process_cpu_usage", "log4j2_events", "jvm_threads_states", "executor_pool_core", "executor_pool_max", "jvm_gc_overhead", "% Of Max Heap Memory Used", "Loaded Class Count" ] } } ] }, "selfDiagnostics": { "destination": "file+console", "level": "DEBUG", "file": { "path": "applicationinsights.log", "maxSizeMb": 5, "maxHistory": 1 } }}
Sadly, I still see the metrics being sent to azure:
from applicationinsights-java.
@tamasvincze Here is my sample for metric-filter.
it works for me. i used the latest 3.5.1 GA.
We reserve certain default metrics not to be filtered out intentionally. You should be able to filter out any other custom metrics though.
In my applicationinsights.log, it showed clearly that json config was applied successfully:
DEBUG c.m.a.a.i.c.ConfigurationBuilder - configuration: {"connectionString":
from applicationinsights-java.
Your configuration made me try something.
Here is my current config:
{
"sampling": {
"requestsPerSecond": 0.5,
"overrides": [
{
"telemetryType": "dependency",
"percentage": 0
}
]
},
"selfDiagnostics": {
"destination": "file+console",
"level": "DEBUG",
"file": {
"path": "applicationinsights.log",
"maxSizeMb": 5,
"maxHistory": 1
}
},
"instrumentation": {
"logging": {
"enabled": "true"
}
},
"preview": {
"processors": [
{
"type": "metric-filter",
"exclude": {
"matchType": "strict",
"metricNames": [
"process_cpu_usage",
"log4j2_events",
"jvm_threads_states",
"executor_pool_core",
"executor_pool_max",
"jvm_gc_overhead",
"% Of Max Heap Memory Used",
"Loaded Class Count"
]
}
}
]
}
}
And for my app, I have 2 environmental variables exported (in the IDEA runconfig):
APPLICATIONINSIGHTS_ROLE_NAME=test-vinctam12
APPLICATIONINSIGHTS_CONFIGURATION_CONTENT={"connectionString":"InstrumentationKey=REDACTED;IngestionEndpoint=https://northeurope-0.in.applicationinsights.azure.com/;LiveEndpoint=https://northeurope.livediagnostics.monitor.azure.com/"}
I don't see any DEBUG logs from the agent.
On Azure Portal I see the excluded metrics:
However if I delete the env vars and use role configuration through the json, like this:
{
"connectionString": "InstrumentationKey=REDACTED;IngestionEndpoint=https://northeurope-0.in.applicationinsights.azure.com/;LiveEndpoint=https://northeurope.livediagnostics.monitor.azure.com/",
"role": {
"name": "test-vinctam13",
"instance": "instance1"
},
"sampling": {
"requestsPerSecond": 0.5,
"overrides": [
{
"telemetryType": "dependency",
"percentage": 0
}
]
},
"selfDiagnostics": {
"destination": "file+console",
"level": "DEBUG",
"file": {
"path": "applicationinsights.log",
"maxSizeMb": 5,
"maxHistory": 1
}
},
"instrumentation": {
"logging": {
"enabled": "true"
}
},
"preview": {
"processors": [
{
"type": "metric-filter",
"exclude": {
"matchType": "strict",
"metricNames": [
"process_cpu_usage",
"log4j2_events",
"jvm_threads_states",
"executor_pool_core",
"executor_pool_max",
"jvm_gc_overhead",
"% Of Max Heap Memory Used",
"Loaded Class Count"
]
}
}
]
}
}
Now I see DEBUG logs, like:
2024-03-13 20:33:49.724Z DEBUG c.m.a.a.i.c.ConfigurationBuilder - read system property: applicationinsights.internal.runtime.attached.json=...
2024-03-13 20:33:49.728Z DEBUG c.m.a.a.i.c.ConfigurationBuilder - configuration: {"connectionString":"InstrumentationKey=...
And now I only see one of the excluded metrics:
Can you try exporting the rolename and connection string instead of having them in the json?
from applicationinsights-java.
Oh you're right, I've been using the wrong env var.
Thanks for the help!
I'll close the issue :)
from applicationinsights-java.
Related Issues (20)
- Is there a way to sample overrides Servicebus requests? HOT 18
- Workflow failed: OWASP dependency check (daily) (#532) HOT 1
- Workflow failed: OWASP dependency check (daily) (#542)
- Workflow failed: OWASP dependency check (daily) (#547)
- Sampling based on dependency result HOT 2
- OpenTelemetry support for MQTT pub/sub with Application Insights Java agent HOT 1
- Ignore newline and carriage return in the connection string file
- Sampling override based on request processing time? HOT 7
- Support for OTEL Synchronous Gauge HOT 3
- ignore InProc sampling dependencies
- Sampling override with http.response.status_code doesn't work HOT 6
- MySql dependency tree not available with applicationinsights-agent-3.5.1 HOT 5
- Question: How to turn off instrumentation of just Azure Service Bus
- Workflow failed: OWASP dependency check (daily) (#585)
- Custom Availability telemetry not working HOT 2
- Azure ServiceBus dependency tree not available with applicationinsights-agent-3.5.2 HOT 2
- Can't load log handler "com.microsoft.applicationinsights.TelemetryClient" - AI 3.5.2 in Java HOT 2
- SFTP dependency tree not available with applicationinsights-agent-3.5.2 HOT 5
- APPLICATIONINSIGHTS_CONNECTION_STRING does not work in 3.5.x, works in 3.4.x HOT 9
- Connection String with `ApplicationId` crashes SDK 3.4.19 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from applicationinsights-java.