GithubHelp home page GithubHelp logo

Comments (39)

brian-brazil avatar brian-brazil commented on July 30, 2024 35

We recommend always using the java agent, if you go against that and use the http server this is one of the issues you'll run into.

from jmx_exporter.

ppatierno avatar ppatierno commented on July 30, 2024 22

@brian-brazil Hi ... reading this issue I don't see any real reason why the HTTP server mode doesn't support JVM metrics and what do you mean saying "they'd be confusing". I'm thinking about using it within a "sidecar" approach on Kubernetes/OpenShift but it seems that you really discourage the HTTP server mode. Can you explain better why ? It's something related to maintaining the source code because it will be deprecated in a near future or there are some technical reasons ?

from jmx_exporter.

alanorth avatar alanorth commented on July 30, 2024 14

Those metrics should always be exported, but they're not enabled for the http server as they'd be confusing.

@brian-brazil can you add some sort of tip to the readme that jvm_* metrics are only exposed when using the Java agent? It took me an hour or two of troubleshooting and searching old issues to figure this out, after playing only with the HTTP server version. Thanks!

from jmx_exporter.

brian-brazil avatar brian-brazil commented on July 30, 2024 13

I've tried to keep the readme light on the http server, so that users would follow the easy path and use the agent as that's what's most clearly documented and works best. At the end of the day users often over-complicate things for themselves, and I can't stop all of them.

Do you have wording you'd suggest?

from jmx_exporter.

mdione-cloudian avatar mdione-cloudian commented on July 30, 2024 12

This is the final set of patterns I'm using:

- pattern: 'java.lang<type=Memory><(\w+)MemoryUsage>(\w+): (\d+)'
  name: jvm_memory_usage_$2_bytes
  labels:
    area: "$1"  # Heap/NonHeap
  value: $3
  type: GAUGE

# name is always the same, the name of the GC
- pattern: 'java.lang<type=GarbageCollector, name=[^,]+, key=([^>]+)><LastGcInfo, memoryUsageAfterGc>(used|commited): (\d+)'
  name: jvm_memory_after_gc_$2_bytes
  value: $3
  labels:
    space: $1
  type: GAUGE

- pattern: 'java.lang<type=GarbageCollector, name=[^>]+><LastGcInfo>duration: (\d+)'
  name: jvm_gc_duration_seconds
  value: $1
  type: GAUGE
  # Convert microseconds to seconds
  valueFactor: 0.000001

# java.lang<type=GarbageCollector, name=G1 Young Generation><>CollectionCount
- pattern: 'java.lang<type=GarbageCollector, name=([^>]+)><>CollectionCount: (\d+)'
  name: jvm_gc_collection_count
  value: $2
  labels:
    name: $1
  type: GAUGE

from jmx_exporter.

agolomoodysaada avatar agolomoodysaada commented on July 30, 2024 11

I would like to re-open this issue @brian-brazil. All the process metrics for Kafka are available through JMX. Since we're running the httpserver against the kafka JMX metrics, it makes sense to have an example for the JVM metrics since they're already available.

Also, I think your logic here is extremely confusing

they're not enabled for the http server as they'd be confusing.

Having inconsistent and undocumented defaults is even more confusing.

from jmx_exporter.

alanorth avatar alanorth commented on July 30, 2024 11

We recommend always using the java agent, if you go against that and use the http server this is one of the issues you'll run into.

@brian-brazil yes I understand that now, but only after an hour or two of troubleshooting and reading the GitHub issues. My comment above was a suggestion that you should make it more obvious in the readme.

The readme isn't very helpful for new users, in my opinion. For example: I'm a sysadmin, not a Java developer. I don't know what JMX or a Java agent is, I'm just trying to monitor some application server! It took me a few hours to figure out how to get this thing running first of all, and then it's not obvious that the JVM metrics aren't exposed via the http server.

from jmx_exporter.

brian-brazil avatar brian-brazil commented on July 30, 2024 10

Those metrics should always be exported, but they're not enabled for the http server as they'd be confusing.

from jmx_exporter.

EdSchouten avatar EdSchouten commented on July 30, 2024 7

Brian,

I don't think the issue necessarily is that people don't know how to run this as an agent. It's more that the README doesn't explain the difference between running it as an agent or as a separate process. This is why this issue still gets some traffic once every couple of weeks/months of people who run into the same problems as I did.

The very top of the README currently has these two sentences right after each other:

It meant to be run as a Java Agent, exposing an HTTP server and scraping the local JVM.
This can be also run as an independent HTTP server and scrape remote JMX targets.

Would it make sense to extend this?

from jmx_exporter.

michaelbv avatar michaelbv commented on July 30, 2024 3

