Skip to content

Add support for cli params/custom label in groovy script #33

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

Closed
jatan28 opened this issue Apr 28, 2021 · 3 comments
Closed

Add support for cli params/custom label in groovy script #33

jatan28 opened this issue Apr 28, 2021 · 3 comments
Assignees

Comments

@jatan28
Copy link

jatan28 commented Apr 28, 2021

Currently, when you are trying to monitor the JVM metrics(using JMX receiver) for multiple processes/applications on a single host, it is impossible to differentiate which process the metrics originated from.
Having support for adding custom labels to the groovy script through command line params or a config would provide the required flexibility to re-use the same groovy script to solve the problem stated above and also give end users the option to add more labels.
Example

 jmx:
 jmx/service1:
  jar_path: /home/opentelemetry-java-contrib-jmx-metrics-0.0.1-SNAPSHOT.jar
  endpoint: localhost:9050
  target_system: jvm
  custom_lables: 
     <label-key>: <label-value>
  collection_interval: 10s

OR

 jmx:
 jmx/service1:
  jar_path: /home/opentelemetry-java-contrib-jmx-metrics-0.0.1-SNAPSHOT.jar
  endpoint: localhost:9050
  groovy_script: test.groovy --labels [<key>:<value>, ...]
  collection_interval: 10s
@rmfitzpatrick rmfitzpatrick self-assigned this Apr 28, 2021
@rmfitzpatrick
Copy link
Contributor

@jatan28 after looking into this a bit I think the use case you're describing may better match resource attributes than labels for individual points. The metric gatherer uses the autoconfigure sdk extension that provides a property for setting these.

Allowing for arbitrary labels for each datapoint would require wrapping the OTel instrument methods to inject them, and this seems undesirable. The label function feature and labels parameter for recording values should already provide the ability to do this where desired in custom script functionality.

Would it be acceptable for me to add a properties config option in the JMX Receiver that will allow propagating these as system properties?

 jmx/service1:
  jar_path: /home/opentelemetry-java-contrib-jmx-metrics-0.0.1-SNAPSHOT.jar
  endpoint: localhost:9050
  target_system: jvm
  properties: 
     - otel.resource.attributes=my.resource.attr=attrvalue,my.other.resource.attr=othervalue
  collection_interval: 10s

The Collector's configuration library doesn't support case sensitive map keys, so I think this would need to be an array of strings to reduce the potential for unexpected behavior.

@jatan28
Copy link
Author

jatan28 commented May 4, 2021

@rmfitzpatrick Yes, this solution would solve the problem in hand. With this and a custom groovy script, we should be able to differentiate the jmx metrics

@rmfitzpatrick
Copy link
Contributor

@jatan28 appears the Collector contrib project has just released a new version with the added functionality in the JMX receiver: https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.28.0

https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/jmxreceiver#properties

Thanks for your patience, and if you run into any issues using it please don't hesitate to open an issue in that project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants