App Insights JMX Configuration

Somnath Mallick 0 Reputation points
2023-10-05T14:50:51.63+00:00

I am having some trouble configuring my App Insights JSON file. Currently this is the JSON file I am using:

{
  "connectionString":"SOME_URL",
  "role":{
    "name":"A_NAME",
    "instance":"AN_INSTANCE"
  },
  "sampling":{
    "requestsPerSecond":200
  },
  "jmxMetrics":[
    {
      "name":"TEMP - GC Thread Count",
      "objectName":"java.lang:type=GarbageCollector,name=PS MarkSweep",
      "attribute":"LastGcInfo.GcThreadCount"
    },
    {
      "name":"TEMP - GC Collection Count",
      "objectName":"java.lang:type=GarbageCollector,name=PS MarkSweep",
      "attribute":"CollectionCount"
    },
    {
      "name":"TEMP - Thread Count",
      "objectName":"java.lang:type=Threading",
      "attribute":"ThreadCount"
    }
  ],
  "instrumentation":{
    "logging":{
      "level":"INFO"
    },
    "micrometer":{
      "enabled":false
    },
    "jdbc":{
      "masking":{
        "enabled":true
      }
    },
    "kafka":{
      "enabled":true
    }
  },
  "heartbeat":{
    "intervalSeconds":60
  }
}


I got most of these via the documentation. Although, I must it is not very well written.

so when I run it using SpringBoot/Java. I see the following error:

2023-10-05 12:59:18.075Z ERROR c.m.a.a.i.p.AbstractJmxPerformanceCounter - Error while fetching JMX data: 'java.lang.IllegalArgumentException: Cannot find object name 'java.lang:type=GarbageCollector,name=PS MarkSweep''

Can you please tell me if there is an error in the syntax of the JMX section. Thanks in advance.

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,873 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AnuragSingh-MSFT 20,831 Reputation points
    2023-10-11T06:03:40.57+00:00

    Somnath Mallick, thank you for the question.

    Based on the error, it seems that your application (or java packages) being used in your application might be different from what is available in the sample provided in the docs. I would suggest using the following setting in the applicationinsights.json file to review all the object names and attributes available for your application which can be collected:

    {
      "selfDiagnostics": {
        "level": "DEBUG"
      }
    }
    

    For more details, see How do I know what metrics are available to configure? Based on the available object type names, attributes you may have to edit the json file to suit the requirements of your application.

    Hope this helps.

    Please let me know if you have any questions.

    0 comments No comments