How do I drop values scraped by default i.e. not controlled by the exporter config?
Stuff like:
jmx_config_reload_success_total 0.0
jvm_memory_pool_bytes_committed{pool="Code Cache",}
Do I need to drop those in the relabeling phase?
I am running it as an agent.

from jmx_exporter.

brian-brazil avatar brian-brazil commented on July 30, 2024 3

Why do you want to drop them? They're all fairly important.

from jmx_exporter.

ppatierno avatar ppatierno commented on July 30, 2024 2

@brian-brazil any updated on the above question ?

from jmx_exporter.

DivsDibs avatar DivsDibs commented on July 30, 2024 2

@brian-brazil Hi Brian, might be too naive to ask, but I'm using the JMX Exporter as an agent as described in the robutsperception link, and I want to customize the name of the metric generated for jvm.* or process.* related metrics.. Reason being, the same jvm/process related metrics are generated by multiple targets and is fed into prometheus, which doesn't allow me to choose the metric from kafka node specifically. Couldn't figure out a way. Would be really helpful, if you please guide me in the right direction? Thanks

from jmx_exporter.

akamensky avatar akamensky commented on July 30, 2024 2

Oh wow, doing design choice because believing that other developers and users don't understand things about JVM?

There is no performance nor implementation limitations of why JVM metrics cannot be available over HTTP server, while there are number of reasons to not run this as a java agent. It is just developers of this tool own decision to not do it because they want so. Amazing.

from jmx_exporter.

brian-brazil avatar brian-brazil commented on July 30, 2024 1

The first section is https://github.com/prometheus/jmx_exporter#running which gives you a full example command line, I'm not sure it's possible to make it any simpler.

from jmx_exporter.

mcastelino avatar mcastelino commented on July 30, 2024 1

@mdione-cloudian we had to use a slightly modified version of your patterns to get java metrics out of kafka. /cc @sraghav1

    - pattern: 'java.lang<type=Memory><(\w+)MemoryUsage>(\w+): (\d+)'
      name: jvm_memory_usage_$2_bytes
      labels:
        area: "$1"  # Heap/NonHeap
      value: $3
      type: GAUGE
    - pattern: 'java.lang<name=([\s\w]+), type=GarbageCollector, key=(\w+)>(.*): (\d+)'
      name: jvm_gc_$3
      labels:
        name: $1
        key: $2
      value: $4
      type: GAUGE
    - pattern: 'java.lang<name=([\s\w]+), type=MemoryPool, key=(\w+)>(.*): (\d+)'
      name: jvm_mempool_$3
      labels:
        name: $1
        key: $2
      value: $4
      type: GAUGE
    - pattern: 'java.lang<name=([\s\w]+), type=GarbageCollector>(.*): (\d+)'
      name: jvm_gc_$2
      labels:
        name: $1
      value: $3
      type: GAUGE
    - pattern: 'java.lang<name=([\s\w]+), type=MemoryPool>(.*): (\d+)'
      name: jvm_mempool_$2
      labels:
        name: $1
      value: $3
      type: GAUGE

from jmx_exporter.

brian-brazil avatar brian-brazil commented on July 30, 2024

These shouldn't be in the examples, as the standard exports of the agent already provide these metrics in a better format.

from jmx_exporter.

EdSchouten avatar EdSchouten commented on July 30, 2024

Oh, wow. Running it separately or as an agent determines which metrics are exported by default? Interesting. Is this documented somewhere? What kind of metrics are exported by default when running as an agent?

from jmx_exporter.

EdSchouten avatar EdSchouten commented on July 30, 2024

Should we document this somewhere?

from jmx_exporter.

wfindley avatar wfindley commented on July 30, 2024

Oh. I just ran into this. How can I induce the http server to do things like jvm_memory_bytes_used?

from jmx_exporter.

brian-brazil avatar brian-brazil commented on July 30, 2024

Run it as a java agent.

from jmx_exporter.

hejix avatar hejix commented on July 30, 2024

Hi Brian, There are many good reasons to run the jmx_exporter separately as a server- the main one being able to change the metrics captured without having to restart the underlying process. Would appreciate either being able to turn on the standard jvm metrics or knowing the rules to enable them as mentioned by earlier posters.

from jmx_exporter.

brian-brazil avatar brian-brazil commented on July 30, 2024

the main one being able to change the metrics captured without having to restart the underlying process.

That doesn't require a restart.

from jmx_exporter.

michaelbv avatar michaelbv commented on July 30, 2024

I want to spend my bytes on other things.

A couple of items that would dramatically reduce the engineering cost of prometheus for us

  1. can you elaborate on

