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

Agent doesn't detect connectionString with configuration file (applicationinsights.json) in default location (same directory as the agent) #3354

Closed
heyjustyn opened this issue Oct 20, 2023 · 4 comments

Comments

@heyjustyn
Copy link

Expected behavior

When enabling Application Insights Java Agent (3.4.17) in Spring Boot (2.7.17) via Docker entry point, it should detect the configuration file (/opt/applicationInsightsAgent/applicationinsights.json) located in the same directory as the agent (/opt/applicationInsightsAgent/applicationinsights-agent.jar).

Below is an example of my applicationinsights.json

{
  "connectionString": "${file:/etc/config/azure.application-insights.connection-string}",
  "role": {
    "name": "redacted"
  },
  "sampling": {
    "percentage": 100
  },
  "instrumentation": {
    "logging": {
      "level": "ALL"
    }
  },
  "preview": {
    "sampling": {
      "overrides": [
        {
          "telemetryType": "request",
          "attributes": [
            {
              "key": "http.url",
              "value": "http[s]{0,1}://[^/]+/actuator/health.*",
              "matchType": "regexp"
            }
          ],
          "percentage": 0
        }
      ]
    }
  }
}

This setup was working in Application Insights Java Agent 3.4.13.

Actual behavior

Application Insights Java Agent throws an the error No connection string provided.

If I define the environment variable APPLICATIONINSIGHTS_CONFIGURATION_FILE with the value /opt/applicationInsightsAgent/applicationinsights.json, Application Insights Java Agent loads without any error.

Here's evidence that the agent and configuration file are in the same directory of the container running within AKS.

[root@redacted-66895b5f76-jfdh8 /]# ls -la /opt/applicationInsightsAgent/
total 39768
drwxr-xr-x 1 root root     4096 Oct 20 00:36 .
drwxr-xr-x 1 root root     4096 Jan  1  1970 ..
-rw-r--r-- 1 root root 40703707 Jan  1  1970 applicationinsights-agent.jar
-rw-r--r-- 0 root root      786 Oct 20 00:36 applicationinsights.json  

To Reproduce

Submitting a PR with an example reproducing the issue in this repository would make it easier for the Application Insight maintainers to help you. Before doing this, you have to fork this repository.

System information

Please provide the following information:

  • SDK Version: 3.14.17
  • OS type and version: RHEL UBI 8.6
  • Application Server type and version (if applicable):
  • Using spring-boot? yes
  • Additional relevant libraries (with version, if applicable):
    • Running on AKS with Kubernetes version 1.26.x
    • Image is built using jib

Logs

Turn on SDK logs and attach/paste them to the issue. If using an application server, also attach any relevant server logs.

Be sure to remove any private information from the logs before posting!

NOTE: Picked up JDK_JAVA_OPTIONS: -XX:+PrintFlagsFinal -XX:+PrintCommandLineFlags -XshowSettings:vm -XX:+AlwaysPreTouch -Xms512m -Xmx512m -XX:MaxMetaspaceSize=180m -XX:InitialCodeCacheSize=32m -XX:ReservedCodeCacheSize=32m -XX:MaxDirectMemorySize=10m

-XX:+AlwaysPreTouch -XX:CompressedClassSpaceSize=180355072 -XX:InitialCodeCacheSize=33554432 -XX:InitialHeapSize=536870912 -XX:MaxDirectMemorySize=10485760 -XX:MaxHeapSize=536870912 -XX:MaxMetaspaceSize=188743680 -XX:+PrintCommandLineFlags -XX:+PrintFlagsFinal -XX:ReservedCodeCacheSize=33554432 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseSerialGC 

2023-10-19 23:34:12.584Z ERROR c.m.applicationinsights.agent - 
*************************
Application Insights Java Agent 3.4.17 startup failed (PID 1)
*************************

Description:
No connection string provided

Action:
Please provide connection string.
23:34:13.616 [Thread-0] DEBUG org.springframework.boot.devtools.restart.classloader.RestartClassLoader - Created RestartClassLoader org.springframework.boot.devtools.restart.classloader.RestartClassLoader@5986a588

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::               (v2.7.17)

2023-10-19T23:34:15,595Z [restartedMain] INFO  com.redacted.ManagementApplication - Starting ManagementApplication using Java 11.0.19 on redacted-6b58bbc755-w965m with PID 1 (/app/classes started by root in /)
2023-10-19T23:34:15,596Z [restartedMain] DEBUG com.redacted.ManagementApplication - Running with Spring Boot v2.7.17, Spring v5.3.30
2023-10-19T23:34:15,596Z [restartedMain] INFO  com.redacted.ManagementApplication - The following 1 profile is active: "k8s"

Screenshots

If applicable, add screenshots to help explain your problem.

@heyams
Copy link
Contributor

heyams commented Oct 20, 2023

@heyjustyn we have a fix in the next release. In the meantime, please keep using the env var. Thanks for reporting.

@heyams
Copy link
Contributor

heyams commented Oct 23, 2023

@heyjustyn can you turn on DEBUG self-diagnostic logging level and share the applicationinsights.log with me?
We did release this fix in 3.4.17.

@heyams
Copy link
Contributor

heyams commented Oct 24, 2023

@heyjustyn can you let me know at your earliest? I am working on a new release this week, and I want to include a fix if this is a bug. Thanks.

Are you using docker to deploy your app to AKS on the azure cloud? It will be helpful if you can provide a repro app.

@heyjustyn
Copy link
Author

@heyams I was unable to replicate this issue when trying to collect the requested logs. We can close this issue. Thanks for looking into it.

@heyjustyn heyjustyn closed this as not planned Won't fix, can't repro, duplicate, stale Oct 24, 2023
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

2 participants