ApplicationInsights-Java icon indicating copy to clipboard operation
ApplicationInsights-Java copied to clipboard

Adding per-worker metrics reported to JMX in applicationinsights.json for App Insights

Open MonikaReddy-MSFT opened this issue 1 year ago • 1 comments

Customer opened a question on Microsoft Q&A, but opening this issue in Github as suggested by PG.

I have a Flink pipeline and if possible I would like to report the metrics to JMX so that I can use the applicationinsights.json to report them to Application Insights. However, when Flink metrics are reported to JMX they have object names with generated IDs like below:

org.apache.flink.taskmanager.job.task.operator.currentOutputWatermark:host=,job_id=<ID>,job_name=Flink_metrics_test,operator_id=<ID>,operator_name=Sink-_logger-sink,subtask_index=0,task_attempt_id=<ID>,task_attempt_num=0,task_id=<ID>,task_name=Source-Custom_Source-time-now-stream-counter-map-_Sink-_logger-sink,tm_id=<ID> Is it still possible to configure them as JMX metrics? Related documentation: https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-jmx-metrics-configuration#configuration-example

MonikaReddy-MSFT avatar Mar 08 '24 17:03 MonikaReddy-MSFT

@MonikaReddy-MSFT In the JMX metrics configuration, you can use * to represent a generated ID.

It should be something like that:

{
  "jmxMetrics": [
    {
      "name": "name",
      "objectName": "org.apache.flink.taskmanager.job.task.operator.currentOutputWatermark:host=*,job_id=*,job_name=Flink_metrics_test,operator_id=*,operator_name=Sink-_logger-sink,subtask_index=0,task_attempt_id=<ID>,task_attempt_num=0,task_id=*,task_name=Source-_Custom_Source_-_time-now-stream_-_counter-map_-_Sink-_logger-sink,tm_id=*",
      "attribute": "attribute"
    }
}

jeanbisutti avatar Mar 08 '24 17:03 jeanbisutti

@jeanbisutti - Thanks for the response.

Customer responded back saying - The documentation needs updated because it made no mention or example of that. Additionally, are these able to replace values in general (i.e. does it work like Regex pattern matching, so I could use a pattern like "objectName": "*.currentOutputWatermark",). T

MonikaReddy-MSFT avatar Mar 18 '24 17:03 MonikaReddy-MSFT

@MonikaReddy-MSFT

See https://docs.oracle.com/javase/8/docs/api/javax/management/ObjectName.html: "The asterisk matches any sequence of zero or more characters".

Microsoft documentation with wildcard: https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-standalone-config#java-management-extensions-metrics

jeanbisutti avatar Apr 02 '24 12:04 jeanbisutti

@jeanbisutti that page has some great information; I think a great solution would be to add links in the documentation so that it can be found easier. Here is a PR: https://github.com/MicrosoftDocs/azure-docs/pull/121864 to fix https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-jmx-metrics-configuration#configuration-example

ivanthewebber avatar Apr 22 '24 23:04 ivanthewebber