That doesn't require a restart.

How do I get it to reload the conf without restarting the process?

  1. I can't get the logging config to work so I get zero log output and haven't any idea why it fails. In most cases the apps I'm scraping are using several of log4j and logback and java.util.logging.

from jmx_exporter.

brian-brazil avatar brian-brazil commented on July 30, 2024

I want to spend my bytes on other things.

If you're so short on resource that this matters (which seems unlikely), you can drop them on the Prometheus end.

How do I get it to reload the conf without restarting the process?

Change the config file on disk.

In most cases the apps I'm scraping are using several of log4j and logback and java.util.logging.

If it's stats on those you want look at the simpleclient modules for those. Neither expose jmx metrics as far as I'm aware.

This has gotten way off-topic, so closing. Please ask usage questions on https://groups.google.com/forum/#!forum/prometheus-users

from jmx_exporter.

brian-brazil avatar brian-brazil commented on July 30, 2024

All the process metrics for Kafka are available through JMX.

Not all of them.

Use of the agent is recommended over the httpserver, and I do not wish to have to maintain two versions of the same bit of code/configuration.

from jmx_exporter.

agolomoodysaada avatar agolomoodysaada commented on July 30, 2024

Thank you for your response.
Is it possible to run the agent with Kafka? Do I have to restart kafka to attach the agent?

from jmx_exporter.

brian-brazil avatar brian-brazil commented on July 30, 2024

Yes, you need to restart kafka to attach it. https://www.robustperception.io/monitoring-kafka-with-prometheus/ has instructions.

from jmx_exporter.

agolomoodysaada avatar agolomoodysaada commented on July 30, 2024

Thank you, last question: are there plans to deprecate the httpserver?

from jmx_exporter.

brian-brazil avatar brian-brazil commented on July 30, 2024

No, there's no plans to do so.

from jmx_exporter.

EdSchouten avatar EdSchouten commented on July 30, 2024

@brian-brazil Any thoughts on #204?

from jmx_exporter.

mdione-cloudian avatar mdione-cloudian commented on July 30, 2024

@EdSchouten I fixed one of your patterns:

- pattern: 'java.lang<type=Memory><(\w+)MemoryUsage>(\w+): (\d+)'
  name: java_memory_usage_$2_bytes
  labels:
    area: "$1"
  value: $3
  # help: Java $2 $1 memory usage
  type: GAUGE

This returns:

# HELP java_memory_usage_used_bytes java.lang.management.MemoryUsage (java.lang<type=Memory><HeapMemoryUsage>used)
# TYPE java_memory_usage_used_bytes gauge
java_memory_usage_used_bytes{area="Heap",} 5.47159024E8
java_memory_usage_used_bytes{area="NonHeap",} 7.235664E7

You can change the help line as you want.

from jmx_exporter.

matiasba avatar matiasba commented on July 30, 2024

Does anyone have patters to collect thread and cpu metrics?

from jmx_exporter.

fstab avatar fstab commented on July 30, 2024

Maybe you don't need the jmx_exporter for that. You could just use the simpleclient_hotspot and call

new StandardExports().register();
new ThreadExports().register();

https://mvnrepository.com/artifact/io.prometheus/simpleclient_hotspot
https://github.com/prometheus/client_java/tree/master/simpleclient_hotspot

from jmx_exporter.

matiasba avatar matiasba commented on July 30, 2024

Sadly I'm trying to use this with a very legacy app that runs only on java 1.5. I need to use the jmx http agent as is. Does anyone knows how to get cpu a thread metrics using the http agent?

from jmx_exporter.

nareshb123 avatar nareshb123 commented on July 30, 2024

jmx_exporter agent is not exporting CPU metrics, can anyone suggest what need to be done.

from jmx_exporter.

mdione-cloudian avatar mdione-cloudian commented on July 30, 2024

@nareshb123 @matiasba asked for the same thing. Maybe he figured it out?

from jmx_exporter.

matiasba avatar matiasba commented on July 30, 2024

@nareshb123 @matiasba asked for the same thing. Maybe he figured it out?

Sadly I just gave up on this, there is very little documentation. I just told the dev team that they need to upgrade their java version of they want to use Prometheus.

from jmx_exporter.

ndimitry avatar ndimitry commented on July 30, 2024

@brian-brazil Just try to start java agent with JBoss/WildFly on Java11 and you will have much fun (spoiler: it just won't run, JBoss/WildFly won't start; and even running on Java8 is a quite a pain), so the http server and examples are useful in some cases.
You may state that there's a bug in JBoss/WildFly (and that might be a fairly right statement), but nevertheless we need monitoring data before bugs are fixed...

from jmx_exporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.