# Is it possible to pull in String Value with JMX Extensions?

**URL:** <https://community.dynatrace.com/t/is-it-possible-to-pull-in-string-value-with-jmx-extensions/38930>\
**Category:** Extensions\
**Tags:** kafka, dynatrace-managed, jmx, extensions, dynatrace-api\
**Created:** [March 21, 2023, 5:01pm UTC](https://community.dynatrace.com/t/is-it-possible-to-pull-in-string-value-with-jmx-extensions/38930 "2023-03-21T17:01:23Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![sivart\_89](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@sivart\_89](https://community.dynatrace.com/u/sivart_89)\
**Post date:** [March 21, 2023, 5:01pm UTC](https://community.dynatrace.com/t/is-it-possible-to-pull-in-string-value-with-jmx-extensions/38930/1 "2023-03-21T17:01:23Z")

</div>

I’ve created a JMX extension for some Kafka metrics but now want to add the connector status metric. According to the confluent link below the connector status can be running, paused, or stopped. Per the JMX Dynatrace documentation, the attributes available in the list are only the numeric ones.

To see other attributes, for example, attributes of the String type, select Include non-numeric attributes. Note that selected attributes must be parsable to double, or boolean type. Otherwise, Dynatrace OneAgent will not collect any data from such a metric. I’m led to believe that the status metric cannot be captured and have seen the same when adding that metric to the JMX extension. Has anyone been able to pull in strings of text such as this status metric?

An alternative way we are thinking of is hitting an API to get the value and then ingesting that into Dynatrace as a metric. However, just want to be sure I’m not missing something with the JMX extension route.

> **[Monitor Kafka Connect and Connectors for Confluent Platform | Confluent...](https://docs.confluent.io/platform/current/connect/monitoring.html)**

Dynatrace JMX doc

> **[JMX extensions](https://docs.dynatrace.com/docs/ingest-from/extend-dynatrace/extend-metrics/ingestion-methods/jmx-extensions)**
>
> Learn how to extend Dynatrace monitoring to include applications you've instrumented with JMX.

---

<div class="post-metadata">

**Author:** ![Mike\_L](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mike_l/32/11717_2.png) [@Mike\_L](https://community.dynatrace.com/u/Mike_L)\
**Post date:** [March 21, 2023, 5:05pm UTC](https://community.dynatrace.com/t/is-it-possible-to-pull-in-string-value-with-jmx-extensions/38930/2 "2023-03-21T17:05:58Z")

</div>

The new JMX extensions in Extension Framework 2.0 will be able to handle this use case. It’s currently wrapping up development and will be out in 2 or so months if all goes well. One of the first extensions we are bringing out together with the data source is actually an improved version of the Kafka extension.&nbsp;[@victor\_balbuena](https://community.dynatrace.com/user/3978), is connector status one of the new metrics you added?

---

<div class="post-metadata">

**Author:** ![victor\_balbuena](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/victor_balbuena/32/9773_2.png) [@victor\_balbuena](https://community.dynatrace.com/u/victor_balbuena)\
**Post date:** [March 22, 2023, 1:01pm UTC](https://community.dynatrace.com/t/is-it-possible-to-pull-in-string-value-with-jmx-extensions/38930/3 "2023-03-22T13:01:28Z")

</div>

The connector status is not one of the metrics defined to be captured by the first version of the Kafka extension in EF2.

---

<div class="post-metadata">

**Author:** ![sivart\_89](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@sivart\_89](https://community.dynatrace.com/u/sivart_89)\
**Post date:** [March 22, 2023, 11:11pm UTC](https://community.dynatrace.com/t/is-it-possible-to-pull-in-string-value-with-jmx-extensions/38930/4 "2023-03-22T23:11:35Z")

</div>

Thank you&nbsp;[@victor\_balbuena](https://community.dynatrace.com/user/3978)&nbsp; and&nbsp;[@Mike\_L](https://community.dynatrace.com/user/11520). We hope the status is eventually incorporated into the kafka 2.0 extension but in the meantime I can utilize the new jmx framework once available.

---

<div class="post-metadata">

**Author:** ![guruprasadv](https://avatars.discourse-cdn.com/v4/letter/g/eada6e/32.png) [@guruprasadv](https://community.dynatrace.com/u/guruprasadv)\
**Post date:** [May 1, 2023, 7:20pm UTC](https://community.dynatrace.com/t/is-it-possible-to-pull-in-string-value-with-jmx-extensions/38930/5 "2023-05-01T19:20:53Z")

</div>

Do we know when this kafka connector status metrics will be available ?

---

<div class="post-metadata">

**Author:** ![victor\_balbuena](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/victor_balbuena/32/9773_2.png) [@victor\_balbuena](https://community.dynatrace.com/u/victor_balbuena)\
**Post date:** [May 2, 2023, 6:44am UTC](https://community.dynatrace.com/t/is-it-possible-to-pull-in-string-value-with-jmx-extensions/38930/6 "2023-05-02T06:44:45Z")

</div>

The expected date for release of the new EF2 Kafka extension is on the 9th of May.

---

<div class="post-metadata">

**Author:** ![sivart\_89](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@sivart\_89](https://community.dynatrace.com/u/sivart_89)\
**Post date:** [May 11, 2023, 4:47pm UTC](https://community.dynatrace.com/t/is-it-possible-to-pull-in-string-value-with-jmx-extensions/38930/7 "2023-05-11T16:47:24Z")

</div>

Thanks for the info. Will this be rolled into a cluster upgrade and be mentioned in release notes? Just wondering how we will be aware of this being available.

It’s my understanding that the newer version of the kafka extension will not have the connector status we are looking for BUT we can still create a custom jmx extension to pull out the metric string whereas before EF2 you could not, is that accurate?

---

<div class="post-metadata">

**Author:** ![Mike\_L](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mike_l/32/11717_2.png) [@Mike\_L](https://community.dynatrace.com/u/Mike_L)\
**Post date:** [May 11, 2023, 10:33pm UTC](https://community.dynatrace.com/t/is-it-possible-to-pull-in-string-value-with-jmx-extensions/38930/8 "2023-05-11T22:33:02Z")

</div>

It is now available for download from the Dynatrace hub.

you can indeed also create your own JMX 2.0 extensions starting with 1.265.

---

<div class="post-metadata">

**Author:** ![Stephen1\_Lee](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@Stephen1\_Lee](https://community.dynatrace.com/u/Stephen1_Lee)\
**Post date:** [May 15, 2023, 4:53pm UTC](https://community.dynatrace.com/t/is-it-possible-to-pull-in-string-value-with-jmx-extensions/38930/9 "2023-05-15T16:53:42Z")

</div>

Hi Mike\_L

Could you link in the new documentation for JMX 2.0 for the Dynatrace hub?

---

<div class="post-metadata">

**Author:** ![Mike\_L](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mike_l/32/11717_2.png) [@Mike\_L](https://community.dynatrace.com/u/Mike_L)\
**Post date:** [May 17, 2023, 12:32pm UTC](https://community.dynatrace.com/t/is-it-possible-to-pull-in-string-value-with-jmx-extensions/38930/10 "2023-05-17T12:32:52Z")

</div>

I recommend that you grab one of the new extensions, such as ActiveMQ, which has it in the extension.yaml:&nbsp;[https://www.dynatrace.com/hub/detail/activemq/?filter=all&type=extension#versions](https://www.dynatrace.com/hub/detail/activemq/?filter=all&type=extension#versions)

---

<div class="post-metadata">

**Author:** ![guruprasadv](https://avatars.discourse-cdn.com/v4/letter/g/eada6e/32.png) [@guruprasadv](https://community.dynatrace.com/u/guruprasadv)\
**Post date:** [June 5, 2023, 6:25pm UTC](https://community.dynatrace.com/t/is-it-possible-to-pull-in-string-value-with-jmx-extensions/38930/11 "2023-06-05T18:25:07Z")

</div>

Hi,

We have updated to latest dynatrace version and still kafka connector status does not get populated in dynatrace dataexplorer.

 ![kafkaconnectorstatus.gif](https://global.discourse-cdn.com/dynatrace/original/2X/a/a66e00a9a930f0cfcc30a201846c0e12795bfdda.gif)

---

<div class="post-metadata">

**Author:** ![sivart\_89](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@sivart\_89](https://community.dynatrace.com/u/sivart_89)\
**Post date:** [June 7, 2023, 1:00pm UTC](https://community.dynatrace.com/t/is-it-possible-to-pull-in-string-value-with-jmx-extensions/38930/12 "2023-06-07T13:00:47Z")

</div>

To add onto&nbsp;[@guruprasadv](https://community.dynatrace.com/user/62372)&nbsp;comment, we have updated the OneAgents to the required version for JMX 2.0 but I can’t seem to get the string value to be pulled out for the JMX extension I have created. I looked at (with a dynatrace resource we have) at the ActiveMQ 2.0 extension linked above by&nbsp;[@Mike\_L](https://community.dynatrace.com/user/11520)&nbsp;and we did not see where that extension is pulling out a string value.

I’m hoping someone has a working example of pulling out a string value using 2.0 JMX. Specifically we are looking for the connector status located at the link below.

> **[Connector metrics - Monitor Kafka Connect and Connectors for Confluent Platform...](https://docs.confluent.io/platform/current/connect/monitoring.html#connector-metrics)**
>
> Connect reports a variety of metrics through Java Management Extensions (JMX). Connect can be configured to report stats using additional pluggable stats reporters using the metric.reporters configuration option. The following sections provide...

---

<div class="post-metadata">

**Author:** ![victor\_balbuena](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/victor_balbuena/32/9773_2.png) [@victor\_balbuena](https://community.dynatrace.com/u/victor_balbuena)\
**Post date:** [June 7, 2023, 1:08pm UTC](https://community.dynatrace.com/t/is-it-possible-to-pull-in-string-value-with-jmx-extensions/38930/13 "2023-06-07T13:08:34Z")

</div>

As mentioned in my previous comment on this thread, the connector status is not one of the metrics captured by the default Kafka extension. You will have to create an extension of your own. When creating it, take into account that metrics in Dynatrace cannot have a value of a string, which means that I see two possible scenarios you might want to accomplish:

1. Ingest the value of the MBean as a dimension, while keeping the value of the metric constant as it is irrelevant. In this case, you can do something like:

```auto
- subgroup: kafka connector status
  query: kafka.connect:type=connector-metrics,connector=*
  dimensions:
    - key: connector
      value: property:connector
    - key: status
      value: attribute:status
  metrics: 
    - key: com.dynatrace.extension.kafka.status
      type: gauge
      value: const:1

```

Where the dimension is not a&nbsp;property&nbsp;of the MBean, but an&nbsp;attribute&nbsp;instead.

1. Transform the captured string into a number depending on its value. For this, you can just do booleans, i.e. check if the captured string is equal to a value or not. It could look something like this (in this case,&nbsp;paused&nbsp;would also report a 0):

```auto
- subgroup: kafka connector status
  query: kafka.connect:type=connector-metrics,connector=*
  dimensions:
    - key: connector
      value: property:connector
  metrics:
    - key: com.dynatrace.extension.kafka.status
      type: gauge
      value:
        attribute:status
        accessor: equals("running")

```

If you want to do something like running=2, paused=1 and stopped=0, that cannot be done at the moment. As mentioned aboved, it is restricted to a boolean so just 0 and 1.

* * *

I personally don’t see anything else you could do with a string MBean, considering that Dynatrace does not support strings being ingested as the value of the metric.

PD: the dimension for the connector is not necessary, I just added it for more clarity on the example.

* * *

**EDIT: This solution works only for immutable attributes as the value is not updated, just read once.**

---

<div class="post-metadata">

**Author:** ![Mike\_L](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mike_l/32/11717_2.png) [@Mike\_L](https://community.dynatrace.com/u/Mike_L)\
**Post date:** [June 7, 2023, 1:12pm UTC](https://community.dynatrace.com/t/is-it-possible-to-pull-in-string-value-with-jmx-extensions/38930/14 "2023-06-07T13:12:18Z")

</div>

Here is an example:

```css
query: "org.apache.activemq:type=Broker"
queryFilters:
  - field: brokerName
    filter: var:broker_name-filter
  - field: destinationName
    filter: var:queue_name-filter
dimensions:
  - key: broker_name
    value: property:brokerName
  - key: queue_name
    value: property:destinationName
  - key: queue_type
    value: property:destinationType
  - key: product_name
    value: const:ActiveMQ
  - key: driver_version
    value: attribute:DriverVersion
  - key: foo_name
    value:
      attribute: Foo
      accessor: getName()
metrics:
  - key: com.dynatrace.extension.jmx.activemq.queue.const
    type: gauge
    value: const:1

```

---

<div class="post-metadata">

**Author:** ![sivart\_89](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@sivart\_89](https://community.dynatrace.com/u/sivart_89)\
**Post date:** [June 12, 2023, 7:51pm UTC](https://community.dynatrace.com/t/is-it-possible-to-pull-in-string-value-with-jmx-extensions/38930/15 "2023-06-12T19:51:47Z")

</div>

I went with option 1 here. Seems to be working so far. I’ve contacted our app side who work with Kafka and are looking for this metric, to confirm it is showing what they need.
